summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/declarative/calculator/CalcButton.qml2
-rw-r--r--demos/declarative/flickr/common/MediaButton.qml2
-rw-r--r--demos/declarative/flickr/common/MediaLineEdit.qml2
-rw-r--r--demos/declarative/flickr/common/Slider.qml2
-rw-r--r--demos/declarative/flickr/common/Star.qml2
-rw-r--r--demos/declarative/flickr/flickr-desktop.qml2
-rw-r--r--demos/declarative/flickr/mobile/Button.qml2
-rw-r--r--demos/declarative/flickr/mobile/GridDelegate.qml2
-rw-r--r--demos/declarative/minehunt/Description.qml2
-rw-r--r--demos/declarative/minehunt/minehunt.qml4
-rw-r--r--demos/declarative/samegame/content/Button.qml2
-rw-r--r--demos/declarative/samegame/content/Dialog.qml2
-rw-r--r--demos/declarative/samegame/samegame.qml2
-rw-r--r--demos/declarative/snake/content/Button.qml2
-rw-r--r--demos/declarative/snake/snake.qml2
-rw-r--r--demos/declarative/twitter/content/Button.qml2
-rw-r--r--demos/declarative/webbrowser/content/fieldtext/FieldText.qml6
-rw-r--r--demos/declarative/webbrowser/webbrowser.qml6
-rw-r--r--doc/src/declarative/advtutorial.qdoc324
-rw-r--r--doc/src/declarative/advtutorial1.qdoc83
-rw-r--r--doc/src/declarative/advtutorial2.qdoc107
-rw-r--r--doc/src/declarative/advtutorial3.qdoc116
-rw-r--r--doc/src/declarative/advtutorial4.qdoc159
-rw-r--r--doc/src/declarative/animation.qdoc4
-rw-r--r--doc/src/declarative/basictypes.qdoc2
-rw-r--r--doc/src/declarative/declarativeui.qdoc4
-rw-r--r--doc/src/declarative/elements.qdoc2
-rw-r--r--doc/src/declarative/example-slideswitch.qdoc6
-rw-r--r--doc/src/declarative/examples.qdoc2
-rw-r--r--doc/src/declarative/extending-examples.qdoc14
-rw-r--r--doc/src/declarative/extending.qdoc2
-rw-r--r--doc/src/declarative/focus.qdoc2
-rw-r--r--doc/src/declarative/qmldebugging.qdoc2
-rw-r--r--doc/src/declarative/qmlintro.qdoc8
-rw-r--r--doc/src/declarative/qmlmodels.qdoc4
-rw-r--r--doc/src/declarative/qmlreference.qdoc4
-rw-r--r--doc/src/declarative/qmlstates.qdoc2
-rw-r--r--doc/src/declarative/qtbinding.qdoc8
-rw-r--r--doc/src/declarative/scope.qdoc2
-rw-r--r--doc/src/declarative/tutorial.qdoc189
-rw-r--r--doc/src/declarative/tutorial1.qdoc97
-rw-r--r--doc/src/declarative/tutorial2.qdoc112
-rw-r--r--doc/src/declarative/tutorial3.qdoc86
-rw-r--r--doc/src/development/qmake-manual.qdoc2
-rw-r--r--doc/src/frameworks-technologies/activeqt.qdoc2
-rw-r--r--doc/src/getting-started/installation.qdoc2
-rw-r--r--doc/src/index.qdoc2
-rw-r--r--doc/src/legal/commercialeditions.qdoc79
-rw-r--r--doc/src/legal/editions.qdoc4
-rw-r--r--doc/src/legal/licenses.qdoc2
-rw-r--r--doc/src/legal/opensourceedition.qdoc1
-rw-r--r--doc/src/modules.qdoc61
-rw-r--r--doc/src/platforms/mac-differences.qdoc2
-rw-r--r--doc/src/snippets/declarative/drag.qml2
-rw-r--r--doc/src/snippets/declarative/mouseregion.qml4
-rw-r--r--doc/src/xml-processing/xml-patterns.qdoc3
-rw-r--r--examples/declarative/anchors/anchor-changes.qml2
-rw-r--r--examples/declarative/animations/easing.qml2
-rw-r--r--examples/declarative/aspectratio/face_fit.qml1
-rw-r--r--examples/declarative/aspectratio/face_fit_animated.qml1
-rw-r--r--examples/declarative/aspectratio/scale_and_crop.qml1
-rw-r--r--examples/declarative/aspectratio/scale_and_sidecrop.qml1
-rw-r--r--examples/declarative/aspectratio/scale_to_fit.qml1
-rw-r--r--examples/declarative/behaviours/MyRect.qml2
-rw-r--r--examples/declarative/behaviours/SideRect.qml2
-rw-r--r--examples/declarative/behaviours/test.qml2
-rw-r--r--examples/declarative/connections/content/Button.qml2
-rw-r--r--examples/declarative/dial/dial.qml2
-rw-r--r--examples/declarative/dynamic/qml/Button.qml2
-rw-r--r--examples/declarative/dynamic/qml/PaletteItem.qml2
-rw-r--r--examples/declarative/effects/effects.qml4
-rw-r--r--examples/declarative/extending/attached/birthdayparty.cpp14
-rw-r--r--examples/declarative/extending/attached/birthdayparty.h8
-rw-r--r--examples/declarative/extending/attached/main.cpp4
-rw-r--r--examples/declarative/extending/binding/birthdayparty.cpp14
-rw-r--r--examples/declarative/extending/binding/birthdayparty.h8
-rw-r--r--examples/declarative/extending/binding/main.cpp4
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.cpp14
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.h8
-rw-r--r--examples/declarative/extending/coercion/main.cpp5
-rw-r--r--examples/declarative/extending/default/birthdayparty.cpp14
-rw-r--r--examples/declarative/extending/default/birthdayparty.h8
-rw-r--r--examples/declarative/extending/default/main.cpp5
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.cpp14
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.h8
-rw-r--r--examples/declarative/extending/grouped/main.cpp4
-rw-r--r--examples/declarative/extending/properties/birthdayparty.cpp14
-rw-r--r--examples/declarative/extending/properties/birthdayparty.h8
-rw-r--r--examples/declarative/extending/properties/main.cpp4
-rw-r--r--examples/declarative/extending/signal/birthdayparty.cpp14
-rw-r--r--examples/declarative/extending/signal/birthdayparty.h8
-rw-r--r--examples/declarative/extending/signal/main.cpp4
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.cpp14
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.h9
-rw-r--r--examples/declarative/extending/valuesource/main.cpp4
-rw-r--r--examples/declarative/layouts/Button.qml2
-rw-r--r--examples/declarative/listview/content/ClickAutoRepeating.qml2
-rw-r--r--examples/declarative/listview/content/MediaButton.qml2
-rw-r--r--examples/declarative/listview/dynamic.qml12
-rw-r--r--examples/declarative/listview/itemlist.qml2
-rw-r--r--examples/declarative/listview/recipes.qml2
-rw-r--r--examples/declarative/mouseregion/mouse.qml4
-rw-r--r--examples/declarative/objectlistmodel/main.cpp2
-rw-r--r--examples/declarative/parallax/qml/ParallaxView.qml2
-rw-r--r--examples/declarative/searchbox/SearchBox.qml4
-rw-r--r--examples/declarative/slideswitch/content/Switch.qml4
-rw-r--r--examples/declarative/states/states.qml6
-rw-r--r--examples/declarative/states/transitions.qml6
-rw-r--r--examples/declarative/tabwidget/TabWidget.qml2
-rw-r--r--examples/declarative/tic-tac-toe/content/TicTac.qml2
-rw-r--r--examples/declarative/tutorials/helloworld/Cell.qml2
-rw-r--r--examples/declarative/tutorials/helloworld/tutorial3.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/Button.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/Button.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Button.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Dialog.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/Button.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/samegame.qml2
-rw-r--r--examples/declarative/velocity/Day.qml2
-rw-r--r--examples/declarative/webview/content/FieldText.qml6
-rw-r--r--examples/declarative/webview/evalandattach.html2
-rw-r--r--examples/declarative/webview/evalandattach.qml2
-rw-r--r--examples/declarative/workerscript/workerscript.qml4
-rw-r--r--examples/declarative/xmldata/yahoonews.qml2
-rw-r--r--examples/declarative/xmlhttprequest/test.qml2
-rw-r--r--src/3rdparty/libpng/pngconf.h2
-rw-r--r--src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc3
-rw-r--r--src/corelib/tools/qbytearray.cpp15
-rw-r--r--src/corelib/tools/qbytearray.h1
-rw-r--r--src/corelib/tools/qlist.cpp91
-rw-r--r--src/corelib/tools/qlist.h155
-rw-r--r--src/declarative/QmlChanges.txt7
-rw-r--r--src/declarative/graphicsitems/graphicsitems.pri6
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsborderimage.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsevents.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp57
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable_p.h8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h15
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflipable.cpp7
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimage.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.cpp195
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.h24
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem_p.h45
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp7
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp9
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmousearea.cpp (renamed from src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp)175
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmousearea_p.h (renamed from src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h)20
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmousearea_p_p.h (renamed from src/declarative/graphicsitems/qmlgraphicsmouseregion_p_p.h)12
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles.cpp23
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspath.cpp11
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspath_p.h4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview.cpp10
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview_p_p.h3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners.cpp39
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrectangle.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrectangle_p.h4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrepeater.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstext.cpp14
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstext_p_p.h2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextedit.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextinput.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp38
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview.cpp25
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview_p.h4
-rw-r--r--src/declarative/qml/qml.h10
-rw-r--r--src/declarative/qml/qml.pri5
-rw-r--r--src/declarative/qml/qmlbinding.cpp2
-rw-r--r--src/declarative/qml/qmlcompiler.cpp103
-rw-r--r--src/declarative/qml/qmlcomponent.cpp2
-rw-r--r--src/declarative/qml/qmlcontext.cpp26
-rw-r--r--src/declarative/qml/qmlcontext.h4
-rw-r--r--src/declarative/qml/qmlcontext_p.h3
-rw-r--r--src/declarative/qml/qmlcontextscriptclass.cpp9
-rw-r--r--src/declarative/qml/qmldom.cpp1
-rw-r--r--src/declarative/qml/qmlengine.cpp39
-rw-r--r--src/declarative/qml/qmlengine_p.h6
-rw-r--r--src/declarative/qml/qmlenginedebug.cpp10
-rw-r--r--src/declarative/qml/qmlerror.cpp1
-rw-r--r--src/declarative/qml/qmlexpression.cpp3
-rw-r--r--src/declarative/qml/qmlinstruction.cpp6
-rw-r--r--src/declarative/qml/qmlinstruction_p.h2
-rw-r--r--src/declarative/qml/qmllist.cpp312
-rw-r--r--src/declarative/qml/qmllist.h140
-rw-r--r--src/declarative/qml/qmllist_p.h85
-rw-r--r--src/declarative/qml/qmllistscriptclass.cpp72
-rw-r--r--src/declarative/qml/qmllistscriptclass_p.h5
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp92
-rw-r--r--src/declarative/qml/qmlmetaproperty.h1
-rw-r--r--src/declarative/qml/qmlmetatype.cpp181
-rw-r--r--src/declarative/qml/qmlmetatype.h56
-rw-r--r--src/declarative/qml/qmlmoduleplugin.cpp1
-rw-r--r--src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp1
-rw-r--r--src/declarative/qml/qmlobjectscriptclass.cpp4
-rw-r--r--src/declarative/qml/qmlparserstatus.cpp1
-rw-r--r--src/declarative/qml/qmlprivate.h177
-rw-r--r--src/declarative/qml/qmlpropertycache.cpp2
-rw-r--r--src/declarative/qml/qmlpropertycache_p.h1
-rw-r--r--src/declarative/qml/qmlscript.cpp2
-rw-r--r--src/declarative/qml/qmlscriptstring.cpp1
-rw-r--r--src/declarative/qml/qmlvme.cpp60
-rw-r--r--src/declarative/qml/qmlvmemetaobject.cpp36
-rw-r--r--src/declarative/qml/qmlvmemetaobject_p.h31
-rw-r--r--src/declarative/util/qmlanimation.cpp65
-rw-r--r--src/declarative/util/qmlanimation_p.h20
-rw-r--r--src/declarative/util/qmlanimation_p_p.h36
-rw-r--r--src/declarative/util/qmlbind.cpp1
-rw-r--r--src/declarative/util/qmlconnection.cpp7
-rw-r--r--src/declarative/util/qmldatetimeformatter.cpp1
-rw-r--r--src/declarative/util/qmleasefollow.cpp11
-rw-r--r--src/declarative/util/qmllistaccessor.cpp134
-rw-r--r--src/declarative/util/qmllistaccessor_p.h7
-rw-r--r--src/declarative/util/qmllistmodel.cpp2
-rw-r--r--src/declarative/util/qmlnumberformatter.cpp1
-rw-r--r--src/declarative/util/qmlpackage.cpp40
-rw-r--r--src/declarative/util/qmlpackage_p.h4
-rw-r--r--src/declarative/util/qmlpixmapcache.cpp29
-rw-r--r--src/declarative/util/qmlpropertychanges.cpp5
-rw-r--r--src/declarative/util/qmlpropertymap.cpp1
-rw-r--r--src/declarative/util/qmlstate.cpp21
-rw-r--r--src/declarative/util/qmlstate_p.h7
-rw-r--r--src/declarative/util/qmlstate_p_p.h33
-rw-r--r--src/declarative/util/qmlstategroup.cpp53
-rw-r--r--src/declarative/util/qmlstategroup_p.h8
-rw-r--r--src/declarative/util/qmltimeline.cpp47
-rw-r--r--src/declarative/util/qmltimeline_p_p.h43
-rw-r--r--src/declarative/util/qmltransition.cpp31
-rw-r--r--src/declarative/util/qmltransition_p.h4
-rw-r--r--src/declarative/util/qmlview.cpp31
-rw-r--r--src/declarative/util/qmlview.h4
-rw-r--r--src/declarative/util/qmlxmllistmodel.cpp79
-rw-r--r--src/declarative/util/qmlxmllistmodel_p.h4
-rw-r--r--src/declarative/widgets/graphicslayouts.cpp4
-rw-r--r--src/declarative/widgets/graphicslayouts_p.h83
-rw-r--r--src/declarative/widgets/graphicswidgets.cpp72
-rw-r--r--src/gui/graphicsview/qgraphicsview_p.h2
-rw-r--r--src/gui/kernel/qapplication_x11.cpp116
-rw-r--r--src/gui/kernel/qcocoaapplication_mac.mm3
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm2
-rw-r--r--src/gui/kernel/qeventdispatcher_mac.mm74
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm4
-rw-r--r--src/gui/kernel/qt_x11_p.h5
-rw-r--r--src/gui/kernel/qwidget_mac.mm5
-rw-r--r--src/gui/text/qstatictext.h4
-rw-r--r--src/gui/util/qsystemtrayicon_mac.mm2
-rw-r--r--src/gui/widgets/qabstractscrollarea_p.h2
-rw-r--r--src/multimedia/base/qmediaserviceprovider.cpp6
-rw-r--r--src/multimedia/playback/qmediaplayer.cpp5
-rw-r--r--src/multimedia/qml/qmlaudio.cpp2
-rw-r--r--src/multimedia/qml/qmlgraphicsvideo.cpp2
-rw-r--r--src/multimedia/qml/qsoundeffect.cpp12
-rw-r--r--src/multimedia/qml/qsoundeffect_p.h2
-rw-r--r--src/multimedia/qml/qsoundeffect_pulse_p.cpp18
-rw-r--r--src/multimedia/qml/qsoundeffect_pulse_p.h2
-rw-r--r--src/multimedia/qml/qsoundeffect_qmedia_p.cpp8
-rw-r--r--src/multimedia/qml/qsoundeffect_qmedia_p.h2
-rw-r--r--src/multimedia/qml/qsoundeffect_qsound_p.cpp2
-rw-r--r--src/multimedia/qml/wavedecoder_p.cpp4
-rw-r--r--src/network/socket/qnativesocketengine.cpp6
-rw-r--r--src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm5
-rw-r--r--src/plugins/mediaservices/qt7/qcvdisplaylink.mm3
-rw-r--r--src/plugins/mediaservices/qt7/qt7movievideowidget.h2
-rw-r--r--src/plugins/mediaservices/qt7/qt7movieviewoutput.mm4
-rw-r--r--src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm2
-rw-r--r--src/script/api/qscriptengine.cpp929
-rw-r--r--src/script/api/qscriptengine_p.h521
-rw-r--r--src/script/api/qscriptvalue.cpp525
-rw-r--r--src/script/api/qscriptvalue_p.h24
-rw-r--r--src/script/bridge/qscriptclassobject.cpp2
-rw-r--r--src/script/bridge/qscriptdeclarativeclass.cpp16
-rw-r--r--src/script/bridge/qscriptqobject.cpp106
-rw-r--r--src/script/bridge/qscriptvariant.cpp2
-rw-r--r--src/testlib/qbenchmark.h2
-rw-r--r--src/testlib/qtestcase.cpp6
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/declarative/declarative.pro3
-rw-r--r--tests/auto/declarative/qmlanimations/data/badtype4.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/dotproperty.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/mixedtype1.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/mixedtype2.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/propertiesTransition.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml2
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/binding.qml4
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/color.qml4
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml2
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/disabled.qml2
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/empty.qml2
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/explicit.qml4
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/groupProperty.qml4
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml4
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml2
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/parent.qml2
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml2
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml2
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/simple.qml4
-rw-r--r--tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp30
-rw-r--r--tests/auto/declarative/qmldebug/tst_qmldebug.cpp2
-rw-r--r--tests/auto/declarative/qmlecmascript/data/listProperties.qml21
-rw-r--r--tests/auto/declarative/qmlecmascript/testtypes.h11
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp13
-rw-r--r--tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp30
-rw-r--r--tests/auto/declarative/qmlgraphicsmousearea/data/dragproperties.qml (renamed from tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml)4
-rw-r--r--tests/auto/declarative/qmlgraphicsmousearea/qmlgraphicsmousearea.pro (renamed from tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro)2
-rw-r--r--tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp (renamed from tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp)14
-rw-r--r--tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp14
-rw-r--r--tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp8
-rw-r--r--tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp42
-rw-r--r--tests/auto/declarative/qmllanguage/data/interfaceQmlList.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/data/listAssignment.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/listAssignment.1.qml4
-rw-r--r--tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml2
-rw-r--r--tests/auto/declarative/qmllanguage/testtypes.h21
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp47
-rw-r--r--tests/auto/declarative/qmllist/data/MyType.qml5
-rw-r--r--tests/auto/declarative/qmllist/data/engineTypes.qml9
-rw-r--r--tests/auto/declarative/qmllist/data/variantToList.qml10
-rw-r--r--tests/auto/declarative/qmllist/tst_qmllist.cpp528
-rw-r--r--tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro5
-rw-r--r--tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp452
-rw-r--r--tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp35
-rw-r--r--tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp81
-rw-r--r--tests/auto/declarative/qmlstates/data/illegalTempState.qml2
-rw-r--r--tests/auto/declarative/qmlstates/data/legalTempState.qml2
-rw-r--r--tests/auto/declarative/qmlstates/data/parentChange.qml2
-rw-r--r--tests/auto/declarative/qmlstates/data/parentChange2.qml2
-rw-r--r--tests/auto/declarative/qmlstates/data/parentChange3.qml2
-rw-r--r--tests/auto/declarative/qmlstates/data/parentChange4.qml2
-rw-r--r--tests/auto/declarative/qmlstates/data/parentChange5.qml2
-rw-r--r--tests/auto/declarative/qmlstates/tst_qmlstates.cpp48
-rw-r--r--tests/auto/declarative/visual/Package_Views/packageviews.qml4
-rw-r--r--tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml6
-rw-r--r--tests/auto/declarative/visual/animation/colorAnimation/colorAnimation.qml2
-rw-r--r--tests/auto/declarative/visual/animation/easing/easing.qml2
-rw-r--r--tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml2
-rw-r--r--tests/auto/declarative/visual/animation/parentAction/parentAction.qml2
-rw-r--r--tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml2
-rw-r--r--tests/auto/declarative/visual/animation/reanchor/reanchor.qml4
-rw-r--r--tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml2
-rw-r--r--tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml8
-rw-r--r--tests/auto/declarative/visual/qmlgraphicspathview/test-pathview.qml2
-rw-r--r--tests/auto/declarative/visual/qmlmouseregion/drag.qml2
-rw-r--r--tests/auto/declarative/visual/qmlmouseregion/mouseregion.qml14
-rw-r--r--tests/auto/declarative/visual/qmlspringfollow/follow.qml2
-rw-r--r--tests/auto/declarative/visual/selftest_noimages/selftest_noimages.qml2
-rw-r--r--tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml2
-rw-r--r--tests/auto/qbytearray/tst_qbytearray.cpp13
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp3
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp25
-rw-r--r--tests/auto/symbols/tst_symbols.cpp12
-rw-r--r--tests/benchmarks/declarative/painting/paintbenchmark.cpp24
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml2
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml2
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml2
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml2
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml2
-rw-r--r--tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml2
-rw-r--r--tools/qdoc3/cppcodeparser.cpp13
-rw-r--r--tools/qdoc3/generator.cpp53
-rw-r--r--tools/qdoc3/generator.h8
-rw-r--r--tools/qdoc3/htmlgenerator.cpp49
-rw-r--r--tools/qdoc3/htmlgenerator.h3
-rw-r--r--tools/qdoc3/node.cpp20
-rw-r--r--tools/qdoc3/node.h6
-rw-r--r--tools/qdoc3/test/qt-build-docs.qdocconf8
-rw-r--r--tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf8
-rw-r--r--tools/qdoc3/test/qt.qdocconf7
-rw-r--r--tools/qmlviewer/content/Browser.qml4
380 files changed, 4845 insertions, 4768 deletions
diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml
index 08851d0..6210e46 100644
--- a/demos/declarative/calculator/CalcButton.qml
+++ b/demos/declarative/calculator/CalcButton.qml
@@ -15,7 +15,7 @@ Rectangle {
Text { id: label; anchors.centerIn: parent; color: palette.buttonText }
- MouseRegion {
+ MouseArea {
id: clickRegion
anchors.fill: parent
onClicked: {
diff --git a/demos/declarative/flickr/common/MediaButton.qml b/demos/declarative/flickr/common/MediaButton.qml
index c12b642..86ac948 100644
--- a/demos/declarative/flickr/common/MediaButton.qml
+++ b/demos/declarative/flickr/common/MediaButton.qml
@@ -16,7 +16,7 @@ Item {
source: "pics/button-pressed.png"
opacity: 0
}
- MouseRegion {
+ MouseArea {
id: mouseRegion
anchors.fill: buttonImage
onClicked: { container.clicked(); }
diff --git a/demos/declarative/flickr/common/MediaLineEdit.qml b/demos/declarative/flickr/common/MediaLineEdit.qml
index b24b296..3dfd1f3 100644
--- a/demos/declarative/flickr/common/MediaLineEdit.qml
+++ b/demos/declarative/flickr/common/MediaLineEdit.qml
@@ -62,7 +62,7 @@ Item {
anchors.right: container.right
}
- MouseRegion {
+ MouseArea {
id: mouseRegion
anchors.fill: buttonImage
onClicked: { container.state = container.state=="Edit" ? "" : "Edit" }
diff --git a/demos/declarative/flickr/common/Slider.qml b/demos/declarative/flickr/common/Slider.qml
index fa1645c..05a87e7 100644
--- a/demos/declarative/flickr/common/Slider.qml
+++ b/demos/declarative/flickr/common/Slider.qml
@@ -27,7 +27,7 @@ Item {
GradientStop { position: 1.0; color: "gray" }
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent; drag.target: parent
drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: slider.xMax+2
onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; }
diff --git a/demos/declarative/flickr/common/Star.qml b/demos/declarative/flickr/common/Star.qml
index 173021b..8cd47b4 100644
--- a/demos/declarative/flickr/common/Star.qml
+++ b/demos/declarative/flickr/common/Star.qml
@@ -17,7 +17,7 @@ Item {
opacity: 0.4
scale: 0.5
}
- MouseRegion {
+ MouseArea {
anchors.fill: container
onClicked: { container.clicked() }
}
diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml
index 3848f12..1ca3cdc 100644
--- a/demos/declarative/flickr/flickr-desktop.qml
+++ b/demos/declarative/flickr/flickr-desktop.qml
@@ -61,7 +61,7 @@ Item {
}
}
- MouseRegion { anchors.fill: wrapper; onClicked: { photoClicked() } }
+ MouseArea { anchors.fill: wrapper; onClicked: { photoClicked() } }
states: [
State {
diff --git a/demos/declarative/flickr/mobile/Button.qml b/demos/declarative/flickr/mobile/Button.qml
index 770330c..4ba6b19 100644
--- a/demos/declarative/flickr/mobile/Button.qml
+++ b/demos/declarative/flickr/mobile/Button.qml
@@ -18,7 +18,7 @@ Item {
source: "images/toolbutton.sci"
width: container.width; height: container.height
}
- MouseRegion {
+ MouseArea {
id: mouseRegion
anchors.fill: buttonImage
onClicked: { container.clicked(); }
diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml
index 6c12896..0f5b69c 100644
--- a/demos/declarative/flickr/mobile/GridDelegate.qml
+++ b/demos/declarative/flickr/mobile/GridDelegate.qml
@@ -67,6 +67,6 @@
}
]
}
- MouseRegion { anchors.fill: wrapper; onClicked: { photoClicked() } }
+ MouseArea { anchors.fill: wrapper; onClicked: { photoClicked() } }
}
}
diff --git a/demos/declarative/minehunt/Description.qml b/demos/declarative/minehunt/Description.qml
index 440dd2e..cc4d3b2 100644
--- a/demos/declarative/minehunt/Description.qml
+++ b/demos/declarative/minehunt/Description.qml
@@ -4,7 +4,7 @@ Item {
id: page
height: myText.height + 20
property var text
- MouseRegion {
+ MouseArea {
anchors.fill: parent
drag.target: page
drag.axis: "XandYAxis"
diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml
index 18e8195..92555c2 100644
--- a/demos/declarative/minehunt/minehunt.qml
+++ b/demos/declarative/minehunt/minehunt.qml
@@ -101,7 +101,7 @@ Item {
}
}
]
- MouseRegion {
+ MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressed: {
@@ -188,7 +188,7 @@ Item {
anchors.right: field.right
anchors.rightMargin: 20
source: isPlaying ? 'pics/face-smile.png' : hasWon ? 'pics/face-smile-big.png': 'pics/face-sad.png'
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onPressed: { reset() }
}
diff --git a/demos/declarative/samegame/content/Button.qml b/demos/declarative/samegame/content/Button.qml
index 63cd555..6629302 100644
--- a/demos/declarative/samegame/content/Button.qml
+++ b/demos/declarative/samegame/content/Button.qml
@@ -17,7 +17,7 @@ Rectangle {
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
Text {
id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
diff --git a/demos/declarative/samegame/content/Dialog.qml b/demos/declarative/samegame/content/Dialog.qml
index 5bd1123..7769328 100644
--- a/demos/declarative/samegame/content/Dialog.qml
+++ b/demos/declarative/samegame/content/Dialog.qml
@@ -18,5 +18,5 @@ Rectangle {
NumberAnimation { duration: 1000 }
}
Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
- MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); }
+ MouseArea { id: mr; anchors.fill: parent; onClicked: forceClose(); }
}
diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml
index f5c4fc5..50f6293 100644
--- a/demos/declarative/samegame/samegame.qml
+++ b/demos/declarative/samegame/samegame.qml
@@ -28,7 +28,7 @@ Rectangle {
width: parent.width - (parent.width % getTileSize());
height: parent.height - (parent.height % getTileSize());
- MouseRegion {
+ MouseArea {
id: gameMR
anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y);
}
diff --git a/demos/declarative/snake/content/Button.qml b/demos/declarative/snake/content/Button.qml
index 63cd555..6629302 100644
--- a/demos/declarative/snake/content/Button.qml
+++ b/demos/declarative/snake/content/Button.qml
@@ -17,7 +17,7 @@ Rectangle {
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
Text {
id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml
index 58827a7..3bec747 100644
--- a/demos/declarative/snake/snake.qml
+++ b/demos/declarative/snake/snake.qml
@@ -101,7 +101,7 @@ Rectangle {
id: skull
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onPressed: {
if (!head || !heartbeat.running) {
diff --git a/demos/declarative/twitter/content/Button.qml b/demos/declarative/twitter/content/Button.qml
index 09d471c..4cba8c3 100644
--- a/demos/declarative/twitter/content/Button.qml
+++ b/demos/declarative/twitter/content/Button.qml
@@ -19,7 +19,7 @@ Item {
source: "images/toolbutton.sci"
width: container.width; height: container.height
}
- MouseRegion {
+ MouseArea {
id: mouseRegion
anchors.fill: buttonImage
onClicked: { container.clicked(); }
diff --git a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml
index b1c1938..19b6acc 100644
--- a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml
+++ b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml
@@ -93,17 +93,17 @@ Item {
}
}
- MouseRegion {
+ MouseArea {
anchors.fill: cancelIcon
onClicked: { reset() }
}
- MouseRegion {
+ MouseArea {
anchors.fill: confirmIcon
onClicked: { confirm() }
}
- MouseRegion {
+ MouseArea {
id: editRegion
anchors.fill: textEdit
onClicked: { edit() }
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml
index 8de13d5..934593c 100644
--- a/demos/declarative/webbrowser/webbrowser.qml
+++ b/demos/declarative/webbrowser/webbrowser.qml
@@ -103,7 +103,7 @@ Item {
}
}
]
- MouseRegion {
+ MouseArea {
anchors.fill: back_e
onClicked: { if (webView.back.enabled) webView.back.trigger() }
}
@@ -114,7 +114,7 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
- MouseRegion {
+ MouseArea {
anchors.fill: reload
onClicked: { webView.reload.trigger() }
}
@@ -159,7 +159,7 @@ Item {
}
}
]
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: { if (webView.forward.enabled) webView.forward.trigger() }
}
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc
index 43dc81e..b7d964c 100644
--- a/doc/src/declarative/advtutorial.qdoc
+++ b/doc/src/declarative/advtutorial.qdoc
@@ -40,8 +40,10 @@
****************************************************************************/
/*!
-\page advtutorial.html
-\title Advanced Tutorial
+\page qml-advtutorial.html
+\title QML Advanced Tutorial
+\brief A more advanced tutorial, showing how to use QML to create a game.
+\nextpage QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks
This tutorial goes step-by-step through creating a full application using just QML.
It is assumed that you already know basic QML (such as from doing the simple tutorial) and the focus is on showing
@@ -49,16 +51,324 @@ how to turn that knowledge into a complete and functioning application.
This tutorial involves a significant amount of JavaScript to implement the game logic. An understanding of JavaScript is helpful to understand the JavaScript parts of this tutorial, but if you don't understand JavaScript you can still get a feel for how to integrate QML elements with backend logic which creates and controls them. From the QML perspective, there is little difference between integrating with backend logic written in C++ and backend logic written in JavaScript.
-In this tutorial we recreate, step by step, the Same Game demo in $QTDIR/demos/declarative/samegame.qml.
+In this tutorial we recreate, step by step, a version of the Same Game demo in $QTDIR/demos/declarative/samegame.qml.
The results of the individual steps are in the $QTDIR/examples/declarative/tutorials/samegame directory.
+The Same Game demo has been extended since this tutorial was written. This tutorial only covers the version in
+the $QTDIR/examples/declarative/tutorials/samegame directory. However once you have completed the tutorial you should be able
+to understand the extensions in the most recent Same Game demo, and even extend it yourself.
+
Tutorial chapters:
\list
-\o \l {Advanced Tutorial 1 - Creating the Game Canvas and Blocks}
-\o \l {Advanced Tutorial 2 - Populating the Game Canvas}
-\o \l {Advanced Tutorial 3 - Implementing the Game Logic}
-\o \l {Advanced Tutorial 4 - Finishing Touches}
+\o \l {QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks}
+\o \l {QML Advanced Tutorial 2 - Populating the Game Canvas}
+\o \l {QML Advanced Tutorial 3 - Implementing the Game Logic}
+\o \l {QML Advanced Tutorial 4 - Finishing Touches}
+\endlist
+*/
+
+/*!
+\page qml-advtutorial1.html
+\title QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks
+\contentspage QML Advanced Tutorial
+\previouspage QML Advanced Tutorial
+\nextpage QML Advanced Tutorial 2 - Populating the Game Canvas
+
+The first step is to create the items in your application. In Same Game we have a main game screen and the blocks that populate it.
+
+\image declarative-adv-tutorial1.png
+
+Here is the QML code for the basic elements. The game window:
+
+\snippet declarative/tutorials/samegame/samegame1/samegame.qml 0
+
+This gives you a basic game window, with room for the game canvas. A new game
+button and room to display the score. The one thing you may not recognize here
+is the \l SystemPalette item. This item provides access to the Qt system palette
+and is used to make the button look more like a system button (for exact native
+feel you would use a \l QPushButton). Since we want a fully functional button,
+we use the QML elements Text and MouseArea inside a Rectangle to assemble a
+button. Below is the code which we wrote to do this:
+
+\snippet declarative/tutorials/samegame/samegame1/Button.qml 0
+
+Note that this Button component was written to be fairly generic, in case we
+want to use a similarly styled button later.
+
+And here is a simple block:
+
+\snippet declarative/tutorials/samegame/samegame1/Block.qml 0
+
+Since it doesn't do anything yet it's very simple, just an image. As the
+tutorial progresses and the block starts doing things the file will become
+more than just an image. Note that we've set the image to be the size of the item.
+This will be used later, when we dynamically create and size the block items the image will be scaled automatically
+to the correct size.
+
+You should be familiar with all that goes on in these files so far. This is a
+very basic start and doesn't move at all - next we will populate the game canvas
+with some blocks.
+*/
+
+
+/*!
+\page qml-advtutorial2.html
+\title QML Advanced Tutorial 2 - Populating the Game Canvas
+\contentspage QML Advanced Tutorial
+\previouspage QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks
+\nextpage QML Advanced Tutorial 3 - Implementing the Game Logic
+
+Now that we've written some basic elements, let's start writing the game. The
+first thing to do is to generate all of the blocks. Now we need to dynamically
+generate all of these blocks, because you have a new, random set of blocks
+every time. As they are dynamically generated every time the new game button is
+clicked, as opposed to on startup, we will be dynamically generating the blocks
+in the JavaScript, as opposed to using a \l Repeater.
+
+This adds enough script to justify a new file, \c{samegame.js}, the intial version
+of which is shown below
+
+\snippet declarative/tutorials/samegame/samegame2/samegame.js 0
+
+The gist of this code is that we create the blocks dynamically, as many as will fit, and then store them in an array for future reference.
+The \c initBoard function will be hooked up to the new game button soon, and should be fairly straight forward.
+
+The \c createBlock function is a lot bigger, and I'll explain it block by block.
+First we ensure that the component has been constructed. QML elements, including composite ones like the \c Block.qml
+that we've written, are never created directly in script. While there is a function to parse and create an arbitrary QML string,
+in the case where you are repeatedly creating the same item you will want to use the \c createComponent function. \c createComponent is
+a built-in function in the declarative JavaScript, and returns a component object.
+A component object prepares and stores a QML element (usually a composite element) for easy and efficient use.
+When the component is ready, you can create a new instance of the loaded QML with the \c createObject method.
+If the component is loaded remotely (over HTTP for example) then you will have to wait for the component to finish loading
+before calling \c createObject. Since we don't wait here (the waiting is asyncronous, the component object will send a signal to tell
+you when it's done) this code will only work if the block QML is a local file.
+
+As we aren't waiting for the component, the next block of code creates a game block with \c{component.createObject}.
+Since there could be an error in the QML file you are trying to load, success is not guaranteed.
+The first bit of error checkign code comes right after \c{createObject()}, to ensure that the object loaded correctly.
+If it did not load correctly the function returns false, but we don't have that hooked up to the main UI to indicate
+that something has gone wrong. Instead we print out error messages to the console, because an error here means an invalid
+QML file and should only happen while you are developing and testing the UI.
+
+Next we start to set up our dynamically created block.
+Because the \c{Block.qml} file is generic it needs to be placed in the main scene, and in the right place.
+This is why \c parent, \c x, \c y, \c width and \c height are set. We then store it in the board array for later use.
+
+Finally, we have some more error handling. You can only call \c{createObject} if the component has loaded.
+If it has not loaded, either it is still loading or there was an error loading (such as a missing file).
+Since we don't request remote files the problem is likely to be a missing or misplaced file.
+Again we print this to the console to aid debugging.
+
+You now have the code to create a field of blocks dynamically, like below:
+
+\image declarative-adv-tutorial2.png
+
+To hook this code up to the \e{New Game} button, you alter it as below:
+
+\snippet declarative/tutorials/samegame/samegame2/samegame.qml 1
+
+We have just replaced the \c{onClicked: console.log("Implement me!")} with \c{onClicked: initBoard()}.
+Note that in order to have the function available, you'll need to include the script in the main file,
+by adding a script element to it.
+
+\snippet declarative/tutorials/samegame/samegame2/samegame.qml 2
+
+With those two changes, and the script file, you are now dynamically creating a field of blocks you can play with.
+They don't do anything now though; the next chapter will add the game mechanics.
+*/
+
+/*!
+\page qml-advtutorial3.html
+\title QML Advanced Tutorial 3 - Implementing the Game Logic
+\contentspage QML Advanced Tutorial
+\previouspage QML Advanced Tutorial 2 - Populating the Game Canvas
+\nextpage QML Advanced Tutorial 4 - Finishing Touches
+
+First we add to the \c initBoard function clearing of the board before filling it up again, so that clicking new game won't leave the previous game
+lying around in the background. To the \c createComponent function we have added setting the type of the block to a number between
+one and three - it's fundamental to the game logic that the blocks be different types if you want a fun game.
+
+The main change was adding the following game logic functions:
+\list
+\o function \c{handleClick(x,y)}
+\o function \c{floodFill(xIdx,yIdx,type)}
+\o function \c{shuffleDown()}
+\o function \c{victoryCheck()}
+\o function \c{floodMoveCheck(xIdx, yIdx, type)}
\endlist
+As this is a tutorial about QML, not game design, these functions will not be discussed in detail. The game logic here
+was written in script, but it could have been written in C++ and had these functions exposed in the same way (except probably faster).
+The interfacing of these functions and QML is what we will focus on. Of these functions, only \c handleClick and \c victoryCheck
+interface closely with the QML. Those functions are shown below (the rest are still in the code for this tutorial located at
+\c{$QTDIR/examples/declarative/tutorials/samegame}).
+
+\snippet declarative/tutorials/samegame/samegame3/samegame.js 1
+\snippet declarative/tutorials/samegame/samegame3/samegame.js 2
+
+You'll notice them referring to the \c gameCanvas item. This is an item that has been added to the QML for easier interfacing with the game logic.
+It is placed next to the background image and replaces the background as the item to create the blocks in.
+Its code is shown below:
+
+\snippet declarative/tutorials/samegame/samegame3/samegame.qml 1
+
+This item is the exact size of the board, contains a score property, and a mouse region for input.
+The blocks are now created as its children, and its size is used to determining the board size, so as to scale to the available screen size.
+Since it needs to bind its size to a multiple of \c tileSize, \c tileSize needs to be moved into a QML property and out of the script file.
+Note that it can still be accessed from the script.
+
+The mouse region simply calls \c{handleClick()}, which deals with the input events.
+Should those events cause the player to score, \c{gameCanvas.score} is updated.
+The score display text item has also been changed to bind its text property to \c{gamecanvas.score}.
+Note that if score was a global variable in the \c{samegame.js} file you could not bind to it. You can only bind to QML properties.
+
+\c victoryCheck() primarily updates the score variable. But it also pops up a dialog saying \e {Game Over} when the game is over.
+In this example we wanted a pure-QML, animated dialog, and since QML doesn't contain one, we wrote our own.
+Below is the code for the \c Dialog element, note how it's designed so as to be usable imperatively from within the script file (via the functions and signals):
+
+\snippet declarative/tutorials/samegame/samegame3/Dialog.qml 0
+
+And this is how it's used in the main QML file:
+
+\snippet declarative/tutorials/samegame/samegame3/samegame.qml 2
+
+Combined with the line of code in \c victoryCheck, this causes a dialog to appear when the game is over, informing the user of that fact.
+
+We now have a working game! The blocks can be clicked, the player can score, and the game can end (and then you start a new one).
+Below is a screenshot of what has been accomplished so far:
+
+\image declarative-adv-tutorial3.png
+
+Here is the QML code as it is now for the main file:
+
+\snippet declarative/tutorials/samegame/samegame3/samegame.qml 0
+
+And the code for the block:
+
+\snippet declarative/tutorials/samegame/samegame3/Block.qml 0
+
+The game works, but it's a little boring right now. Where are the smooth animated transitions? Where are the high scores?
+If you were a QML expert you could have written these in for the first iteration, but in this tutorial they've been saved
+until the next chapter - where your application becomes alive!
+*/
+
+/*!
+\page qml-advtutorial4.html
+\title QML Advanced Tutorial 4 - Finishing Touches
+\contentspage QML Advanced Tutorial
+\previouspage QML Advanced Tutorial 3 - Implementing the Game Logic
+
+Now we're going to do two things to liven the game up. Animate the blocks and add a web-based high score system.
+
+If you compare the \c samegame3 directory with \c samegame4, you'll noticed that we've cleaned the directory structure up.
+We now have a lot of files, and so they've been split up into folders - the most notable one being a content folder
+which we've placed all the QML but the main file.
+
+\section2 Animated Blocks
+
+The most vital animations are that the blocks move fluidly around the board. QML has many tools for fluid behavior,
+and in this case we're going to use the \l SpringFollow element. By having the script set \c targetX and \c targetY, instead of \c x
+and \c y directly, we can set the \c x and \c y of the block to a follow. \l SpringFollow is a property value source, which means
+that you can set a property to be one of these elements and it will automatically bind the property to the element's value.
+The SpringFollow's value follows another value over time, when the value it is tracking changes the SpringFollow's
+value will also change, but it will move smoothly there over time with a spring-like movement (based on the spring
+parameters specified). This is shown in the below snippet of code from \c Block.qml:
+
+\code
+ property int targetX: 0
+ property int targetY: 0
+
+ x: SpringFollow { source: targetX; spring: 2; damping: 0.2 }
+ y: SpringFollow { source: targetY; spring: 2; damping: 0.2 }
+\endcode
+
+We also have to change the \c{samegame.js} code, so that wherever it was setting the \c x or \c y it now sets \c targetX and \c targetY
+(including when creating the block). This simple change is all you need to get spring moving blocks that no longer teleport
+around the board. If you try doing just this though, you'll notice that they now never jump from one point to another, even in
+the initialization! This gives an odd effect of having them all slide out of the corner (0,0) on start up. We'd rather that they
+fall down from the top in rows. To do this, we disable the \c x follow (but not the \c y follow) and only enable it after we've set
+the \c x in the \c createBlock function. The above snippet now becomes:
+
+\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 1
+
+The next-most vital animation is a smooth exit. For this animation, we'll use a \l Behavior element. A Behavior is also a property
+value source, and it is much like SpringFollow except that it doesn't model the behavior of a spring. You specify how a Behavior
+transitions using the standard animations. As we want the blocks to smoothly fade in and out we'll set a Behavior on the block
+image's opacity, like so:
+
+\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 2
+
+Note that the \c{opacity: 0} makes it start out transparent. We could set the opacity in the script file when we create and destroy the blocks,
+but instead we use states (as this is useful for the next animation we'll implement). The below snippet is set on the root
+element of \c{Block.qml}:
+\code
+ property bool dying: false
+ states: [
+ State{ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ }, State{ name: "DeathState"; when: dying == true
+ PropertyChanges { target: img; opacity: 0 }
+ }
+ ]
+\endcode
+
+Now it will automatically fade in, as we set spawned to true already when implementing the block movement animations.
+To fade out, we set 'dying' to true instead of setting opacity to 0 when a block is destroyed (in the \c floodFill function).
+
+The least vital animations are a cool-looking particle effect when they get destroyed. First we create a \l Particles element in
+the block, like so:
+
+\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 3
+
+To fully understand this you'll want to look at the Particles element documentation, but it's important to note that emissionRate is set
+to zero, so that no particles are emitted normally.
+We next extend the 'dying' state, which creates a burst of particles by calling the burst method on the particles element. The code for the states now look
+like this:
+
+\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 4
+
+And now the game should be beautifully animated and smooth, with a subtle (or not-so-subtle) animation added for all of the
+player's actions. The end result is shown below, with a different set of images to demonstrate basic themeing:
+
+\image declarative-adv-tutorial4.gif
+
+The basic theme change there is the result of simply replacing the images. This can be done at run time by setting the source property, so a further advanced feature to try on your own is to add a button which toggles between two different themes.
+
+\section2 Offline High Scores
+Another extension we might want for the game is some way of storing and retrieving high scores. This tutorial contains both online and offline high score storage.
+
+For better high score data, we want the name and time of the player. The time is obtained in the script fairly simply, but we
+have to ask the player for their name. We thus re-use the dialog QML file to pop up a dialog asking for the player's name (and
+if they exit this dialog without entering it they have a way to opt out of posting their high score). When the dialog is closed we store the name and high score, using the code below.
+
+\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 2
+
+For offline storage, we use the HTML 5 offline storage JavaScript API to maintain a persistant SQL database unique to this application. This first line in this function calls the function for the web-based high scores, described later, if it has been setup. Next we create an offline storage database for the high scores using openDatabase and prepare the data and SQL query that we want to use to save it. The offline storage API uses SQL queries for data manipulation and retrival, and in the db.transaction call we use three SQL queries to initialize the database (if necessary), and then add to and retrieve high scores. To use the returned data, we turn it into a string with one line per row returned, and show a dialog containing that string. For a more detailed explanation of the offline storage API in QML, consult the global object documentation.
+
+This is one way of storing and displaying high scores locally, but not the only way. A more complex alternative would have been to create a high score dialog component, and pass the results to it for processing and display (instead of resusing the Dialog). This would allow a more themable dialog that could present the high scores better. If your QML is the UI for a C++ application, you could also have passed the score to a C++ function to store it locally in a variety of ways, including a simple format without SQL or in another SQL database.
+
+\section2 Web-based High Scores
+
+You've seen how to store high scores locally, but it is also easy to integrate a web enabled high score storage into your QML application. This tutorial also shows you how to communicate the high scores to a web server. The implementation we've done is very
+simple - the high score data is posted to a php script running on a server somewhere, and that server then stores it and
+displays it to visitors. You could request an XML or QML file from that same server, which contained and displayed the scores,
+but that's beyond the scope of this tutorial. The php script we've used is available in the examples directory.
+
+if the player entered their name we can send the data to the web service in the following snippet out of the script file:
+
+\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 1
+
+This is the same \c XMLHttpRequest() as you'll find in browser JavaScript, and can be used in the same way to dynamically get XML
+or QML from the web service to display the high scores. We don't worry about the response in this case, we just post the high
+score data to the web server. If it had returned a QML file (or a URL to a QML file) you could instantiate it in much the same
+way as you did the blocks.
+
+An alternate way to access and submit web-based data would be to use QML elements designed for this purpose - XmlListModel
+makes it very easy to fetch and display XML based data such as RSS in a QML application (see the Flickr demo for an example).
+
+By following this tutorial you've now ben shown how to write a fully functional application in QML, with the application logic
+written in a script file and with both many fluid animations and being web-enabled. Congratulations, you should now be skilled
+enough to write entire applications in QML.
*/
diff --git a/doc/src/declarative/advtutorial1.qdoc b/doc/src/declarative/advtutorial1.qdoc
deleted file mode 100644
index 9c6ea71..0000000
--- a/doc/src/declarative/advtutorial1.qdoc
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page advtutorial1.html
-\title Advanced Tutorial 1 - Creating the Game Canvas and Blocks
-
-The first step is to create the items in your application. In Same Game we have a main game screen and the blocks that populate it.
-
-\image declarative-adv-tutorial1.png
-
-Here is the QML code for the basic elements. The game window:
-
-\snippet declarative/tutorials/samegame/samegame1/samegame.qml 0
-
-This gives you a basic game window, with room for the game canvas. A new game
-button and room to display the score. The one thing you may not recognize here
-is the \l SystemPalette item. This item provides access to the Qt system palette
-and is used to make the button look more like a system button (for exact native
-feel you would use a \l QPushButton). Since we want a fully functional button,
-we use the QML elements Text and MouseRegion inside a Rectangle to assemble a
-button. Below is the code which we wrote to do this:
-
-\snippet declarative/tutorials/samegame/samegame1/Button.qml 0
-
-Note that this Button component was written to be fairly generic, in case we
-want to use a similarly styled button later.
-
-And here is a simple block:
-
-\snippet declarative/tutorials/samegame/samegame1/Block.qml 0
-
-Since it doesn't do anything yet it's very simple, just an image. As the
-tutorial progresses and the block starts doing things the file will become
-more than just an image. Note that we've set the image to be the size of the item.
-This will be used later, when we dynamically create and size the block items the image will be scaled automatically
-to the correct size.
-
-You should be familiar with all that goes on in these files so far. This is a
-very basic start and doesn't move at all - next we will populate the game canvas
-with some blocks.
-
-[\l {advtutorial.html}{Advanced Tutorial}] [Next: \l {Advanced Tutorial 2 - Populating the Game Canvas}]
-*/
-
diff --git a/doc/src/declarative/advtutorial2.qdoc b/doc/src/declarative/advtutorial2.qdoc
deleted file mode 100644
index 4fe10c1..0000000
--- a/doc/src/declarative/advtutorial2.qdoc
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page advtutorial2.html
-\title Advanced Tutorial 2 - Populating the Game Canvas
-
-Now that we've written some basic elements, let's start writing the game. The
-first thing to do is to generate all of the blocks. Now we need to dynamically
-generate all of these blocks, because you have a new, random set of blocks
-every time. As they are dynamically generated every time the new game button is
-clicked, as opposed to on startup, we will be dynamically generating the blocks
-in the JavaScript, as opposed to using a \l Repeater.
-
-This adds enough script to justify a new file, \c{samegame.js}, the intial version
-of which is shown below
-
-\snippet declarative/tutorials/samegame/samegame2/samegame.js 0
-
-The gist of this code is that we create the blocks dynamically, as many as will fit, and then store them in an array for future reference.
-The \c initBoard function will be hooked up to the new game button soon, and should be fairly straight forward.
-
-The \c createBlock function is a lot bigger, and I'll explain it block by block.
-First we ensure that the component has been constructed. QML elements, including composite ones like the \c Block.qml
-that we've written, are never created directly in script. While there is a function to parse and create an arbitrary QML string,
-in the case where you are repeatedly creating the same item you will want to use the \c createComponent function. \c createComponent is
-a built-in function in the declarative JavaScript, and returns a component object.
-A component object prepares and stores a QML element (usually a composite element) for easy and efficient use.
-When the component is ready, you can create a new instance of the loaded QML with the \c createObject method.
-If the component is loaded remotely (over HTTP for example) then you will have to wait for the component to finish loading
-before calling \c createObject. Since we don't wait here (the waiting is asyncronous, the component object will send a signal to tell
-you when it's done) this code will only work if the block QML is a local file.
-
-As we aren't waiting for the component, the next block of code creates a game block with \c{component.createObject}.
-Since there could be an error in the QML file you are trying to load, success is not guaranteed.
-The first bit of error checkign code comes right after \c{createObject()}, to ensure that the object loaded correctly.
-If it did not load correctly the function returns false, but we don't have that hooked up to the main UI to indicate
-that something has gone wrong. Instead we print out error messages to the console, because an error here means an invalid
-QML file and should only happen while you are developing and testing the UI.
-
-Next we start to set up our dynamically created block.
-Because the \c{Block.qml} file is generic it needs to be placed in the main scene, and in the right place.
-This is why \c parent, \c x, \c y, \c width and \c height are set. We then store it in the board array for later use.
-
-Finally, we have some more error handling. You can only call \c{createObject} if the component has loaded.
-If it has not loaded, either it is still loading or there was an error loading (such as a missing file).
-Since we don't request remote files the problem is likely to be a missing or misplaced file.
-Again we print this to the console to aid debugging.
-
-You now have the code to create a field of blocks dynamically, like below:
-
-\image declarative-adv-tutorial2.png
-
-To hook this code up to the \e{New Game} button, you alter it as below:
-
-\snippet declarative/tutorials/samegame/samegame2/samegame.qml 1
-
-We have just replaced the \c{onClicked: console.log("Implement me!")} with \c{onClicked: initBoard()}.
-Note that in order to have the function available, you'll need to include the script in the main file,
-by adding a script element to it.
-
-\snippet declarative/tutorials/samegame/samegame2/samegame.qml 2
-
-With those two changes, and the script file, you are now dynamically creating a field of blocks you can play with.
-They don't do anything now though; the next chapter will add the game mechanics.
-
-[Previous: \l {Advanced Tutorial 1 - Creating the Game canvas and block}] [\l {advtutorial.html}{Advanced Tutorial}] [Next: \l {Advanced Tutorial 3 - Implementing the Game Logic}]
-
-*/
diff --git a/doc/src/declarative/advtutorial3.qdoc b/doc/src/declarative/advtutorial3.qdoc
deleted file mode 100644
index 0c53e74..0000000
--- a/doc/src/declarative/advtutorial3.qdoc
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page advtutorial3.html
-\title Advanced Tutorial 3 - Implementing the Game Logic
-
-First we add to the \c initBoard function clearing of the board before filling it up again, so that clicking new game won't leave the previous game
-lying around in the background. To the \c createComponent function we have added setting the type of the block to a number between
-one and three - it's fundamental to the game logic that the blocks be different types if you want a fun game.
-
-The main change was adding the following game logic functions:
-\list
-\o function \c{handleClick(x,y)}
-\o function \c{floodFill(xIdx,yIdx,type)}
-\o function \c{shuffleDown()}
-\o function \c{victoryCheck()}
-\o function \c{floodMoveCheck(xIdx, yIdx, type)}
-\endlist
-
-As this is a tutorial about QML, not game design, these functions will not be discussed in detail. The game logic here
-was written in script, but it could have been written in C++ and had these functions exposed in the same way (except probably faster).
-The interfacing of these functions and QML is what we will focus on. Of these functions, only \c handleClick and \c victoryCheck
-interface closely with the QML. Those functions are shown below (the rest are still in the code for this tutorial located at
-\c{$QTDIR/examples/declarative/tutorials/samegame}).
-
-\snippet declarative/tutorials/samegame/samegame3/samegame.js 1
-\snippet declarative/tutorials/samegame/samegame3/samegame.js 2
-
-You'll notice them referring to the \c gameCanvas item. This is an item that has been added to the QML for easier interfacing with the game logic.
-It is placed next to the background image and replaces the background as the item to create the blocks in.
-Its code is shown below:
-
-\snippet declarative/tutorials/samegame/samegame3/samegame.qml 1
-
-This item is the exact size of the board, contains a score property, and a mouse region for input.
-The blocks are now created as its children, and its size is used to determining the board size, so as to scale to the available screen size.
-Since it needs to bind its size to a multiple of \c tileSize, \c tileSize needs to be moved into a QML property and out of the script file.
-Note that it can still be accessed from the script.
-
-The mouse region simply calls \c{handleClick()}, which deals with the input events.
-Should those events cause the player to score, \c{gameCanvas.score} is updated.
-The score display text item has also been changed to bind its text property to \c{gamecanvas.score}.
-Note that if score was a global variable in the \c{samegame.js} file you could not bind to it. You can only bind to QML properties.
-
-\c victoryCheck() primarily updates the score variable. But it also pops up a dialog saying \e {Game Over} when the game is over.
-In this example we wanted a pure-QML, animated dialog, and since QML doesn't contain one, we wrote our own.
-Below is the code for the \c Dialog element, note how it's designed so as to be usable imperatively from within the script file (via the functions and signals):
-
-\snippet declarative/tutorials/samegame/samegame3/Dialog.qml 0
-
-And this is how it's used in the main QML file:
-
-\snippet declarative/tutorials/samegame/samegame3/samegame.qml 2
-
-Combined with the line of code in \c victoryCheck, this causes a dialog to appear when the game is over, informing the user of that fact.
-
-We now have a working game! The blocks can be clicked, the player can score, and the game can end (and then you start a new one).
-Below is a screenshot of what has been accomplished so far:
-
-\image declarative-adv-tutorial3.png
-
-Here is the QML code as it is now for the main file:
-
-\snippet declarative/tutorials/samegame/samegame3/samegame.qml 0
-
-And the code for the block:
-
-\snippet declarative/tutorials/samegame/samegame3/Block.qml 0
-
-The game works, but it's a little boring right now. Where are the smooth animated transitions? Where are the high scores?
-If you were a QML expert you could have written these in for the first iteration, but in this tutorial they've been saved
-until the next chapter - where your application becomes alive!
-
-[Previous: \l {Advanced Tutorial 2 - Populating the Game Canvas}] [\l {advtutorial.html}{Advanced Tutorial}] [Next: \l {Advanced Tutorial 4 - Finishing Touches}]
-
-*/
-
diff --git a/doc/src/declarative/advtutorial4.qdoc b/doc/src/declarative/advtutorial4.qdoc
deleted file mode 100644
index ca3b82f..0000000
--- a/doc/src/declarative/advtutorial4.qdoc
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page advtutorial4.html
-\title Advanced Tutorial 4 - Finishing Touches
-
-Now we're going to do two things to liven the game up. Animate the blocks and add a web-based high score system.
-
-If you compare the \c samegame3 directory with \c samegame4, you'll noticed that we've cleaned the directory structure up.
-We now have a lot of files, and so they've been split up into folders - the most notable one being a content folder
-which we've placed all the QML but the main file.
-
-\section2 Animated Blocks
-
-The most vital animations are that the blocks move fluidly around the board. QML has many tools for fluid behavior,
-and in this case we're going to use the \l SpringFollow element. By having the script set \c targetX and \c targetY, instead of \c x
-and \c y directly, we can set the \c x and \c y of the block to a follow. \l SpringFollow is a property value source, which means
-that you can set a property to be one of these elements and it will automatically bind the property to the element's value.
-The SpringFollow's value follows another value over time, when the value it is tracking changes the SpringFollow's
-value will also change, but it will move smoothly there over time with a spring-like movement (based on the spring
-parameters specified). This is shown in the below snippet of code from \c Block.qml:
-
-\code
- property int targetX: 0
- property int targetY: 0
-
- x: SpringFollow { source: targetX; spring: 2; damping: 0.2 }
- y: SpringFollow { source: targetY; spring: 2; damping: 0.2 }
-\endcode
-
-We also have to change the \c{samegame.js} code, so that wherever it was setting the \c x or \c y it now sets \c targetX and \c targetY
-(including when creating the block). This simple change is all you need to get spring moving blocks that no longer teleport
-around the board. If you try doing just this though, you'll notice that they now never jump from one point to another, even in
-the initialization! This gives an odd effect of having them all slide out of the corner (0,0) on start up. We'd rather that they
-fall down from the top in rows. To do this, we disable the \c x follow (but not the \c y follow) and only enable it after we've set
-the \c x in the \c createBlock function. The above snippet now becomes:
-
-\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 1
-
-The next-most vital animation is a smooth exit. For this animation, we'll use a \l Behavior element. A Behavior is also a property
-value source, and it is much like SpringFollow except that it doesn't model the behavior of a spring. You specify how a Behavior
-transitions using the standard animations. As we want the blocks to smoothly fade in and out we'll set a Behavior on the block
-image's opacity, like so:
-
-\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 2
-
-Note that the \c{opacity: 0} makes it start out transparent. We could set the opacity in the script file when we create and destroy the blocks,
-but instead we use states (as this is useful for the next animation we'll implement). The below snippet is set on the root
-element of \c{Block.qml}:
-\code
- property bool dying: false
- states: [
- State{ name: "AliveState"; when: spawned == true && dying == false
- PropertyChanges { target: img; opacity: 1 }
- }, State{ name: "DeathState"; when: dying == true
- PropertyChanges { target: img; opacity: 0 }
- }
- ]
-\endcode
-
-Now it will automatically fade in, as we set spawned to true already when implementing the block movement animations.
-To fade out, we set 'dying' to true instead of setting opacity to 0 when a block is destroyed (in the \c floodFill function).
-
-The least vital animations are a cool-looking particle effect when they get destroyed. First we create a \l Particles element in
-the block, like so:
-
-\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 3
-
-To fully understand this you'll want to look at the Particles element documentation, but it's important to note that emissionRate is set
-to zero, so that no particles are emitted normally.
-We next extend the 'dying' state, which creates a burst of particles by calling the burst method on the particles element. The code for the states now look
-like this:
-
-\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 4
-
-And now the game should be beautifully animated and smooth, with a subtle (or not-so-subtle) animation added for all of the
-player's actions. The end result is shown below, with a different set of images to demonstrate basic themeing:
-
-\image declarative-adv-tutorial4.gif
-
-The basic theme change there is the result of simply replacing the images. This can be done at run time by setting the source property, so a further advanced feature to try on your own is to add a button which toggles between two different themes.
-
-\section2 Offline High Scores
-Another extension we might want for the game is some way of storing and retrieving high scores. This tutorial contains both online and offline high score storage.
-
-For better high score data, we want the name and time of the player. The time is obtained in the script fairly simply, but we
-have to ask the player for their name. We thus re-use the dialog QML file to pop up a dialog asking for the player's name (and
-if they exit this dialog without entering it they have a way to opt out of posting their high score). When the dialog is closed we store the name and high score, using the code below.
-
-\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 2
-
-For offline storage, we use the HTML 5 offline storage JavaScript API to maintain a persistant SQL database unique to this application. This first line in this function calls the function for the web-based high scores, described later, if it has been setup. Next we create an offline storage database for the high scores using openDatabase and prepare the data and SQL query that we want to use to save it. The offline storage API uses SQL queries for data manipulation and retrival, and in the db.transaction call we use three SQL queries to initialize the database (if necessary), and then add to and retrieve high scores. To use the returned data, we turn it into a string with one line per row returned, and show a dialog containing that string. For a more detailed explanation of the offline storage API in QML, consult the global object documentation.
-
-This is one way of storing and displaying high scores locally, but not the only way. A more complex alternative would have been to create a high score dialog component, and pass the results to it for processing and display (instead of resusing the Dialog). This would allow a more themable dialog that could present the high scores better. If your QML is the UI for a C++ application, you could also have passed the score to a C++ function to store it locally in a variety of ways, including a simple format without SQL or in another SQL database.
-
-\section2 Web-based High Scores
-
-You've seen how to store high scores locally, but it is also easy to integrate a web enabled high score storage into your QML application. This tutorial also shows you how to communicate the high scores to a web server. The implementation we've done is very
-simple - the high score data is posted to a php script running on a server somewhere, and that server then stores it and
-displays it to visitors. You could request an XML or QML file from that same server, which contained and displayed the scores,
-but that's beyond the scope of this tutorial. The php script we've used is available in the examples directory.
-
-if the player entered their name we can send the data to the web service in the following snippet out of the script file:
-
-\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 1
-
-This is the same \c XMLHttpRequest() as you'll find in browser JavaScript, and can be used in the same way to dynamically get XML
-or QML from the web service to display the high scores. We don't worry about the response in this case, we just post the high
-score data to the web server. If it had returned a QML file (or a URL to a QML file) you could instantiate it in much the same
-way as you did the blocks.
-
-An alternate way to access and submit web-based data would be to use QML elements designed for this purpose - XmlListModel
-makes it very easy to fetch and display XML based data such as RSS in a QML application (see the Flickr demo for an example).
-
-By following this tutorial you've now ben shown how to write a fully functional application in QML, with the application logic
-written in a script file and with both many fluid animations and being web-enabled. Congratulations, you should now be skilled
-enough to write entire applications in QML.
-
-[Previous: \l {Advanced Tutorial 3 - Implementing the Game Logic}] [\l {advtutorial.html}{Advanced Tutorial}]
-*/
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index 1acc111..d80c3fa 100644
--- a/doc/src/declarative/animation.qdoc
+++ b/doc/src/declarative/animation.qdoc
@@ -110,7 +110,7 @@ PropertyAnimation {
Image {
id: image
source: "image.png"
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onPressed: animation.start()
}
@@ -251,7 +251,7 @@ State {
\o Update x from a script
\qml
-MouseRegion {
+MouseArea {
....
onClicked: redRect.x = 24;
}
diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc
index 16e0c2e..a260812 100644
--- a/doc/src/declarative/basictypes.qdoc
+++ b/doc/src/declarative/basictypes.qdoc
@@ -294,7 +294,7 @@
Actions are used like this:
\qml
- MouseRegion { onClicked: MyItem.myaction.trigger() }
+ MouseArea { onClicked: MyItem.myaction.trigger() }
State { name: "enabled"; when: MyItem.myaction.enabled == true }
Text { text: MyItem.someaction.text }
\endqml
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc
index 2bfc3d5..1129f00 100644
--- a/doc/src/declarative/declarativeui.qdoc
+++ b/doc/src/declarative/declarativeui.qdoc
@@ -73,8 +73,8 @@ completely new applications. QML is fully \l {Extending QML}{extensible from C+
\section1 Getting Started:
\list
\o \l {Introduction to the QML language}
-\o \l {Tutorial}{Tutorial: 'Hello World'}
-\o \l {advtutorial.html}{Tutorial: 'Same Game'}
+\o \l {QML Tutorial}{Tutorial: 'Hello World'}
+\o \l {QML Advanced Tutorial}{Tutorial: 'Same Game'}
\o \l {QML Examples and Walkthroughs}
\o \l {Using QML in C++ Applications}
\endlist
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index e8fb1e7..682a2ac 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -126,7 +126,7 @@ The following table lists the QML elements provided by the Qt Declarative module
\o
\list
-\o \l MouseRegion
+\o \l MouseArea
\o \l FocusScope
\endlist
diff --git a/doc/src/declarative/example-slideswitch.qdoc b/doc/src/declarative/example-slideswitch.qdoc
index 79b362e..d1b1066 100644
--- a/doc/src/declarative/example-slideswitch.qdoc
+++ b/doc/src/declarative/example-slideswitch.qdoc
@@ -84,15 +84,15 @@ the text will only be visible when the switch is on.
\snippet examples/declarative/slideswitch/content/Switch.qml 4
First, we create the background image of the switch.
-In order for the switch to toggle when the user clicks on the background, we add a \l{MouseRegion} as a child item of the image.
-A \c MouseRegion has a \c onClicked property that is triggered when the item is clicked. For the moment we will just call a
+In order for the switch to toggle when the user clicks on the background, we add a \l{MouseArea} as a child item of the image.
+A \c MouseArea has a \c onClicked property that is triggered when the item is clicked. For the moment we will just call a
\c toggle() function. We will see what this function does in a moment.
\snippet examples/declarative/slideswitch/content/Switch.qml 5
Then, we place the image of the knob on top of the background.
The interaction here is a little more complex. We want the knob to move with the finger when it is clicked. That is what the \c drag
-property of the \c MouseRegion is for. We also want to toggle the switch if the knob is released between state. We handle this case
+property of the \c MouseArea is for. We also want to toggle the switch if the knob is released between state. We handle this case
in the \c dorelease() function that is called in the \c onReleased property.
\section2 States
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc
index 7de7a19..0478731 100644
--- a/doc/src/declarative/examples.qdoc
+++ b/doc/src/declarative/examples.qdoc
@@ -80,7 +80,7 @@ These will be documented, and demonstrate how to achieve various things in QML.
\o \l{qmlexampletoggleswitch.html}{Toggle Switch}
\o \image switch-example.gif
\row
- \o \l{Advanced Tutorial}{SameGame}
+ \o \l{QML Advanced Tutorial}{SameGame}
\o \image declarative-adv-tutorial4.gif
\endtable
diff --git a/doc/src/declarative/extending-examples.qdoc b/doc/src/declarative/extending-examples.qdoc
index c569ee0..b84ae0e 100644
--- a/doc/src/declarative/extending-examples.qdoc
+++ b/doc/src/declarative/extending-examples.qdoc
@@ -105,15 +105,15 @@ The BirthdayParty class is declared like this:
\snippet examples/declarative/extending/properties/birthdayparty.h 3
The class contains a member to store the celebrant object, and also a
-QmlConcreteList<Person *> member.
+QList<Person *> member.
In QML, the type of a list properties - and the guests property is a list of
-people - are all of type QmlList<T *>*. QmlList is an abstract list interface
-that allows a developer to react to QML accessing and modifying the contents of
-the list. This is useful for implementing "virtual lists" or other advanced
-scenarios, but can't be used directly for the common case of just wanting a
-regular list of things. For this a concrete implementation, QmlConcreteList, is
-provided and that is used here.
+people - are all of type QmlListProperty<T>. QmlListProperty is simple value
+type that contains a set of function pointers. QML calls these function
+pointers whenever it needs to read from, write to or otherwise interact with
+the list. In addition to concrete lists like the people list used in this
+example, the use of QmlListProperty allows for "virtual lists" and other advanced
+scenarios.
\section2 Define the BirthdayParty
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index e9a7803..0456f3f 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -169,7 +169,7 @@ for assignment to appropriately typed properties.
The guests property is a list of \c Person objects. Properties that are lists
of objects or Qt interfaces are also declared with the Q_PROPERTY() macro, just
-like other properties. List properties must have the type \c {QmlList<T *>*}.
+like other properties. List properties must have the type \c {QmlListProperty<T>}.
As with object properties, the type \a T must be registered with QML.
The guest property declaration looks like this:
diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc
index bfbb6af..6459a2e 100644
--- a/doc/src/declarative/focus.qdoc
+++ b/doc/src/declarative/focus.qdoc
@@ -263,7 +263,7 @@ Rectangle {
FocusScope {
id: page; width: 240; height: 25
MyWidget { focus: true }
- MouseRegion { anchors.fill: parent; onClicked: { page.focus = true } }
+ MouseArea { anchors.fill: parent; onClicked: { page.focus = true } }
}
\endcode
\endtable
diff --git a/doc/src/declarative/qmldebugging.qdoc b/doc/src/declarative/qmldebugging.qdoc
index c11ff1f..56bd7d2 100644
--- a/doc/src/declarative/qmldebugging.qdoc
+++ b/doc/src/declarative/qmldebugging.qdoc
@@ -50,7 +50,7 @@
\qml
Rectangle {
width: 200; height: 200
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: console.log("clicked")
}
diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc
index 11a286f..b353e44 100644
--- a/doc/src/declarative/qmlintro.qdoc
+++ b/doc/src/declarative/qmlintro.qdoc
@@ -326,11 +326,11 @@ Item {
\section2 Signal Handlers
Signal handlers allow actions to be taken in reponse to an event. For instance,
-the \l MouseRegion element has signal handlers to handle mouse press, release
+the \l MouseArea element has signal handlers to handle mouse press, release
and click:
\code
-MouseRegion {
+MouseArea {
onPressed: console.log("mouse button pressed")
}
\endcode
@@ -338,10 +338,10 @@ MouseRegion {
All signal handlers begin with \e "on".
Some signal handlers include an optional parameter, for example
-the MouseRegion onPressed signal handler has a \e mouse parameter:
+the MouseArea onPressed signal handler has a \e mouse parameter:
\code
-MouseRegion {
+MouseArea {
acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressed: if (mouse.button == Qt.RightButton) console.log("Right mouse button pressed")
}
diff --git a/doc/src/declarative/qmlmodels.qdoc b/doc/src/declarative/qmlmodels.qdoc
index 39a09bd..4843a7b 100644
--- a/doc/src/declarative/qmlmodels.qdoc
+++ b/doc/src/declarative/qmlmodels.qdoc
@@ -223,7 +223,7 @@ ListView {
anchors.fill: parent
model: myModel
delegate: Component {
- Rect {
+ Rectangle {
height: 25
Text { text: modelData }
}
@@ -258,7 +258,7 @@ dataList.append(new DataObject("Item 3", "blue"));
dataList.append(new DataObject("Item 4", "yellow"));
QmlContext *ctxt = view.rootContext();
-ctxt->setContextProperty("myModel", QVariant::fromValue(&dataList));
+ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
\endcode
The properties of the object may then be accessed in the delegate:
diff --git a/doc/src/declarative/qmlreference.qdoc b/doc/src/declarative/qmlreference.qdoc
index 7caa402..107d579 100644
--- a/doc/src/declarative/qmlreference.qdoc
+++ b/doc/src/declarative/qmlreference.qdoc
@@ -65,8 +65,8 @@
Getting Started:
\list
\o \l {Introduction to the QML language}
- \o \l {tutorial}{Tutorial: 'Hello World'}
- \o \l {advtutorial.html}{Advanced Tutorial: 'Same Game'}
+ \o \l {QML Tutorial}{Tutorial: 'Hello World'}
+ \o \l {QML Advanced Tutorial}{Advanced Tutorial: 'Same Game'}
\o \l {QML Examples and Walkthroughs}
\endlist
diff --git a/doc/src/declarative/qmlstates.qdoc b/doc/src/declarative/qmlstates.qdoc
index 36a2479..2118c2b 100644
--- a/doc/src/declarative/qmlstates.qdoc
+++ b/doc/src/declarative/qmlstates.qdoc
@@ -94,7 +94,7 @@ Item {
}
]
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: myItem.state = 'moved'
}
diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc
index 7857d48..732ff86 100644
--- a/doc/src/declarative/qtbinding.qdoc
+++ b/doc/src/declarative/qtbinding.qdoc
@@ -212,7 +212,7 @@ Rectangle {
text: "Hello Colorful World!"
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: {
palette.text = "blue";
@@ -255,7 +255,7 @@ the following types:
\o QVariant
\endlist
-This example toggles the "LED Blinker" when the MouseRegion is clicked:
+This example toggles the "LED Blinker" when the MouseArea is clicked:
\table
\row
@@ -291,7 +291,7 @@ int main(int argc, char **argv)
import Qt 4.6
Rectangle {
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: {
if (ledBlinker.isRunning())
@@ -315,7 +315,7 @@ is to have a "running" property. This leads to much nicer QML code:
import Qt 4.6
Rectangle {
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: ledBlinker.running = !ledBlinker.running
}
diff --git a/doc/src/declarative/scope.qdoc b/doc/src/declarative/scope.qdoc
index 5486afd..f709335 100644
--- a/doc/src/declarative/scope.qdoc
+++ b/doc/src/declarative/scope.qdoc
@@ -317,7 +317,7 @@ Rectangle {
anchors.centerIn: parent
text: root.text
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: buttonClicked(text)
}
diff --git a/doc/src/declarative/tutorial.qdoc b/doc/src/declarative/tutorial.qdoc
index 825590c..98efe12 100644
--- a/doc/src/declarative/tutorial.qdoc
+++ b/doc/src/declarative/tutorial.qdoc
@@ -40,11 +40,13 @@
****************************************************************************/
/*!
-\page tutorial.html
-\title Tutorial
+\page qml-tutorial.html
+\title QML Tutorial
+\brief An introduction to the basic concepts and features of QML.
+\nextpage QML Tutorial 1 - Basic Types
-This tutorial gives an introduction to QML. It doesn't cover everything; the emphasis is on teaching the key principles,
-and features are introduced as needed.
+This tutorial gives an introduction to QML, the mark up language for Qt Quick. It doesn't cover everything;
+the emphasis is on teaching the key principles, and features are introduced as needed.
Through the different steps of this tutorial we will learn about QML basic types, we will create our own QML component
with properties and signals, and we will create a simple animation with the help of states and transitions.
@@ -56,9 +58,182 @@ The tutorial's source code is located in the $QTDIR/examples/declarative/tutoria
Tutorial chapters:
\list
-\o \l {Tutorial 1 - Basic Types}
-\o \l {Tutorial 2 - QML Component}
-\o \l {Tutorial 3 - States and Transitions}
+\o \l {QML Tutorial 1 - Basic Types}
+\o \l {QML Tutorial 2 - QML Component}
+\o \l {QML Tutorial 3 - States and Transitions}
\endlist
*/
+
+/*!
+\page qml-tutorial1.html
+\title QML Tutorial 1 - Basic Types
+\contentspage QML Tutorial
+\previouspage QML Tutorial
+\nextpage QML Tutorial 2 - QML Component
+
+This first program is a very simple "Hello world" example that introduces some basic QML concepts.
+The picture below is a screenshot of this program.
+
+\image declarative-tutorial1.png
+
+Here is the QML code for the application:
+
+\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 0
+
+\section1 Walkthrough
+
+\section2 Import
+
+First, we need to import the types that we need for this example. Most QML files will import the built-in QML
+types (like \l{Rectangle}, \l{Image}, ...) that come with Qt with:
+
+\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 3
+
+\section2 Rectangle element
+
+\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 1
+
+We declare a root element of type \l{Rectangle}. It is one of the basic building blocks you can use to create an application in QML.
+We give it an \c{id} to be able to refer to it later. In this case, we call it \e page.
+We also set the \c width, \c height and \c color properties.
+The \l{Rectangle} element contains many other properties (such as \c x and \c y), but these are left at their default values.
+
+\section2 Text element
+
+\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 2
+
+We add a \l Text element as a child of our root element that will display the text 'Hello world!'.
+
+The \c y property is used to position the text vertically at 30 pixels from the top of its parent.
+
+The \c font.pointSize and \c font.bold properties are related to fonts and use the \l{dot properties}{dot notation}.
+
+The \c anchors.horizontalCenter property refers to the horizontal center of an element.
+In this case, we specify that our text element should be horizontally centered in the \e page element (see \l{anchor-layout}{Anchor-based Layout}).
+
+\section2 Viewing the example
+
+To view what you have created, run the qmlviewer (located in the \c bin directory) with your filename as the first argument.
+For example, to run the provided completed Tutorial 1 example from the install location, you would type:
+
+\code
+bin/qmlviewer $QTDIR/examples/declarative/tutorials/helloworld/tutorial1.qml
+\endcode
+*/
+
+/*!
+\page qml-tutorial2.html
+\title QML Tutorial 2 - QML Component
+\contentspage QML Tutorial
+\previouspage QML Tutorial 1 - Basic Types
+\nextpage QML Tutorial 3 - States and Transitions
+
+This chapter adds a color picker to change the color of the text.
+
+\image declarative-tutorial2.png
+
+Our color picker is made of six cells with different colors.
+To avoid writing the same code multiple times, we first create a new \c Cell component.
+A component provides a way of defining a new type that we can re-use in other QML files.
+A QML component is like a black-box and interacts with the outside world through properties, signals and slots and is generally
+defined in its own QML file (for more details, see \l {Defining new Components}).
+The component's filename must always start with a capital letter.
+
+Here is the QML code for \c Cell.qml:
+
+\snippet examples/declarative/tutorials/helloworld/Cell.qml 0
+
+\section1 Walkthrough
+
+\section2 The Cell Component
+
+\snippet examples/declarative/tutorials/helloworld/Cell.qml 1
+
+The root element of our component is an \l Item with the \c id \e container.
+An \l Item is the most basic visual element in QML and is often used as a container for other elements.
+
+\snippet examples/declarative/tutorials/helloworld/Cell.qml 4
+
+We declare a \c color property. This property is accessible from \e outside our component, this allows us
+to instantiate the cells with different colors.
+This property is just an alias to an existing property - the color of the rectangle that compose the cell (see \l{intro-properties}{Properties}).
+
+\snippet examples/declarative/tutorials/helloworld/Cell.qml 5
+
+We want our component to also have a signal that we call \e clicked with a \e color parameter.
+We will use this signal to change the color of the text in the main QML file later.
+
+\snippet examples/declarative/tutorials/helloworld/Cell.qml 2
+
+Our cell component is basically a colored rectangle with the \c id \e rectangle.
+
+The \c anchors.fill property is a convenient way to set the size of an element.
+In this case the rectangle will have the same size as its parent (see \l{anchor-layout}{Anchor-based Layout}).
+
+\snippet examples/declarative/tutorials/helloworld/Cell.qml 3
+
+In order to change the color of the text when clicking on a cell, we create a \l MouseRegion element with
+the same size as its parent.
+
+A \l MouseRegion defines a signal called \e clicked.
+When this signal is triggered we want to emit our own \e clicked signal with the color as parameter.
+
+\section2 The main QML file
+
+In our main QML file, we use our \c Cell component to create the color picker:
+
+\snippet examples/declarative/tutorials/helloworld/tutorial2.qml 0
+
+We create the color picker by putting 6 cells with different colors in a grid.
+
+\snippet examples/declarative/tutorials/helloworld/tutorial2.qml 1
+
+When the \e clicked signal of our cell is triggered, we want to set the color of the text to the color passed as a parameter.
+We can react to any signal of our component through a property of the name \e 'onSignalName' (see \l{Signal Handlers}).
+*/
+
+/*!
+\page qml-tutorial3.html
+\title QML Tutorial 3 - States and Transitions
+\contentspage QML Tutorial
+\previouspage QML Tutorial 2 - QML Component
+
+In this chapter, we make this example a little bit more dynamic by introducing states and transitions.
+
+We want our text to move to the bottom of the screen, rotate and become red when clicked.
+
+\image declarative-tutorial3_animation.gif
+
+Here is the QML code:
+
+\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 0
+
+\section1 Walkthrough
+
+\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 2
+
+First, we create a new \e down state for our text element.
+This state will be activated when the \l MouseRegion is pressed, and deactivated when it is released.
+
+The \e down state includes a set of property changes from our implicit \e {default state}
+(the items as they were initially defined in the QML).
+Specifically, we set the \c y property of the text to \c 160, the rotation to \c 180 and the \c color to red.
+
+\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 3
+
+Because we don't want the text to appear at the bottom instantly but rather move smoothly,
+we add a transition between our two states.
+
+\c from and \c to define the states between which the transition will run.
+In this case, we want a transition from the default state to our \e down state.
+
+Because we want the same transition to be run in reverse when changing back from the \e down state to the default state,
+we set \c reversible to \c true.
+This is equivalent to writing the two transitions separately.
+
+The \l ParallelAnimation element makes sure that the two types of animations (number and color) start at the same time.
+We could also run them one after the other by using \l SequentialAnimation instead.
+
+For more details on states and transitions, see \l {QML States}.
+*/
diff --git a/doc/src/declarative/tutorial1.qdoc b/doc/src/declarative/tutorial1.qdoc
deleted file mode 100644
index 3a79a15..0000000
--- a/doc/src/declarative/tutorial1.qdoc
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page tutorial1.html
-\title Tutorial 1 - Basic Types
-
-This first program is a very simple "Hello world" example that introduces some basic QML concepts.
-The picture below is a screenshot of this program.
-
-\image declarative-tutorial1.png
-
-Here is the QML code for the application:
-
-\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 0
-
-\section1 Walkthrough
-
-\section2 Import
-
-First, we need to import the types that we need for this example. Most QML files will import the built-in QML
-types (like \l{Rectangle}, \l{Image}, ...) that come with Qt with:
-
-\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 3
-
-\section2 Rectangle element
-
-\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 1
-
-We declare a root element of type \l{Rectangle}. It is one of the basic building blocks you can use to create an application in QML.
-We give it an \c{id} to be able to refer to it later. In this case, we call it \e page.
-We also set the \c width, \c height and \c color properties.
-The \l{Rectangle} element contains many other properties (such as \c x and \c y), but these are left at their default values.
-
-\section2 Text element
-
-\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 2
-
-We add a \l Text element as a child of our root element that will display the text 'Hello world!'.
-
-The \c y property is used to position the text vertically at 30 pixels from the top of its parent.
-
-The \c font.pointSize and \c font.bold properties are related to fonts and use the \l{dot properties}{dot notation}.
-
-The \c anchors.horizontalCenter property refers to the horizontal center of an element.
-In this case, we specify that our text element should be horizontally centered in the \e page element (see \l{anchor-layout}{Anchor-based Layout}).
-
-\section2 Viewing the example
-
-To view what you have created, run the qmlviewer (located in the \c bin directory) with your filename as the first argument.
-For example, to run the provided completed Tutorial 1 example from the install location, you would type:
-
-\code
-bin/qmlviewer $QTDIR/examples/declarative/tutorials/helloworld/tutorial1.qml
-\endcode
-
-[\l {Tutorial}] [Next: \l {Tutorial 2 - QML Component}]
-
-*/
diff --git a/doc/src/declarative/tutorial2.qdoc b/doc/src/declarative/tutorial2.qdoc
deleted file mode 100644
index 4e11f7c..0000000
--- a/doc/src/declarative/tutorial2.qdoc
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page tutorial2.html
-\title Tutorial 2 - QML Component
-
-This chapter adds a color picker to change the color of the text.
-
-\image declarative-tutorial2.png
-
-Our color picker is made of six cells with different colors.
-To avoid writing the same code multiple times, we first create a new \c Cell component.
-A component provides a way of defining a new type that we can re-use in other QML files.
-A QML component is like a black-box and interacts with the outside world through properties, signals and slots and is generally
-defined in its own QML file (for more details, see \l {Defining new Components}).
-The component's filename must always start with a capital letter.
-
-Here is the QML code for \c Cell.qml:
-
-\snippet examples/declarative/tutorials/helloworld/Cell.qml 0
-
-\section1 Walkthrough
-
-\section2 The Cell Component
-
-\snippet examples/declarative/tutorials/helloworld/Cell.qml 1
-
-The root element of our component is an \l Item with the \c id \e container.
-An \l Item is the most basic visual element in QML and is often used as a container for other elements.
-
-\snippet examples/declarative/tutorials/helloworld/Cell.qml 4
-
-We declare a \c color property. This property is accessible from \e outside our component, this allows us
-to instantiate the cells with different colors.
-This property is just an alias to an existing property - the color of the rectangle that compose the cell (see \l{intro-properties}{Properties}).
-
-\snippet examples/declarative/tutorials/helloworld/Cell.qml 5
-
-We want our component to also have a signal that we call \e clicked with a \e color parameter.
-We will use this signal to change the color of the text in the main QML file later.
-
-\snippet examples/declarative/tutorials/helloworld/Cell.qml 2
-
-Our cell component is basically a colored rectangle with the \c id \e rectangle.
-
-The \c anchors.fill property is a convenient way to set the size of an element.
-In this case the rectangle will have the same size as its parent (see \l{anchor-layout}{Anchor-based Layout}).
-
-\snippet examples/declarative/tutorials/helloworld/Cell.qml 3
-
-In order to change the color of the text when clicking on a cell, we create a \l MouseRegion element with
-the same size as its parent.
-
-A \l MouseRegion defines a signal called \e clicked.
-When this signal is triggered we want to emit our own \e clicked signal with the color as parameter.
-
-\section2 The main QML file
-
-In our main QML file, we use our \c Cell component to create the color picker:
-
-\snippet examples/declarative/tutorials/helloworld/tutorial2.qml 0
-
-We create the color picker by putting 6 cells with different colors in a grid.
-
-\snippet examples/declarative/tutorials/helloworld/tutorial2.qml 1
-
-When the \e clicked signal of our cell is triggered, we want to set the color of the text to the color passed as a parameter.
-We can react to any signal of our component through a property of the name \e 'onSignalName' (see \l{Signal Handlers}).
-
-[Previous: \l {Tutorial 1 - Basic Types}] [Next: \l {Tutorial 3 - States and Transitions}]
-
-*/
-
diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc
deleted file mode 100644
index 323395e..0000000
--- a/doc/src/declarative/tutorial3.qdoc
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page tutorial3.html
-\title Tutorial 3 - States and Transitions
-
-In this chapter, we make this example a little bit more dynamic by introducing states and transitions.
-
-We want our text to move to the bottom of the screen, rotate and become red when clicked.
-
-\image declarative-tutorial3_animation.gif
-
-Here is the QML code:
-
-\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 0
-
-\section1 Walkthrough
-
-\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 2
-
-First, we create a new \e down state for our text element.
-This state will be activated when the \l MouseRegion is pressed, and deactivated when it is released.
-
-The \e down state includes a set of property changes from our implicit \e {default state}
-(the items as they were initially defined in the QML).
-Specifically, we set the \c y property of the text to \c 160, the rotation to \c 180 and the \c color to red.
-
-\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 3
-
-Because we don't want the text to appear at the bottom instantly but rather move smoothly,
-we add a transition between our two states.
-
-\c from and \c to define the states between which the transition will run.
-In this case, we want a transition from the default state to our \e down state.
-
-Because we want the same transition to be run in reverse when changing back from the \e down state to the default state,
-we set \c reversible to \c true.
-This is equivalent to writing the two transitions separately.
-
-The \l ParallelAnimation element makes sure that the two types of animations (number and color) start at the same time.
-We could also run them one after the other by using \l SequentialAnimation instead.
-
-For more details on states and transitions, see \l {QML States}.
-
-[Previous: \l {Tutorial 2 - QML Component}] [\l {Tutorial}]
-
-*/
diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc
index 6215268..6406193 100644
--- a/doc/src/development/qmake-manual.qdoc
+++ b/doc/src/development/qmake-manual.qdoc
@@ -872,7 +872,7 @@
Developers using Visual Studio to write Qt applications can use the
Visual Studio integration facilities provided with the
- \l{Qt Commercial Editions} and do not need to worry about how
+ \l{Qt Commercial Edition} and do not need to worry about how
project dependencies are managed.
However, some developers may need to import an existing \c qmake project
diff --git a/doc/src/frameworks-technologies/activeqt.qdoc b/doc/src/frameworks-technologies/activeqt.qdoc
index 67b9bb3..e24959d 100644
--- a/doc/src/frameworks-technologies/activeqt.qdoc
+++ b/doc/src/frameworks-technologies/activeqt.qdoc
@@ -93,7 +93,7 @@
plugin that integrates the QAxContainer module into \l{Qt
Designer}.
- The ActiveQt modules are part of the \l{Qt Full Framework Edition} and
+ The ActiveQt modules are part of the \l{Qt Commercial Edition} and
the \l{Open Source Versions of Qt}.
\sa {QAxContainer Module}, {QAxServer Module}
diff --git a/doc/src/getting-started/installation.qdoc b/doc/src/getting-started/installation.qdoc
index e54774b..b23629d 100644
--- a/doc/src/getting-started/installation.qdoc
+++ b/doc/src/getting-started/installation.qdoc
@@ -176,7 +176,7 @@ consult the installation instructions provided instead of the ones in
this document.
\o \l{Open Source Versions of Qt} is not officially supported for use with
any version of Visual Studio. Integration with Visual Studio is available
-as part of the \l{Qt Commercial Editions}.
+as part of the \l{Qt Commercial Edition}.
\endlist
\endtable
diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc
index d1f5f0f..52d4488 100644
--- a/doc/src/index.qdoc
+++ b/doc/src/index.qdoc
@@ -142,7 +142,7 @@
<td valign="top">
<ul>
<li><a href="gpl.html">GNU GPL</a>, <a href="lgpl.html">GNU LGPL</a></li>
- <li><a href="commercialeditions.html">Commercial Editions</a></li>
+ <li><a href="commercialedition.html">Commercial Edition</a></li>
<li><a href="licensing.html">Licenses Used in Qt</a></li>
</ul>
</td>
diff --git a/doc/src/legal/commercialeditions.qdoc b/doc/src/legal/commercialeditions.qdoc
index 4e44376..dde8d69 100644
--- a/doc/src/legal/commercialeditions.qdoc
+++ b/doc/src/legal/commercialeditions.qdoc
@@ -40,61 +40,19 @@
****************************************************************************/
/*!
- \page commercialeditions.html
- \title Qt Commercial Editions
+ \page commercialedition.html
+ \title Qt Commercial Edition
\ingroup licensing
\brief Information about the license and features of the Commercial Edition.
- \keyword Qt Full Framework Edition
- \keyword Qt GUI Framework Edition
-
- Two editions of Qt are available under a commercial license:
- Qt GUI Framework Edition, and Qt Full Framework Edition.
+ Qt can be used to develop closed source software if you obtain a commercial
+ license.
If you want to develop Free or Open Source software for release using a recognized
Open Source license, you can use the \l{Open Source Versions of Qt}.
The table below summarizes the differences between the two commercial editions:
- \table 75%
- \header \o{1,2} Features \o{2,1} Editions
- \header \o Qt GUI Framework \o Qt Full Framework
- \row \o \l{QtCore}{Qt Core classes (QtCore)} \o \bold{X} \o \bold{X}
- \row \o \l{QtGui}{Qt GUI classes (QtGui)} \o \bold{(X)} \o \bold{X}
- \row \o \l{Graphics View Classes} (part of QtGui) \o \o \bold{X}
- \row \o \l{QtNetwork}{Networking (QtNetwork)} \o \o \bold{X}
- \row \o \l{QtOpenGL}{OpenGL (QtOpenGL)} \o \o \bold{X}
- \row \o \l{QtScript}{Scripting (QtScript)} \o \o \bold{X}
- \row \o \l{QtScriptTools}{Script Debugging (QtScriptTools)}\o \o \bold{X}
- \row \o \l{QtSql}{Database/SQL (QtSql)} \o \o \bold{X}
- \row \o \l{QtSvg}{SVG (QtSvg)} \o \o \bold{X}
- \row \o \l{QtWebKit}{WebKit integration (QtWebKit)} \o \o \bold{X}
- \row \o \l{QtXml}{XML (QtXml)} \o \o \bold{X}
- \row \o \l{QtXmlPatterns}{XQuery and XPath (QtXmlPatterns)}\o \o \bold{X}
- \row \o \l{Qt3Support}{Qt 3 Support (Qt3Support)} \o \bold{(X)} \o \bold{X}
- \row \o \l{QtHelp}{Help system (QtHelp)} \o \o \bold{X}
- \row \o \l{QtDBus}{D-Bus IPC support (QtDBus)} \o \bold{X} \o \bold{X}
- \row \o \l{QtDesigner}{\QD extension classes (QtDesigner)} \o \o \bold{X}
- \row \o \l{QtTest}{Unit testing framework (QtTest)} \o \bold{X} \o \bold{X}
- \row \o \l{QtUiTools}{Run-time form handling (QtUiTools)} \o \o \bold{X}
- \row \o \l{Phonon Module}{Phonon Multimedia Framework} \o \o \bold{X}
- \row \o \l{ActiveQt} \o \o \bold{<X>}
- \endtable
-
- \bold{(X)} The Qt GUI Framework Edition contains selected classes from the QtGui and
- Qt3Support modules corresponding to the functionality available in the Qt 3 Professional
- Edition.
-
- \bold{<X>} The ActiveQt module is only available on Windows.
-
- Lists of the classes available in each edition are available on the
- following pages:
-
- \list
- \o \l{Qt GUI Framework Edition}
- \o \l{Qt Full Framework Edition}
- \endlist
-
Please see the \l{Supported Platforms}{list of supported
platforms} for up-to-date information about the various platforms
and compilers that Qt supports.
@@ -103,36 +61,13 @@
\l{Qt Licensing Overview} and information on \l{Qt License Pricing}
for commercial editions of Qt and other Qt-related products.
- To purchase, please visit the \l{How to Order}{online order
- form}.
+ To purchase, please visit the \l{How to Order}{online order form}.
- For further information and assistance, please contact Qt
- sales.
+ For further information and assistance, please contact Qt sales.
Web: http://qt.nokia.com/contact.
Phone, U.S. office (for North America): \bold{1-650-813-1676}.
- Phone, Norway office (for the rest of the world): \bold{+47 21 60
- 48 00}.
-*/
-
-/*!
- \page full-framework-edition-classes.html
- \title Qt Full Framework Edition
- \ingroup classlists
-
- \brief The list of Qt classes included in the Full Framework Edition.
-
- \generatelist{classesbyedition Desktop}
-*/
-
-/*!
- \page gui-framework-edition-classes.html
- \title Qt GUI Framework Edition
- \ingroup classlists
-
- \brief The list of Qt classes included in the GUI Framework Edition.
-
- \generatelist{classesbyedition DesktopLight}
+ Phone, Norway office (for the rest of the world): \bold{+47 21 60 48 00}.
*/
diff --git a/doc/src/legal/editions.qdoc b/doc/src/legal/editions.qdoc
index 4de77c1..c7e73f2 100644
--- a/doc/src/legal/editions.qdoc
+++ b/doc/src/legal/editions.qdoc
@@ -53,8 +53,8 @@
In terms of license conditions, there are two main forms of Qt:
\list
- \o The \l{Qt Commercial Editions} are the commercial
- versions of \l{About Qt}{Qt}.
+ \o The \l{Qt Commercial Edition} is the commercial version of
+ \l{About Qt}{Qt} which can be used to create closed source software.
\o The \l{Open Source Versions of Qt} are freely available for download.
\endlist
diff --git a/doc/src/legal/licenses.qdoc b/doc/src/legal/licenses.qdoc
index 344ebd4..d1bf4cf 100644
--- a/doc/src/legal/licenses.qdoc
+++ b/doc/src/legal/licenses.qdoc
@@ -60,7 +60,7 @@
Qt contains some code that is not provided under the
\l{GNU General Public License (GPL)},
\l{GNU Lesser General Public License (LGPL)} or the
- \l{Qt Commercial Editions}{Qt Commercial License Agreement}, but rather under
+ \l{Qt Commercial Edition}{Qt Commercial License Agreement}, but rather under
specific licenses from the original authors. Some pieces of code were developed
by Nokia and others originated from third parties.
This page lists the licenses used, names the authors, and links
diff --git a/doc/src/legal/opensourceedition.qdoc b/doc/src/legal/opensourceedition.qdoc
index c199e34..d95e107 100644
--- a/doc/src/legal/opensourceedition.qdoc
+++ b/doc/src/legal/opensourceedition.qdoc
@@ -87,5 +87,4 @@
If you are in doubt what edition of Qt is right for your project,
please contact
\l{mailto:qt-info@nokia.com}{qt-info@nokia.com}.
-
*/
diff --git a/doc/src/modules.qdoc b/doc/src/modules.qdoc
index 78af7eb..9e1d340 100644
--- a/doc/src/modules.qdoc
+++ b/doc/src/modules.qdoc
@@ -109,8 +109,6 @@
definitions of the module's classes, use the following directive:
\snippet doc/src/snippets/code/doc_src_qtcore.qdoc 0
-
- The QtCore module is part of all \l{Qt editions}.
*/
@@ -128,9 +126,6 @@
following directive:
\snippet doc/src/snippets/code/doc_src_qtgui.qdoc 0
-
- The QtGui module is part of the \l{Qt GUI Framework Edition},
- the \l{Qt Full Framework Edition}, and the \l{Open Source Versions of Qt}.
*/
/*!
@@ -177,9 +172,6 @@
.pro file:
\snippet doc/src/snippets/code/doc_src_qtnetwork.qdoc 0
-
- The QtNetwork module is part of the \l{Qt Full Framework Edition} and the
- \l{Open Source Versions of Qt}.
*/
/*!
@@ -225,9 +217,9 @@
OpenGL module can take advantage of the whole Qt API for
non-OpenGL-specific GUI functionality.
- The QtOpenGL module is part of the \l{Qt Full Framework Edition} and the
- \l{Open Source Versions of Qt}. It is available on Windows, X11, and Mac OS X.
- \l{Qt for Embedded Linux and OpenGL} supports OpenGL ES (OpenGL for Embedded Systems).
+ The QtOpenGL module is available on Windows, X11 and Mac OS X.
+ \l{Qt for Embedded Linux and OpenGL} supports OpenGL ES (OpenGL for
+ Embedded Systems).
\note To be able to use the OpenGL API in \l{Qt for Embedded Linux}, it must be
integrated with the Q Window System (QWS). See the
\l{Qt for Embedded Linux and OpenGL} documentation for details.
@@ -319,9 +311,6 @@
scriptable with QtScript, see \l{Making Applications
Scriptable}.
- The QtScript module is part of the \l{Qt Full Framework Edition} and the
- \l{Open Source Versions of Qt}.
-
\section1 License Information
Qt Commercial Edition licensees that wish to distribute applications that
@@ -379,9 +368,6 @@
To link against the module, add this line to your \l qmake \c .pro file:
\snippet doc/src/snippets/code/doc.src.qtscripttools.qdoc 1
-
- The QtScriptTools module is part of the \l{Qt Full Framework Edition} and
- the \l{Open Source Versions of Qt}.
*/
/*!
@@ -402,9 +388,6 @@
\snippet doc/src/snippets/code/doc_src_qtsql.qdoc 1
- The QtSql module is part of the \l{Qt Full Framework Edition} and the
- \l{Open Source Versions of Qt}.
-
See the \l{SQL Programming} guide for information about using this
module in your applications.
*/
@@ -430,9 +413,6 @@
\snippet doc/src/snippets/code/doc_src_qtsvg.qdoc 1
- The QtSvg module is part of the \l{Qt Full Framework Edition} and the
- \l{Open Source Versions of Qt}.
-
\section1 License Information
Some code for arc handling in this module is derived from code with
@@ -488,9 +468,6 @@
Further XML support is provided by the \l{Qt Solutions} group who
provide, for example, classes that support SOAP and MML with the
Qt XML classes.
-
- This module is part of the \l{Qt Full Framework Edition} and the
- \l{Open Source Versions of Qt}.
*/
/*!
@@ -515,9 +492,6 @@
\snippet doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc 1
- This module is part of the \l{Qt Full Framework Edition} and the
- \l{Open Source Versions of Qt}.
-
\section1 License Information
The XML Schema implementation provided by this module contains the \c xml.xsd file
@@ -594,9 +568,6 @@
\snippet doc/src/snippets/code/doc_src_phonon.qdoc 1
- The Phonon module is part of the \l{Qt Full Framework Edition} and the
- \l{Open Source Versions of Qt}.
-
\section1 Qt Backends
Qt Backends are currently developed for Phonon version 4.1. The Phonon
@@ -672,12 +643,6 @@
diverse parts of the Qt 3 API, it has dependencies on the QtCore,
QtGui, QtNetwork, QtSql, and QtXml modules.
- This module is part of the \l{Qt Full Framework Edition} and the
- \l{Open Source Versions of Qt}. Most classes offered by this module are
- also part of the \l{Qt GUI Framework Edition}.
- Classes that are not available for \l{Qt GUI Framework Edition}
- users are marked as such in the class documentation.
-
\sa {Porting to Qt 4}
*/
@@ -705,10 +670,6 @@
file:
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 1
-
- \note These classes are part of the \l{Open Source Versions of Qt} and
- \l{Qt Commercial Editions}{Qt Full Framework Edition} for commercial
- users.
*/
/*!
@@ -745,10 +706,6 @@
\snippet doc/src/snippets/code/doc_src_qtuiloader.qdoc 1
- \note These classes are part of the \l{Open Source Versions of Qt} and
- \l{Qt Commercial Editions}{Qt Full Framework Edition} for commercial
- users.
-
\sa{Calculator Builder Example}, {World Time Clock Builder Example}
*/
@@ -773,10 +730,6 @@
\snippet doc/src/snippets/code/doc_src_qthelp.qdoc 1
- These classes are part of the \l{Open Source Versions of Qt} and
- \l{Qt Commercial Editions}{Qt Full Framework Edition} for commercial
- users.
-
\section1 License Information
The QtHelp module uses the CLucene indexing library to provide full-text
@@ -860,7 +813,7 @@
The QAxContainer module is not covered by the \l{GNU General Public License (GPL)},
the \l{GNU Lesser General Public License (LGPL)}, or the
- \l{Qt Commercial Editions}{Qt Commercial License}. Instead, it is distributed under
+ \l{Qt Commercial Edition}{Qt Commercial License}. Instead, it is distributed under
the following license.
\legalese
@@ -910,7 +863,7 @@
The QAxContainer module is not covered by the \l{GNU General Public License (GPL)},
the \l{GNU Lesser General Public License (LGPL)}, or the
- \l{Qt Commercial Editions}{Qt Commercial License}. Instead, it is distributed under
+ \l{Qt Commercial Edition}{Qt Commercial License}. Instead, it is distributed under
the following license.
\legalese
@@ -1005,7 +958,7 @@
The QAxContainer module is not covered by the \l{GNU General Public License (GPL)},
the \l{GNU Lesser General Public License (LGPL)}, or the
- \l{Qt Commercial Editions}{Qt Commercial License}. Instead, it is distributed under
+ \l{Qt Commercial Edition}{Qt Commercial License}. Instead, it is distributed under
the following license.
\legalese
@@ -1043,7 +996,7 @@
located in the \c{src/s60main} directory are not covered by the
\l{GNU General Public License (GPL)}, the
\l{GNU Lesser General Public License (LGPL)}, or the
- \l{Qt Commercial Editions}{Qt Commercial License}. Instead, they are
+ \l{Qt Commercial Edition}{Qt Commercial License}. Instead, they are
distributed under the following license.
\legalese
diff --git a/doc/src/platforms/mac-differences.qdoc b/doc/src/platforms/mac-differences.qdoc
index bda439d..58d64de 100644
--- a/doc/src/platforms/mac-differences.qdoc
+++ b/doc/src/platforms/mac-differences.qdoc
@@ -301,7 +301,7 @@
\contentspage {Other Licenses Used in Qt}{Contents}
\ingroup licensing
- \brief License information for contributions by Apple, Inc. to specific parts of the Qt/Mac Cocoa port.
+ \brief License information for contributions by Apple, Inc. to specific parts of the Qt for Mac OS X Cocoa port.
\legalese
diff --git a/doc/src/snippets/declarative/drag.qml b/doc/src/snippets/declarative/drag.qml
index 8735d0c..8e5b599 100644
--- a/doc/src/snippets/declarative/drag.qml
+++ b/doc/src/snippets/declarative/drag.qml
@@ -6,7 +6,7 @@ Rectangle {
Image {
id: pic; source: "qtlogo-64.png"; anchors.verticalCenter: parent.verticalCenter
opacity: (600.0-pic.x) / 600;
- MouseRegion {
+ MouseArea {
anchors.fill: parent
drag.target: pic
drag.axis: "XAxis"
diff --git a/doc/src/snippets/declarative/mouseregion.qml b/doc/src/snippets/declarative/mouseregion.qml
index 67857f5..79f8f8f 100644
--- a/doc/src/snippets/declarative/mouseregion.qml
+++ b/doc/src/snippets/declarative/mouseregion.qml
@@ -4,13 +4,13 @@ Rectangle { width: 200; height: 100
HorizontalLayout {
//! [0]
Rectangle { width: 100; height: 100; color: "green"
- MouseRegion { anchors.fill: parent; onClicked: { parent.color = 'red' } }
+ MouseArea { anchors.fill: parent; onClicked: { parent.color = 'red' } }
}
//! [0]
//! [1]
Rectangle {
width: 100; height: 100; color: "green"
- MouseRegion {
+ MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
diff --git a/doc/src/xml-processing/xml-patterns.qdoc b/doc/src/xml-processing/xml-patterns.qdoc
index 408b2da..68056fd 100644
--- a/doc/src/xml-processing/xml-patterns.qdoc
+++ b/doc/src/xml-processing/xml-patterns.qdoc
@@ -65,8 +65,7 @@
\l{http://www.w3.org/TR/xpath20} {XPath 2.0} in Qt applications,
for querying XML data \e{and} for querying
\l{QAbstractXmlNodeModel} {non-XML data that can be modeled to
- look like XML}. The QtXmlPatterns module is included in the \l{Qt
- Full Framework Edition}, and the \l{Open Source Versions of Qt}.
+ look like XML}.
Readers who are not familiar with the XQuery/XPath language can read
\l {A Short Path to XQuery} for a brief introduction.
diff --git a/examples/declarative/anchors/anchor-changes.qml b/examples/declarative/anchors/anchor-changes.qml
index f6fd35d..99ca3db 100644
--- a/examples/declarative/anchors/anchor-changes.qml
+++ b/examples/declarative/anchors/anchor-changes.qml
@@ -25,7 +25,7 @@ Item {
Text { text: "Bottom"; anchors.bottom: parent.bottom }
}
- MouseRegion {
+ MouseArea {
anchors.fill: content
onPressed: window.state = "FullScreen"
onReleased: window.state = ""
diff --git a/examples/declarative/animations/easing.qml b/examples/declarative/animations/easing.qml
index 59e9b17..9b5bcc6 100644
--- a/examples/declarative/animations/easing.qml
+++ b/examples/declarative/animations/easing.qml
@@ -68,7 +68,7 @@ Rectangle {
border.color: "White"; border.width: 2
height: 32; width: 32; radius: 8; anchors.verticalCenter: parent.verticalCenter
- MouseRegion {
+ MouseArea {
onClicked: if (rect.state == '') rect.state = "right"; else rect.state = ''
anchors.fill: parent
}
diff --git a/examples/declarative/aspectratio/face_fit.qml b/examples/declarative/aspectratio/face_fit.qml
index 482d1b7..6a031a4 100644
--- a/examples/declarative/aspectratio/face_fit.qml
+++ b/examples/declarative/aspectratio/face_fit.qml
@@ -16,6 +16,7 @@ Rectangle {
Image {
id: face
smooth: true
+ anchors.centerIn: parent
source: "pics/face.png"
x: (parent.width-width*scale)/2
y: (parent.height-height*scale)/2
diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml
index 80a762b..90ea516 100644
--- a/examples/declarative/aspectratio/face_fit_animated.qml
+++ b/examples/declarative/aspectratio/face_fit_animated.qml
@@ -14,6 +14,7 @@ Rectangle {
Image {
id: face
smooth: true
+ anchors.centerIn: parent
source: "pics/face.png"
x: (parent.width-width*scale)/2
y: (parent.height-height*scale)/2
diff --git a/examples/declarative/aspectratio/scale_and_crop.qml b/examples/declarative/aspectratio/scale_and_crop.qml
index 283e24b..2e2b6ed 100644
--- a/examples/declarative/aspectratio/scale_and_crop.qml
+++ b/examples/declarative/aspectratio/scale_and_crop.qml
@@ -12,6 +12,7 @@ Rectangle {
Image {
id: face
smooth: true
+ anchors.centerIn: parent
source: "pics/face.png"
x: (parent.width-width*scale)/2
y: (parent.height-height*scale)/2
diff --git a/examples/declarative/aspectratio/scale_and_sidecrop.qml b/examples/declarative/aspectratio/scale_and_sidecrop.qml
index c3ef859..8230e49 100644
--- a/examples/declarative/aspectratio/scale_and_sidecrop.qml
+++ b/examples/declarative/aspectratio/scale_and_sidecrop.qml
@@ -13,6 +13,7 @@ Rectangle {
Image {
id: face
smooth: true
+ anchors.centerIn: parent
source: "pics/face.png"
x: (parent.width-width*scale)/2
y: (parent.height-height*scale)/2
diff --git a/examples/declarative/aspectratio/scale_to_fit.qml b/examples/declarative/aspectratio/scale_to_fit.qml
index 961ac04..eae4d16 100644
--- a/examples/declarative/aspectratio/scale_to_fit.qml
+++ b/examples/declarative/aspectratio/scale_to_fit.qml
@@ -13,6 +13,7 @@ Rectangle {
Image {
id: face
smooth: true
+ anchors.centerIn: parent
source: "pics/face.png"
x: (parent.width-width*scale)/2
y: (parent.height-height*scale)/2
diff --git a/examples/declarative/behaviours/MyRect.qml b/examples/declarative/behaviours/MyRect.qml
index a272e1f..caf0d83 100644
--- a/examples/declarative/behaviours/MyRect.qml
+++ b/examples/declarative/behaviours/MyRect.qml
@@ -6,7 +6,7 @@ Rectangle {
width: 100
height: 100
id: page
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: { bluerect.parent = page; bluerect.x=0 }
}
diff --git a/examples/declarative/behaviours/SideRect.qml b/examples/declarative/behaviours/SideRect.qml
index c7c7ebf..63b7db2 100644
--- a/examples/declarative/behaviours/SideRect.qml
+++ b/examples/declarative/behaviours/SideRect.qml
@@ -9,7 +9,7 @@ Rectangle {
width: 75; height: 50
radius: 5
border.width: 10; border.color: "white";
- MouseRegion {
+ MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: { focusRect.x = myRect.x; focusRect.y = myRect.y; focusRect.text = myRect.text }
diff --git a/examples/declarative/behaviours/test.qml b/examples/declarative/behaviours/test.qml
index 1869c45..fc3f4bf 100644
--- a/examples/declarative/behaviours/test.qml
+++ b/examples/declarative/behaviours/test.qml
@@ -5,7 +5,7 @@ Rectangle {
width: 800
height: 600
id: page
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: { bluerect.parent = page; console.log(mouseX); bluerect.x = mouseX; }
}
diff --git a/examples/declarative/connections/content/Button.qml b/examples/declarative/connections/content/Button.qml
index 1d46acc..0e33c78 100644
--- a/examples/declarative/connections/content/Button.qml
+++ b/examples/declarative/connections/content/Button.qml
@@ -8,5 +8,5 @@ Item {
signal clicked
Image { id: icon }
- MouseRegion { anchors.fill: icon; onClicked: button.clicked() }
+ MouseArea { anchors.fill: icon; onClicked: button.clicked() }
}
diff --git a/examples/declarative/dial/dial.qml b/examples/declarative/dial/dial.qml
index c7b7659..3aed70e 100644
--- a/examples/declarative/dial/dial.qml
+++ b/examples/declarative/dial/dial.qml
@@ -26,7 +26,7 @@ Rectangle {
GradientStop { position: 0.0; color: "#424242" }
GradientStop { position: 1.0; color: "black" }
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
drag.target: parent; drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: container.width - 32
}
diff --git a/examples/declarative/dynamic/qml/Button.qml b/examples/declarative/dynamic/qml/Button.qml
index cf2ffa7..757e295 100644
--- a/examples/declarative/dynamic/qml/Button.qml
+++ b/examples/declarative/dynamic/qml/Button.qml
@@ -19,6 +19,6 @@ Rectangle {
color: if(!mr.pressed){activePalette.button;}else{activePalette.dark;}
}
}
- MouseRegion { id:mr; anchors.fill: parent; onClicked: container.clicked() }
+ MouseArea { id:mr; 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/declarative/dynamic/qml/PaletteItem.qml b/examples/declarative/dynamic/qml/PaletteItem.qml
index bb6036d..8a9a9ee 100644
--- a/examples/declarative/dynamic/qml/PaletteItem.qml
+++ b/examples/declarative/dynamic/qml/PaletteItem.qml
@@ -4,7 +4,7 @@ GenericItem {
id: itemButton
property string file
Script { source: "itemCreation.js" }
- MouseRegion {
+ MouseArea {
anchors.fill: parent;
onPressed: startDrag(mouse);
onPositionChanged: moveDrag(mouse);
diff --git a/examples/declarative/effects/effects.qml b/examples/declarative/effects/effects.qml
index 51658ff..0674433 100644
--- a/examples/declarative/effects/effects.qml
+++ b/examples/declarative/effects/effects.qml
@@ -20,7 +20,7 @@ Rectangle {
}
}
- MouseRegion { anchors.fill: parent; onClicked: blurEffect.running = !blurEffect.running }
+ MouseArea { anchors.fill: parent; onClicked: blurEffect.running = !blurEffect.running }
}
Text { text: "Blur"; anchors.top: blur.bottom; anchors.horizontalCenter: blur.horizontalCenter }
@@ -36,7 +36,7 @@ Rectangle {
offset.y: NumberAnimation { id: dropShadowEffect; from: 0; to: 10; duration: 1000; running: false; repeat: true; }
}
- MouseRegion { anchors.fill: parent; onClicked: dropShadowEffect.running = !dropShadowEffect.running }
+ MouseArea { anchors.fill: parent; onClicked: dropShadowEffect.running = !dropShadowEffect.running }
}
Image {
diff --git a/examples/declarative/extending/attached/birthdayparty.cpp b/examples/declarative/extending/attached/birthdayparty.cpp
index 9dc13de..ffdda57 100644
--- a/examples/declarative/extending/attached/birthdayparty.cpp
+++ b/examples/declarative/extending/attached/birthdayparty.cpp
@@ -72,9 +72,19 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlList<Person *> *BirthdayParty::guests()
+QmlListProperty<Person> BirthdayParty::guests()
{
- return &m_guests;
+ return QmlListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
}
BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
diff --git a/examples/declarative/extending/attached/birthdayparty.h b/examples/declarative/extending/attached/birthdayparty.h
index bd8952b..9ba0f8b 100644
--- a/examples/declarative/extending/attached/birthdayparty.h
+++ b/examples/declarative/extending/attached/birthdayparty.h
@@ -65,7 +65,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_PROPERTY(QmlListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -73,12 +73,14 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlList<Person *> *guests();
+ QmlListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
static BirthdayPartyAttached *qmlAttachedProperties(QObject *);
private:
Person *m_celebrant;
- QmlConcreteList<Person *> m_guests;
+ QList<Person *> m_guests;
};
QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES)
diff --git a/examples/declarative/extending/attached/main.cpp b/examples/declarative/extending/attached/main.cpp
index 2ec783f..27a9287 100644
--- a/examples/declarative/extending/attached/main.cpp
+++ b/examples/declarative/extending/attached/main.cpp
@@ -61,8 +61,8 @@ int main(int argc, char ** argv)
else
qWarning() << "She is inviting:";
- for (int ii = 0; ii < party->guests()->count(); ++ii) {
- Person *guest = party->guests()->at(ii);
+ for (int ii = 0; ii < party->guestCount(); ++ii) {
+ Person *guest = party->guest(ii);
QDate rsvpDate;
QObject *attached =
diff --git a/examples/declarative/extending/binding/birthdayparty.cpp b/examples/declarative/extending/binding/birthdayparty.cpp
index 8a409af..62b9c7b 100644
--- a/examples/declarative/extending/binding/birthdayparty.cpp
+++ b/examples/declarative/extending/binding/birthdayparty.cpp
@@ -77,9 +77,19 @@ void BirthdayParty::setCelebrant(Person *c)
emit celebrantChanged();
}
-QmlList<Person *> *BirthdayParty::guests()
+QmlListProperty<Person> BirthdayParty::guests()
{
- return &m_guests;
+ return QmlListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
}
void BirthdayParty::startParty()
diff --git a/examples/declarative/extending/binding/birthdayparty.h b/examples/declarative/extending/binding/birthdayparty.h
index 5651c65..8bdb76a 100644
--- a/examples/declarative/extending/binding/birthdayparty.h
+++ b/examples/declarative/extending/binding/birthdayparty.h
@@ -71,7 +71,7 @@ Q_OBJECT
// ![0]
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant NOTIFY celebrantChanged)
// ![0]
-Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_PROPERTY(QmlListProperty<Person> guests READ guests)
Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker)
Q_CLASSINFO("DefaultProperty", "guests")
public:
@@ -80,7 +80,9 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlList<Person *> *guests();
+ QmlListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
QString speaker() const;
void setSpeaker(const QString &);
@@ -94,7 +96,7 @@ signals:
private:
Person *m_celebrant;
- QmlConcreteList<Person *> m_guests;
+ QList<Person *> m_guests;
};
QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES)
diff --git a/examples/declarative/extending/binding/main.cpp b/examples/declarative/extending/binding/main.cpp
index 4ad9929..ba38e82 100644
--- a/examples/declarative/extending/binding/main.cpp
+++ b/examples/declarative/extending/binding/main.cpp
@@ -61,8 +61,8 @@ int main(int argc, char ** argv)
else
qWarning() << "She is inviting:";
- for (int ii = 0; ii < party->guests()->count(); ++ii) {
- Person *guest = party->guests()->at(ii);
+ for (int ii = 0; ii < party->guestCount(); ++ii) {
+ Person *guest = party->guest(ii);
QDate rsvpDate;
QObject *attached =
diff --git a/examples/declarative/extending/coercion/birthdayparty.cpp b/examples/declarative/extending/coercion/birthdayparty.cpp
index 014d307..15a4ca9 100644
--- a/examples/declarative/extending/coercion/birthdayparty.cpp
+++ b/examples/declarative/extending/coercion/birthdayparty.cpp
@@ -55,9 +55,19 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlList<Person *> *BirthdayParty::guests()
+QmlListProperty<Person> BirthdayParty::guests()
{
- return &m_guests;
+ return QmlListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
}
QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/coercion/birthdayparty.h b/examples/declarative/extending/coercion/birthdayparty.h
index 8563ec3..5a9eb08 100644
--- a/examples/declarative/extending/coercion/birthdayparty.h
+++ b/examples/declarative/extending/coercion/birthdayparty.h
@@ -50,7 +50,7 @@ class BirthdayParty : public QObject
Q_OBJECT
// ![0]
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_PROPERTY(QmlListProperty<Person> guests READ guests)
// ![0]
public:
BirthdayParty(QObject *parent = 0);
@@ -58,11 +58,13 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlList<Person *> *guests();
+ QmlListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
private:
Person *m_celebrant;
- QmlConcreteList<Person *> m_guests;
+ QList<Person *> m_guests;
};
QML_DECLARE_TYPE(BirthdayParty);
diff --git a/examples/declarative/extending/coercion/main.cpp b/examples/declarative/extending/coercion/main.cpp
index c6cc847..ccbee83 100644
--- a/examples/declarative/extending/coercion/main.cpp
+++ b/examples/declarative/extending/coercion/main.cpp
@@ -60,8 +60,9 @@ int main(int argc, char ** argv)
qWarning() << "He is inviting:";
else
qWarning() << "She is inviting:";
- for (int ii = 0; ii < party->guests()->count(); ++ii)
- qWarning() << " " << party->guests()->at(ii)->name();
+
+ for (int ii = 0; ii < party->guestCount(); ++ii)
+ qWarning() << " " << party->guest(ii)->name();
} else {
qWarning() << "An error occured";
}
diff --git a/examples/declarative/extending/default/birthdayparty.cpp b/examples/declarative/extending/default/birthdayparty.cpp
index 014d307..15a4ca9 100644
--- a/examples/declarative/extending/default/birthdayparty.cpp
+++ b/examples/declarative/extending/default/birthdayparty.cpp
@@ -55,9 +55,19 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlList<Person *> *BirthdayParty::guests()
+QmlListProperty<Person> BirthdayParty::guests()
{
- return &m_guests;
+ return QmlListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
}
QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/default/birthdayparty.h b/examples/declarative/extending/default/birthdayparty.h
index 869b32c..f25f8c2 100644
--- a/examples/declarative/extending/default/birthdayparty.h
+++ b/examples/declarative/extending/default/birthdayparty.h
@@ -50,7 +50,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_PROPERTY(QmlListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -58,11 +58,13 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlList<Person *> *guests();
+ QmlListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
private:
Person *m_celebrant;
- QmlConcreteList<Person *> m_guests;
+ QList<Person *> m_guests;
};
// ![0]
QML_DECLARE_TYPE(BirthdayParty);
diff --git a/examples/declarative/extending/default/main.cpp b/examples/declarative/extending/default/main.cpp
index c6cc847..ccbee83 100644
--- a/examples/declarative/extending/default/main.cpp
+++ b/examples/declarative/extending/default/main.cpp
@@ -60,8 +60,9 @@ int main(int argc, char ** argv)
qWarning() << "He is inviting:";
else
qWarning() << "She is inviting:";
- for (int ii = 0; ii < party->guests()->count(); ++ii)
- qWarning() << " " << party->guests()->at(ii)->name();
+
+ for (int ii = 0; ii < party->guestCount(); ++ii)
+ qWarning() << " " << party->guest(ii)->name();
} else {
qWarning() << "An error occured";
}
diff --git a/examples/declarative/extending/grouped/birthdayparty.cpp b/examples/declarative/extending/grouped/birthdayparty.cpp
index 014d307..15a4ca9 100644
--- a/examples/declarative/extending/grouped/birthdayparty.cpp
+++ b/examples/declarative/extending/grouped/birthdayparty.cpp
@@ -55,9 +55,19 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlList<Person *> *BirthdayParty::guests()
+QmlListProperty<Person> BirthdayParty::guests()
{
- return &m_guests;
+ return QmlListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
}
QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/grouped/birthdayparty.h b/examples/declarative/extending/grouped/birthdayparty.h
index 3f4a3a6..fd0d955 100644
--- a/examples/declarative/extending/grouped/birthdayparty.h
+++ b/examples/declarative/extending/grouped/birthdayparty.h
@@ -49,7 +49,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_PROPERTY(QmlListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -57,11 +57,13 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlList<Person *> *guests();
+ QmlListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
private:
Person *m_celebrant;
- QmlConcreteList<Person *> m_guests;
+ QList<Person *> m_guests;
};
QML_DECLARE_TYPE(BirthdayParty);
diff --git a/examples/declarative/extending/grouped/main.cpp b/examples/declarative/extending/grouped/main.cpp
index 23ba8bf..79aaab5 100644
--- a/examples/declarative/extending/grouped/main.cpp
+++ b/examples/declarative/extending/grouped/main.cpp
@@ -62,8 +62,8 @@ int main(int argc, char ** argv)
qWarning() << "She is inviting:";
Person *bestShoe = 0;
- for (int ii = 0; ii < party->guests()->count(); ++ii) {
- Person *guest = party->guests()->at(ii);
+ for (int ii = 0; ii < party->guestCount(); ++ii) {
+ Person *guest = party->guest(ii);
qWarning() << " " << guest->name();
if (!bestShoe || bestShoe->shoe()->price() < guest->shoe()->price())
diff --git a/examples/declarative/extending/properties/birthdayparty.cpp b/examples/declarative/extending/properties/birthdayparty.cpp
index 332b090..23e6e58 100644
--- a/examples/declarative/extending/properties/birthdayparty.cpp
+++ b/examples/declarative/extending/properties/birthdayparty.cpp
@@ -56,9 +56,19 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlList<Person *> *BirthdayParty::guests()
+QmlListProperty<Person> BirthdayParty::guests()
{
- return &m_guests;
+ return QmlListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
}
// ![0]
diff --git a/examples/declarative/extending/properties/birthdayparty.h b/examples/declarative/extending/properties/birthdayparty.h
index ceefd5b..e5d316c 100644
--- a/examples/declarative/extending/properties/birthdayparty.h
+++ b/examples/declarative/extending/properties/birthdayparty.h
@@ -54,7 +54,7 @@ Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
// ![1]
// ![2]
-Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_PROPERTY(QmlListProperty<Person> guests READ guests)
// ![2]
// ![3]
public:
@@ -63,11 +63,13 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlList<Person *> *guests();
+ QmlListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
private:
Person *m_celebrant;
- QmlConcreteList<Person *> m_guests;
+ QList<Person *> m_guests;
};
QML_DECLARE_TYPE(BirthdayParty);
// ![3]
diff --git a/examples/declarative/extending/properties/main.cpp b/examples/declarative/extending/properties/main.cpp
index 229e59a..97d7905 100644
--- a/examples/declarative/extending/properties/main.cpp
+++ b/examples/declarative/extending/properties/main.cpp
@@ -56,8 +56,8 @@ int main(int argc, char ** argv)
if (party && party->celebrant()) {
qWarning() << party->celebrant()->name() << "is having a birthday!";
qWarning() << "They are inviting:";
- for (int ii = 0; ii < party->guests()->count(); ++ii)
- qWarning() << " " << party->guests()->at(ii)->name();
+ for (int ii = 0; ii < party->guestCount(); ++ii)
+ qWarning() << " " << party->guest(ii)->name();
} else {
qWarning() << "An error occured";
}
diff --git a/examples/declarative/extending/signal/birthdayparty.cpp b/examples/declarative/extending/signal/birthdayparty.cpp
index 88c5459..d8686f0 100644
--- a/examples/declarative/extending/signal/birthdayparty.cpp
+++ b/examples/declarative/extending/signal/birthdayparty.cpp
@@ -72,9 +72,19 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlList<Person *> *BirthdayParty::guests()
+QmlListProperty<Person> BirthdayParty::guests()
{
- return &m_guests;
+ return QmlListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
}
void BirthdayParty::startParty()
diff --git a/examples/declarative/extending/signal/birthdayparty.h b/examples/declarative/extending/signal/birthdayparty.h
index 8ce5d7b..30ed43b 100644
--- a/examples/declarative/extending/signal/birthdayparty.h
+++ b/examples/declarative/extending/signal/birthdayparty.h
@@ -65,7 +65,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_PROPERTY(QmlListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -73,7 +73,9 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlList<Person *> *guests();
+ QmlListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
static BirthdayPartyAttached *qmlAttachedProperties(QObject *);
@@ -85,7 +87,7 @@ signals:
private:
Person *m_celebrant;
- QmlConcreteList<Person *> m_guests;
+ QList<Person *> m_guests;
};
QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES)
diff --git a/examples/declarative/extending/signal/main.cpp b/examples/declarative/extending/signal/main.cpp
index 4e981c5..eb3bb4b 100644
--- a/examples/declarative/extending/signal/main.cpp
+++ b/examples/declarative/extending/signal/main.cpp
@@ -61,8 +61,8 @@ int main(int argc, char ** argv)
else
qWarning() << "She is inviting:";
- for (int ii = 0; ii < party->guests()->count(); ++ii) {
- Person *guest = party->guests()->at(ii);
+ for (int ii = 0; ii < party->guestCount(); ++ii) {
+ Person *guest = party->guest(ii);
QDate rsvpDate;
QObject *attached =
diff --git a/examples/declarative/extending/valuesource/birthdayparty.cpp b/examples/declarative/extending/valuesource/birthdayparty.cpp
index b483f68..a5b3fab 100644
--- a/examples/declarative/extending/valuesource/birthdayparty.cpp
+++ b/examples/declarative/extending/valuesource/birthdayparty.cpp
@@ -72,9 +72,19 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlList<Person *> *BirthdayParty::guests()
+QmlListProperty<Person> BirthdayParty::guests()
{
- return &m_guests;
+ return QmlListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
}
void BirthdayParty::startParty()
diff --git a/examples/declarative/extending/valuesource/birthdayparty.h b/examples/declarative/extending/valuesource/birthdayparty.h
index e7ca461..b5a0522 100644
--- a/examples/declarative/extending/valuesource/birthdayparty.h
+++ b/examples/declarative/extending/valuesource/birthdayparty.h
@@ -66,7 +66,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_PROPERTY(QmlListProperty<Person> guests READ guests)
// ![0]
Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker)
// ![0]
@@ -77,7 +77,10 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlList<Person *> *guests();
+ QmlListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
+
QString speaker() const;
void setSpeaker(const QString &);
@@ -90,7 +93,7 @@ signals:
private:
Person *m_celebrant;
- QmlConcreteList<Person *> m_guests;
+ QList<Person *> m_guests;
};
QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES)
diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp
index 4ad9929..ba38e82 100644
--- a/examples/declarative/extending/valuesource/main.cpp
+++ b/examples/declarative/extending/valuesource/main.cpp
@@ -61,8 +61,8 @@ int main(int argc, char ** argv)
else
qWarning() << "She is inviting:";
- for (int ii = 0; ii < party->guests()->count(); ++ii) {
- Person *guest = party->guests()->at(ii);
+ for (int ii = 0; ii < party->guestCount(); ++ii) {
+ Person *guest = party->guest(ii);
QDate rsvpDate;
QObject *attached =
diff --git a/examples/declarative/layouts/Button.qml b/examples/declarative/layouts/Button.qml
index 44d0c7b..0bdb9fc 100644
--- a/examples/declarative/layouts/Button.qml
+++ b/examples/declarative/layouts/Button.qml
@@ -7,7 +7,7 @@ Rectangle { border.color: "black"; color: "steelblue"; radius: 5; width: pix.wid
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;}
- MouseRegion{ id:mr; anchors.fill: parent; onClicked: {parent.focus = true; page.clicked()}}
+ MouseArea{ id:mr; anchors.fill: parent; onClicked: {parent.focus = true; page.clicked()}}
states:
State{ name:"pressed"; when:mr.pressed
diff --git a/examples/declarative/listview/content/ClickAutoRepeating.qml b/examples/declarative/listview/content/ClickAutoRepeating.qml
index be37b50..0850f4e 100644
--- a/examples/declarative/listview/content/ClickAutoRepeating.qml
+++ b/examples/declarative/listview/content/ClickAutoRepeating.qml
@@ -23,7 +23,7 @@ Item {
PauseAnimation { duration: repeatperiod }
}
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onPressed: autoRepeat.start()
onReleased: { autoRepeat.stop(); parent.isPressed = false; page.released() }
diff --git a/examples/declarative/listview/content/MediaButton.qml b/examples/declarative/listview/content/MediaButton.qml
index 1c88844..e9065c1 100644
--- a/examples/declarative/listview/content/MediaButton.qml
+++ b/examples/declarative/listview/content/MediaButton.qml
@@ -14,7 +14,7 @@ Item {
source: "pics/button-pressed.png"
opacity: 0
}
- MouseRegion {
+ MouseArea {
id: clickRegion
anchors.fill: normal
onClicked: { container.clicked(); }
diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml
index dd898f9..81550d7 100644
--- a/examples/declarative/listview/dynamic.qml
+++ b/examples/declarative/listview/dynamic.qml
@@ -57,10 +57,10 @@ Rectangle {
Column {
id: moveButtons; x: 5; width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter
Image { source: "content/pics/go-up.png"
- MouseRegion { anchors.fill: parent; onClicked: fruitModel.move(index,index-1,1) }
+ MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index-1,1) }
}
Image { source: "content/pics/go-down.png"
- MouseRegion { anchors.fill: parent; onClicked: fruitModel.move(index,index+1,1) }
+ MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index+1,1) }
}
}
@@ -93,7 +93,7 @@ Rectangle {
Image {
id: removeButton; source: "content/pics/archive-remove.png"
anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: 10 }
- MouseRegion { anchors.fill:parent; onClicked: fruitModel.remove(index) }
+ MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) }
}
}
}
@@ -131,7 +131,7 @@ Rectangle {
spacing: 8
id: buttons
Image { source: "content/pics/archive-insert.png"
- MouseRegion { anchors.fill: parent;
+ MouseArea { anchors.fill: parent;
onClicked: {
fruitModel.append({
"name":"Pizza Margarita",
@@ -142,7 +142,7 @@ Rectangle {
}
}
Image { source: "content/pics/archive-insert.png"
- MouseRegion { anchors.fill: parent;
+ MouseArea { anchors.fill: parent;
onClicked: {
fruitModel.insert(0,{
"name":"Pizza Supreme",
@@ -153,7 +153,7 @@ Rectangle {
}
}
Image { source: "content/pics/archive-remove.png"
- MouseRegion { anchors.fill: parent; onClicked: fruitModel.clear() }
+ MouseArea { anchors.fill: parent; onClicked: fruitModel.clear() }
}
}
}
diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml
index 6392153..54981b7 100644
--- a/examples/declarative/listview/itemlist.qml
+++ b/examples/declarative/listview/itemlist.qml
@@ -51,7 +51,7 @@ Rectangle {
Rectangle {
width: 5; height: 5
radius: 3
- MouseRegion { width: 20; height: 20; anchors.centerIn: parent; onClicked: view.currentIndex = index }
+ MouseArea { width: 20; height: 20; anchors.centerIn: parent; onClicked: view.currentIndex = index }
color: view.currentIndex == index ? "blue" : "white"
}
}
diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml
index 3410f56..f848be0 100644
--- a/examples/declarative/listview/recipes.qml
+++ b/examples/declarative/listview/recipes.qml
@@ -32,7 +32,7 @@ Rectangle {
// 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.
- MouseRegion {
+ MouseArea {
id: pageMouse
anchors.fill: parent
onClicked: wrapper.state = 'Details';
diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml
index d07d471..9191f8a 100644
--- a/examples/declarative/mouseregion/mouse.qml
+++ b/examples/declarative/mouseregion/mouse.qml
@@ -7,7 +7,7 @@ Rectangle {
width: 50; height: 50
color: "red"
Text { text: "Click"; anchors.centerIn: parent }
- MouseRegion {
+ MouseArea {
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressed: { console.log('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') }
@@ -24,7 +24,7 @@ Rectangle {
y: 100; width: 50; height: 50
color: "blue"
Text { text: "Drag"; anchors.centerIn: parent }
- MouseRegion {
+ MouseArea {
drag.target: parent
drag.axis: "XAxis"
drag.minimumX: 0
diff --git a/examples/declarative/objectlistmodel/main.cpp b/examples/declarative/objectlistmodel/main.cpp
index 5eb6b7d..9e38bea 100644
--- a/examples/declarative/objectlistmodel/main.cpp
+++ b/examples/declarative/objectlistmodel/main.cpp
@@ -68,7 +68,7 @@ int main(int argc, char ** argv)
dataList.append(new DataObject("Item 4", "yellow"));
QmlContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", QVariant::fromValue(&dataList));
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
view.execute();
view.show();
diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml
index f10d374..811891b 100644
--- a/examples/declarative/parallax/qml/ParallaxView.qml
+++ b/examples/declarative/parallax/qml/ParallaxView.qml
@@ -58,7 +58,7 @@ Item {
transformOrigin: "Center"
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: { root.currentIndex = index }
}
diff --git a/examples/declarative/searchbox/SearchBox.qml b/examples/declarative/searchbox/SearchBox.qml
index 7077a11..524b652 100644
--- a/examples/declarative/searchbox/SearchBox.qml
+++ b/examples/declarative/searchbox/SearchBox.qml
@@ -23,7 +23,7 @@ FocusScope {
text: "Type something..."; color: "gray"; font.italic: true
}
- MouseRegion { anchors.fill: parent; onClicked: focusScope.focus = true }
+ MouseArea { anchors.fill: parent; onClicked: focusScope.focus = true }
TextInput {
id: textInput
@@ -38,7 +38,7 @@ FocusScope {
anchors.verticalCenter: parent.verticalCenter
source: "images/edit-clear-locationbar-rtl.png"; opacity: 0
- MouseRegion { anchors.fill: parent; onClicked: { textInput.text = ''; focusScope.focus = true } }
+ MouseArea { anchors.fill: parent; onClicked: { textInput.text = ''; focusScope.focus = true } }
}
states: State {
diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml
index c7f1c24..930f471 100644
--- a/examples/declarative/slideswitch/content/Switch.qml
+++ b/examples/declarative/slideswitch/content/Switch.qml
@@ -32,7 +32,7 @@ Item {
//![4]
Image {
id: background; source: "background.svg"
- MouseRegion { anchors.fill: parent; onClicked: toggle() }
+ MouseArea { anchors.fill: parent; onClicked: toggle() }
}
//![4]
@@ -40,7 +40,7 @@ Item {
Image {
id: knob; source: "knob.svg"; x: 1; y: 2
- MouseRegion {
+ MouseArea {
anchors.fill: parent
drag.target: knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78
onClicked: toggle()
diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml
index 6f6b40f..89f2421 100644
--- a/examples/declarative/states/states.qml
+++ b/examples/declarative/states/states.qml
@@ -10,7 +10,7 @@ Rectangle {
anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 }
width: 64; height: 64; radius: 6
color: "Transparent"; border.color: "Gray"
- MouseRegion { anchors.fill: parent; onClicked: page.state = '' }
+ MouseArea { anchors.fill: parent; onClicked: page.state = '' }
}
// Another target region. Clicking in here sets the state to 'Position1'
@@ -19,7 +19,7 @@ Rectangle {
anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 }
width: 64; height: 64; radius: 6
color: "Transparent"; border.color: "Gray"
- MouseRegion { anchors.fill: parent; onClicked: page.state = 'Position1' }
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'Position1' }
}
// Another target region. Clicking in here sets the state to 'Position2'
@@ -28,7 +28,7 @@ Rectangle {
anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 }
width: 64; height: 64; radius: 6
color: "Transparent"; border.color: "Gray"
- MouseRegion { anchors.fill: parent; onClicked: page.state = 'Position2' }
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'Position2' }
}
// The image which will be moved when my state changes
diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml
index ba97d9be..48d5f60 100644
--- a/examples/declarative/states/transitions.qml
+++ b/examples/declarative/states/transitions.qml
@@ -10,7 +10,7 @@ Rectangle {
anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 }
width: 64; height: 64; radius: 6
color: "Transparent"; border.color: "Gray"
- MouseRegion { anchors.fill: parent; onClicked: page.state = '' }
+ MouseArea { anchors.fill: parent; onClicked: page.state = '' }
}
// Another target region. Clicking in here sets the state to 'Position1'
@@ -19,7 +19,7 @@ Rectangle {
anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 }
width: 64; height: 64; radius: 6
color: "Transparent"; border.color: "Gray"
- MouseRegion { anchors.fill: parent; onClicked: page.state = 'Position1' }
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'Position1' }
}
// Another target region. Clicking in here sets the state to 'Position2'
@@ -28,7 +28,7 @@ Rectangle {
anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 }
width: 64; height: 64; radius: 6
color: "Transparent"; border.color: "Gray"
- MouseRegion { anchors.fill: parent; onClicked: page.state = 'Position2' }
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'Position2' }
}
// The image which will be moved when my state changes
diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml
index c56f41e..f0dfee8 100644
--- a/examples/declarative/tabwidget/TabWidget.qml
+++ b/examples/declarative/tabwidget/TabWidget.qml
@@ -25,7 +25,7 @@ Item {
text: stack.children[index].title
elide: Text.ElideRight
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: page.current = index
}
diff --git a/examples/declarative/tic-tac-toe/content/TicTac.qml b/examples/declarative/tic-tac-toe/content/TicTac.qml
index eb80743..ccb7b78 100644
--- a/examples/declarative/tic-tac-toe/content/TicTac.qml
+++ b/examples/declarative/tic-tac-toe/content/TicTac.qml
@@ -13,7 +13,7 @@ Item {
anchors.centerIn: parent
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: parent.clicked()
}
diff --git a/examples/declarative/tutorials/helloworld/Cell.qml b/examples/declarative/tutorials/helloworld/Cell.qml
index c38b40e..de4f3bb 100644
--- a/examples/declarative/tutorials/helloworld/Cell.qml
+++ b/examples/declarative/tutorials/helloworld/Cell.qml
@@ -23,7 +23,7 @@ Item {
//![2]
//![3]
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: container.clicked(container.color)
}
diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml
index 107b066..9eaa009 100644
--- a/examples/declarative/tutorials/helloworld/tutorial3.qml
+++ b/examples/declarative/tutorials/helloworld/tutorial3.qml
@@ -14,7 +14,7 @@ Rectangle {
transformOrigin: Item.Center
//![1]
- MouseRegion { id: mouseRegion; anchors.fill: parent }
+ MouseArea { id: mouseRegion; anchors.fill: parent }
//![1]
//![2]
diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml
index 85e6777..2e31ff8 100644
--- a/examples/declarative/tutorials/samegame/samegame1/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml
@@ -18,7 +18,7 @@ Rectangle {
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ 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/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml
index 63cd555..6629302 100644
--- a/examples/declarative/tutorials/samegame/samegame2/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame2/Button.qml
@@ -17,7 +17,7 @@ Rectangle {
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ 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/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml
index 63cd555..6629302 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Button.qml
@@ -17,7 +17,7 @@ Rectangle {
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ 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/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
index 96dc246..9d35832 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
@@ -18,6 +18,6 @@ Rectangle {
NumberAnimation { duration: 1000 }
}
Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
- MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); }
+ MouseArea { id: mr; anchors.fill: parent; onClicked: forceClose(); }
}
//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
index 8bdb428..c616397 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
@@ -27,7 +27,7 @@ Rectangle {
width: parent.width - (parent.width % tileSize);
height: parent.height - (parent.height % tileSize);
- MouseRegion {
+ MouseArea {
id: gameMR
anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y);
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
index 63cd555..6629302 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
@@ -17,7 +17,7 @@ Rectangle {
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseRegion { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ 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/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
index 3371d53..ed9fd32 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
@@ -17,5 +17,5 @@ Rectangle {
NumberAnimation { duration: 1000 }
}
Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
- MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); }
+ MouseArea { id: mr; anchors.fill: parent; onClicked: forceClose(); }
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/tutorials/samegame/samegame4/samegame.qml
index 19b929f..a228e60 100644
--- a/examples/declarative/tutorials/samegame/samegame4/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/samegame.qml
@@ -27,7 +27,7 @@ Rectangle {
width: parent.width - (parent.width % getTileSize());
height: parent.height - (parent.height % getTileSize());
- MouseRegion {
+ MouseArea {
id: gameMR
anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y);
}
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
index 030fa13..c39f99b 100644
--- a/examples/declarative/velocity/Day.qml
+++ b/examples/declarative/velocity/Day.qml
@@ -48,7 +48,7 @@ Rectangle {
x: stickyImage.x
width: stickyImage.width * stickyImage.scale
height: stickyImage.height * stickyImage.scale
- MouseRegion {
+ MouseArea {
id: mouse
onClicked: { myText.focus = true }
anchors.fill: parent
diff --git a/examples/declarative/webview/content/FieldText.qml b/examples/declarative/webview/content/FieldText.qml
index b1c1938..19b6acc 100644
--- a/examples/declarative/webview/content/FieldText.qml
+++ b/examples/declarative/webview/content/FieldText.qml
@@ -93,17 +93,17 @@ Item {
}
}
- MouseRegion {
+ MouseArea {
anchors.fill: cancelIcon
onClicked: { reset() }
}
- MouseRegion {
+ MouseArea {
anchors.fill: confirmIcon
onClicked: { confirm() }
}
- MouseRegion {
+ MouseArea {
id: editRegion
anchors.fill: textEdit
onClicked: { edit() }
diff --git a/examples/declarative/webview/evalandattach.html b/examples/declarative/webview/evalandattach.html
index c0992bb..48a1c33 100644
--- a/examples/declarative/webview/evalandattach.html
+++ b/examples/declarative/webview/evalandattach.html
@@ -1,7 +1,7 @@
<body bgcolor=gray onload="ftext.confirmed.connect (ftext_confirmed); ">
<script>
do_it = function () {var oPressed = document.getElementById('pressed');
- oPressed.innerHTML = 'MouseRegion in QML clicked!';};
+ oPressed.innerHTML = 'MouseArea in QML clicked!';};
ftext_confirmed = function () { statusText1.text = ftext.text; var oT = document.getElementById('htmlTextInput'); oT.value = ftext.text }
</script>
<table border=1>
diff --git a/examples/declarative/webview/evalandattach.qml b/examples/declarative/webview/evalandattach.qml
index 1b211c9..94301cd 100644
--- a/examples/declarative/webview/evalandattach.qml
+++ b/examples/declarative/webview/evalandattach.qml
@@ -21,7 +21,7 @@ Item {
anchors.right: parent.right
}
- MouseRegion {
+ MouseArea {
anchors.fill: teksti
onClicked: { webView.evaluateJavaScript ("do_it()") }
}
diff --git a/examples/declarative/workerscript/workerscript.qml b/examples/declarative/workerscript/workerscript.qml
index e36d4d4..0566f1f 100644
--- a/examples/declarative/workerscript/workerscript.qml
+++ b/examples/declarative/workerscript/workerscript.qml
@@ -20,7 +20,7 @@ Rectangle {
anchors.leftMargin: 20
color: "red"
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } );
}
@@ -32,7 +32,7 @@ Rectangle {
anchors.rightMargin: 20
color: "blue"
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } );
}
diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml
index 23463c2..b80e29c 100644
--- a/examples/declarative/xmldata/yahoonews.qml
+++ b/examples/declarative/xmldata/yahoonews.qml
@@ -22,7 +22,7 @@ Rectangle {
id: delegate
height: wrapper.height + 10
- MouseRegion {
+ MouseArea {
anchors.fill: wrapper
onPressed: delegate.ListView.view.currentIndex = index;
onClicked: if (wrapper.state == 'Details') wrapper.state = ''; else wrapper.state = 'Details';
diff --git a/examples/declarative/xmlhttprequest/test.qml b/examples/declarative/xmlhttprequest/test.qml
index 18e328b..15ac54b 100644
--- a/examples/declarative/xmlhttprequest/test.qml
+++ b/examples/declarative/xmlhttprequest/test.qml
@@ -3,7 +3,7 @@ import Qt 4.6
Rectangle {
width: 800; height: 600
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: {
diff --git a/src/3rdparty/libpng/pngconf.h b/src/3rdparty/libpng/pngconf.h
index 9eec6d3..5d202db 100644
--- a/src/3rdparty/libpng/pngconf.h
+++ b/src/3rdparty/libpng/pngconf.h
@@ -330,7 +330,7 @@
#endif
/* Enough people need this for various reasons to include it here */
-#if !defined(MACOS) && !defined(RISCOS)
+#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE)
# include <sys/types.h>
#endif
diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc
index 411762a..9e653e4 100644
--- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc
+++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc
@@ -83,9 +83,6 @@
QtWebKit is based on the Open Source WebKit engine. More information about
WebKit itself can be found on the \l{WebKit Open Source Project} Web site.
- The QtWebKit module is part of the \l{Qt Full Framework Edition}, and the
- \l{Open Source Versions of Qt}.
-
\note Building the QtWebKit module with debugging symbols is problematic
on many platforms due to the size of the WebKit engine. We recommend
building the module only in release mode for embedded platforms.
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index a27e488..3324796 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -1804,7 +1804,20 @@ QByteArray &QByteArray::replace(int pos, int len, const QByteArray &after)
*/
QByteArray &QByteArray::replace(int pos, int len, const char *after)
{
- int alen = qstrlen(after);
+ return replace(pos,len,after,qstrlen(after));
+}
+
+/*! \fn QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen)
+
+ \overload
+
+ Replaces \a len bytes from index position \a pos with \a alen bytes
+ from the string \a after. \a after is allowed to have '\0' characters.
+
+ \since 4.7
+*/
+QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen)
+{
if (len == alen && (pos + len <= d->size)) {
detach();
memcpy(d->data + pos, after, len*sizeof(char));
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index ec592f5f..0b77512 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -237,6 +237,7 @@ public:
QByteArray &insert(int i, const QByteArray &a);
QByteArray &remove(int index, int len);
QByteArray &replace(int index, int len, const char *s);
+ QByteArray &replace(int index, int len, const char *s, int alen);
QByteArray &replace(int index, int len, const QByteArray &s);
QByteArray &replace(char before, const char *after);
QByteArray &replace(char before, const QByteArray &after);
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index ac0dc46..6f5bb9b 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -66,6 +66,53 @@ static int grow(int size)
return x;
}
+/*!
+ * Detaches the QListData by allocating new memory for a list which will be bigger
+ * than the copied one and is expected to grow further.
+ * *idx is the desired insertion point and is clamped to the actual size of the list.
+ * num is the number of new elements to insert at the insertion point.
+ * Returns the old (shared) data, it is up to the caller to deref() and free().
+ * For the new data node_copy needs to be called.
+ *
+ * \internal
+ */
+QListData::Data *QListData::detach_grow(int *idx, int num)
+{
+ Data *x = d;
+ int l = x->end - x->begin;
+ int nl = l + num;
+ int alloc = grow(nl);
+ Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + alloc * sizeof(void *)));
+ Q_CHECK_PTR(t);
+
+ t->ref = 1;
+ t->sharable = true;
+ t->alloc = alloc;
+ // The space reservation algorithm's optimization is biased towards appending:
+ // Something which looks like an append will put the data at the beginning,
+ // while something which looks like a prepend will put it in the middle
+ // instead of at the end. That's based on the assumption that prepending
+ // is uncommon and even an initial prepend will eventually be followed by
+ // at least some appends.
+ int bg;
+ if (*idx < 0) {
+ *idx = 0;
+ bg = (alloc - nl) >> 1;
+ } else if (*idx > l) {
+ *idx = l;
+ bg = 0;
+ } else if (*idx < (l >> 1)) {
+ bg = (alloc - nl) >> 1;
+ } else {
+ bg = 0;
+ }
+ t->begin = bg;
+ t->end = bg + nl;
+ d = t;
+
+ return x;
+}
+
#if QT_VERSION >= 0x050000
# error "Remove QListData::detach(), it is only required for binary compatibility for 4.0.x to 4.2.x"
#endif
@@ -180,22 +227,30 @@ void QListData::realloc(int alloc)
d->begin = d->end = 0;
}
-// ensures that enough space is available to append one element
-void **QListData::append()
+// ensures that enough space is available to append n elements
+void **QListData::append(int n)
{
Q_ASSERT(d->ref == 1);
- if (d->end == d->alloc) {
- int n = d->end - d->begin;
- if (d->begin > 2 * d->alloc / 3) {
+ int e = d->end;
+ if (e + n > d->alloc) {
+ int b = d->begin;
+ if (b - n >= 2 * d->alloc / 3) {
// we have enough space. Just not at the end -> move it.
- ::memcpy(d->array + n, d->array + d->begin, n * sizeof(void *));
- d->begin = n;
- d->end = n * 2;
+ e -= b;
+ ::memcpy(d->array, d->array + b, e * sizeof(void *));
+ d->begin = 0;
} else {
- realloc(grow(d->alloc + 1));
+ realloc(grow(d->alloc + n));
}
}
- return d->array + d->end++;
+ d->end = e + n;
+ return d->array + e;
+}
+
+// ensures that enough space is available to append one element
+void **QListData::append()
+{
+ return append(1);
}
// ensures that enough space is available to append the list
@@ -209,7 +264,7 @@ void **QListData::append(const QListData& l)
int n = l.d->end - l.d->begin;
if (n) {
if (e + n > d->alloc)
- realloc(grow(e + l.d->end - l.d->begin));
+ realloc(grow(e + n));
::memcpy(d->array + d->end, l.d->array + l.d->begin, n*sizeof(void*));
d->end += n;
}
@@ -219,15 +274,7 @@ void **QListData::append(const QListData& l)
// ensures that enough space is available to append the list
void **QListData::append2(const QListData& l)
{
- Q_ASSERT(d->ref == 1);
- int e = d->end;
- int n = l.d->end - l.d->begin;
- if (n) {
- if (e + n > d->alloc)
- realloc(grow(e + n));
- d->end += n;
- }
- return d->array + e;
+ return append(l.d->end - l.d->begin);
}
void **QListData::prepend()
@@ -253,11 +300,11 @@ void **QListData::insert(int i)
Q_ASSERT(d->ref == 1);
if (i <= 0)
return prepend();
- if (i >= d->end - d->begin)
+ int size = d->end - d->begin;
+ if (i >= size)
return append();
bool leftward = false;
- int size = d->end - d->begin;
if (d->begin == 0) {
if (d->end == d->alloc) {
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 5364e8e..3a29e13 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -52,6 +52,7 @@
#endif
#include <new>
+#include <limits.h>
#include <string.h>
QT_BEGIN_HEADER
@@ -73,6 +74,7 @@ struct Q_CORE_EXPORT QListData {
enum { DataHeaderSize = sizeof(Data) - sizeof(void *) };
Data *detach(int alloc);
+ Data *detach_grow(int *i, int n);
Data *detach(); // remove in 5.0
Data *detach2(); // remove in 5.0
Data *detach3(); // remove in 5.0
@@ -80,6 +82,7 @@ struct Q_CORE_EXPORT QListData {
static Data shared_null;
Data *d;
void **erase(void **xi);
+ void **append(int n);
void **append();
void **append(const QListData &l);
void **append2(const QListData &l); // remove in 5.0
@@ -95,6 +98,25 @@ struct Q_CORE_EXPORT QListData {
inline void **end() const { return d->array + d->end; }
};
+//////////////////////////////////////////////////////////////////////////////////
+//
+// QtPodForSize and QtPodForType are internal and may change or go away any time.
+// We mean it.
+//
+//////////////////////////////////////////////////////////////////////////////////
+template <int N> struct QtPodForSize {
+ // This base type is rather obviously broken and cannot be made
+ // working due to alignment constraints.
+ // This doesn't matter as far as QList is concerned, as we are
+ // using this type only for QTypeInfo<T>::isLarge == false.
+ typedef struct { } Type;
+};
+template <> struct QtPodForSize<1> { typedef quint8 Type; };
+template <> struct QtPodForSize<2> { typedef quint16 Type; };
+template <> struct QtPodForSize<4> { typedef quint32 Type; };
+template <> struct QtPodForSize<8> { typedef quint64 Type; };
+template <class T> struct QtPodForType : QtPodForSize<sizeof(T)> { };
+
template <typename T>
class QList
{
@@ -333,6 +355,7 @@ public:
#endif
private:
+ Node *detach_helper_grow(int i, int n);
void detach_helper(int alloc);
void detach_helper();
void free(QListData::Data *d);
@@ -480,9 +503,8 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::reserve(int alloc)
template <typename T>
Q_OUTOFLINE_TEMPLATE void QList<T>::append(const T &t)
{
- detach();
- if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
- Node *n = reinterpret_cast<Node *>(p.append());
+ if (d->ref != 1) {
+ Node *n = detach_helper_grow(INT_MAX, 1);
QT_TRY {
node_construct(n, t);
} QT_CATCH(...) {
@@ -490,13 +512,24 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::append(const T &t)
QT_RETHROW;
}
} else {
- const T cpy(t);
- Node *n = reinterpret_cast<Node *>(p.append());
- QT_TRY {
- node_construct(n, cpy);
- } QT_CATCH(...) {
- --d->end;
- QT_RETHROW;
+ if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
+ Node *n = reinterpret_cast<Node *>(p.append());
+ QT_TRY {
+ node_construct(n, t);
+ } QT_CATCH(...) {
+ --d->end;
+ QT_RETHROW;
+ }
+ } else {
+ typedef typename QtPodForType<T>::Type PodNode;
+ PodNode cpy = *reinterpret_cast<const PodNode *>(&t);
+ Node *n = reinterpret_cast<Node *>(p.append());
+ QT_TRY {
+ node_construct(n, *reinterpret_cast<const T *>(&cpy));
+ } QT_CATCH(...) {
+ --d->end;
+ QT_RETHROW;
+ }
}
}
}
@@ -504,9 +537,8 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::append(const T &t)
template <typename T>
inline void QList<T>::prepend(const T &t)
{
- detach();
- if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
- Node *n = reinterpret_cast<Node *>(p.prepend());
+ if (d->ref != 1) {
+ Node *n = detach_helper_grow(0, 1);
QT_TRY {
node_construct(n, t);
} QT_CATCH(...) {
@@ -514,13 +546,24 @@ inline void QList<T>::prepend(const T &t)
QT_RETHROW;
}
} else {
- const T cpy(t);
- Node *n = reinterpret_cast<Node *>(p.prepend());
- QT_TRY {
- node_construct(n, cpy);
- } QT_CATCH(...) {
- ++d->begin;
- QT_RETHROW;
+ if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
+ Node *n = reinterpret_cast<Node *>(p.prepend());
+ QT_TRY {
+ node_construct(n, t);
+ } QT_CATCH(...) {
+ ++d->begin;
+ QT_RETHROW;
+ }
+ } else {
+ typedef typename QtPodForType<T>::Type PodNode;
+ PodNode cpy = *reinterpret_cast<const PodNode *>(&t);
+ Node *n = reinterpret_cast<Node *>(p.prepend());
+ QT_TRY {
+ node_construct(n, *reinterpret_cast<const T *>(&cpy));
+ } QT_CATCH(...) {
+ ++d->begin;
+ QT_RETHROW;
+ }
}
}
}
@@ -528,9 +571,8 @@ inline void QList<T>::prepend(const T &t)
template <typename T>
inline void QList<T>::insert(int i, const T &t)
{
- detach();
- if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
- Node *n = reinterpret_cast<Node *>(p.insert(i));
+ if (d->ref != 1) {
+ Node *n = detach_helper_grow(i, 1);
QT_TRY {
node_construct(n, t);
} QT_CATCH(...) {
@@ -538,13 +580,24 @@ inline void QList<T>::insert(int i, const T &t)
QT_RETHROW;
}
} else {
- const T cpy(t);
- Node *n = reinterpret_cast<Node *>(p.insert(i));
- QT_TRY {
- node_construct(n, cpy);
- } QT_CATCH(...) {
- p.remove(i);
- QT_RETHROW;
+ if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
+ Node *n = reinterpret_cast<Node *>(p.insert(i));
+ QT_TRY {
+ node_construct(n, t);
+ } QT_CATCH(...) {
+ p.remove(i);
+ QT_RETHROW;
+ }
+ } else {
+ typedef typename QtPodForType<T>::Type PodNode;
+ PodNode cpy = *reinterpret_cast<const PodNode *>(&t);
+ Node *n = reinterpret_cast<Node *>(p.insert(i));
+ QT_TRY {
+ node_construct(n, *reinterpret_cast<const T *>(&cpy));
+ } QT_CATCH(...) {
+ p.remove(i);
+ QT_RETHROW;
+ }
}
}
}
@@ -554,12 +607,7 @@ inline void QList<T>::replace(int i, const T &t)
{
Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::replace", "index out of range");
detach();
- if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
- reinterpret_cast<Node *>(p.at(i))->t() = t;
- } else {
- const T cpy(t);
- reinterpret_cast<Node *>(p.at(i))->t() = cpy;
- }
+ reinterpret_cast<Node *>(p.at(i))->t() = t;
}
template <typename T>
@@ -622,6 +670,36 @@ Q_OUTOFLINE_TEMPLATE T QList<T>::value(int i, const T& defaultValue) const
}
template <typename T>
+Q_OUTOFLINE_TEMPLATE typename QList<T>::Node *QList<T>::detach_helper_grow(int i, int c)
+{
+ Node *n = reinterpret_cast<Node *>(p.begin());
+ QListData::Data *x = p.detach_grow(&i, c);
+ QT_TRY {
+ node_copy(reinterpret_cast<Node *>(p.begin()),
+ reinterpret_cast<Node *>(p.begin() + i), n);
+ } QT_CATCH(...) {
+ qFree(d);
+ d = x;
+ QT_RETHROW;
+ }
+ QT_TRY {
+ node_copy(reinterpret_cast<Node *>(p.begin() + i + c),
+ reinterpret_cast<Node *>(p.end()), n + i);
+ } QT_CATCH(...) {
+ node_destruct(reinterpret_cast<Node *>(p.begin()),
+ reinterpret_cast<Node *>(p.begin() + i));
+ qFree(d);
+ d = x;
+ QT_RETHROW;
+ }
+
+ if (!x->ref.deref())
+ free(x);
+
+ return reinterpret_cast<Node *>(p.begin() + i);
+}
+
+template <typename T>
Q_OUTOFLINE_TEMPLATE void QList<T>::detach_helper(int alloc)
{
Node *n = reinterpret_cast<Node *>(p.begin());
@@ -730,8 +808,9 @@ Q_OUTOFLINE_TEMPLATE typename QList<T>::iterator QList<T>::erase(typename QList<
template <typename T>
Q_OUTOFLINE_TEMPLATE QList<T> &QList<T>::operator+=(const QList<T> &l)
{
- detach();
- Node *n = reinterpret_cast<Node *>(p.append2(l.p));
+ Node *n = (d->ref != 1)
+ ? detach_helper_grow(INT_MAX, l.size())
+ : reinterpret_cast<Node *>(p.append2(l.p));
QT_TRY{
node_copy(n, reinterpret_cast<Node *>(p.end()), reinterpret_cast<Node *>(l.p.begin()));
} QT_CATCH(...) {
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index e3aab65..06fa720 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -1,6 +1,8 @@
=============================================================================
The changes below are pre Qt 4.7.0 alpha
+Renamed MouseRegion -> MouseArea
+
QmlView
-------
The API of QmlView has been narrowed and its role as a convenience class
@@ -26,6 +28,11 @@ ListModel
- foo: true is now a bool (not string "true")
- foo: false is now a bool (not string "false" == true!)
+PropertyAnimation
+------------------
+matchProperties and matchTargets have been renamed back to properties and targets.
+The semantics are explained in the PropertyAnimation::properties documentation
+and the animation overview documentation.
=============================================================================
The changes below are pre-4.6.0 release.
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri
index db9c29e..e5343c6 100644
--- a/src/declarative/graphicsitems/graphicsitems.pri
+++ b/src/declarative/graphicsitems/graphicsitems.pri
@@ -28,8 +28,8 @@ HEADERS += \
$$PWD/qmlgraphicspositioners_p_p.h \
$$PWD/qmlgraphicsloader_p.h \
$$PWD/qmlgraphicsloader_p_p.h \
- $$PWD/qmlgraphicsmouseregion_p.h \
- $$PWD/qmlgraphicsmouseregion_p_p.h \
+ $$PWD/qmlgraphicsmousearea_p.h \
+ $$PWD/qmlgraphicsmousearea_p_p.h \
$$PWD/qmlgraphicspath_p.h \
$$PWD/qmlgraphicspath_p_p.h \
$$PWD/qmlgraphicspathview_p.h \
@@ -70,7 +70,7 @@ SOURCES += \
$$PWD/qmlgraphicsfocusscope.cpp \
$$PWD/qmlgraphicspositioners.cpp \
$$PWD/qmlgraphicsloader.cpp \
- $$PWD/qmlgraphicsmouseregion.cpp \
+ $$PWD/qmlgraphicsmousearea.cpp \
$$PWD/qmlgraphicspath.cpp \
$$PWD/qmlgraphicspathview.cpp \
$$PWD/qmlgraphicsrectangle.cpp \
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
index cde9ec7..72b4717 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
@@ -123,6 +123,7 @@ static qreal adjustedPosition(QmlGraphicsItem *item, QmlGraphicsAnchorLine::Anch
/*!
\internal
\class QmlGraphicsAnchors
+ \since 4.7
\ingroup group_layouts
\brief The QmlGraphicsAnchors class provides a way to lay out items relative to other items.
diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
index 697be15..4dea33c 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
@@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass AnimatedImage QmlGraphicsAnimatedImage
\inherits Image
+ \since 4.7
This item provides for playing animations stored as images containing a series of frames,
such as GIF files. The full list of supported formats can be determined with
diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
index f739464..25a220f 100644
--- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
@@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE
\qmlclass BorderImage QmlGraphicsBorderImage
\brief The BorderImage element provides an image that can be used as a border.
\inherits Item
+ \since 4.7
\snippet snippets/declarative/border-image.qml 0
@@ -61,8 +62,8 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \internal
\class QmlGraphicsBorderImage BorderImage
+ \internal
\brief The QmlGraphicsBorderImage class provides an image item that you can add to a QmlView.
*/
diff --git a/src/declarative/graphicsitems/qmlgraphicsevents.cpp b/src/declarative/graphicsitems/qmlgraphicsevents.cpp
index 1f63218..e8ba885 100644
--- a/src/declarative/graphicsitems/qmlgraphicsevents.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsevents.cpp
@@ -44,6 +44,7 @@
QT_BEGIN_NAMESPACE
/*!
\qmlclass KeyEvent QmlGraphicsKeyEvent
+ \since 4.7
\brief The KeyEvent object provides information about a key event.
For example, the following changes the Item's state property when the Enter
@@ -183,7 +184,7 @@ Item {
For example, to react to a Shift key + Left mouse button click:
\qml
-MouseRegion {
+MouseArea {
onClicked: { if (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier) doSomething(); }
}
\endqml
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
index 6825f89..e92fea4 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
@@ -132,8 +132,6 @@ QmlGraphicsFlickablePrivate::QmlGraphicsFlickablePrivate()
, horizontalVelocity(this), verticalVelocity(this), vTime(0), visibleArea(0)
, flickDirection(QmlGraphicsFlickable::AutoFlickDirection)
{
- fixupXEvent = QmlTimeLineEvent::timeLineEvent<QmlGraphicsFlickablePrivate, &QmlGraphicsFlickablePrivate::fixupX>(&_moveX, this);
- fixupYEvent = QmlTimeLineEvent::timeLineEvent<QmlGraphicsFlickablePrivate, &QmlGraphicsFlickablePrivate::fixupY>(&_moveY, this);
}
void QmlGraphicsFlickablePrivate::init()
@@ -176,7 +174,7 @@ void QmlGraphicsFlickablePrivate::flickX(qreal velocity)
}
timeline.reset(_moveX);
timeline.accel(_moveX, v, deceleration, maxDistance);
- timeline.execute(fixupXEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this));
if (!flicked) {
flicked = true;
emit q->flickingChanged();
@@ -214,7 +212,7 @@ void QmlGraphicsFlickablePrivate::flickY(qreal velocity)
}
timeline.reset(_moveY);
timeline.accel(_moveY, v, deceleration, maxDistance);
- timeline.execute(fixupYEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this));
if (!flicked) {
flicked = true;
emit q->flickingChanged();
@@ -255,6 +253,16 @@ void QmlGraphicsFlickablePrivate::fixupX()
vTime = timeline.time();
}
+void QmlGraphicsFlickablePrivate::fixupY_callback(void *data)
+{
+ ((QmlGraphicsFlickablePrivate *)data)->fixupY();
+}
+
+void QmlGraphicsFlickablePrivate::fixupX_callback(void *data)
+{
+ ((QmlGraphicsFlickablePrivate *)data)->fixupX();
+}
+
void QmlGraphicsFlickablePrivate::fixupY()
{
Q_Q(QmlGraphicsFlickable);
@@ -937,51 +945,22 @@ void QmlGraphicsFlickable::cancelFlick()
movementEnding();
}
-void QmlGraphicsFlickablePrivate::data_removeAt(int)
-{
- // ###
-}
-
-int QmlGraphicsFlickablePrivate::data_count() const
-{
- // ###
- return 0;
-}
-
-void QmlGraphicsFlickablePrivate::data_append(QObject *o)
+void QmlGraphicsFlickablePrivate::data_append(QmlListProperty<QObject> *prop, QObject *o)
{
- Q_Q(QmlGraphicsFlickable);
QmlGraphicsItem *i = qobject_cast<QmlGraphicsItem *>(o);
if (i)
- viewport->fxChildren()->append(i);
+ i->setParentItem(static_cast<QmlGraphicsFlickablePrivate*>(prop->data)->viewport);
else
- o->setParent(q);
-}
-
-void QmlGraphicsFlickablePrivate::data_insert(int, QObject *)
-{
- // ###
+ o->setParent(prop->object);
}
-QObject *QmlGraphicsFlickablePrivate::data_at(int) const
-{
- // ###
- return 0;
-}
-
-void QmlGraphicsFlickablePrivate::data_clear()
-{
- // ###
-}
-
-
-QmlList<QObject *> *QmlGraphicsFlickable::flickableData()
+QmlListProperty<QObject> QmlGraphicsFlickable::flickableData()
{
Q_D(QmlGraphicsFlickable);
- return &d->data;
+ return QmlListProperty<QObject>(this, (void *)d, QmlGraphicsFlickablePrivate::data_append);
}
-QmlList<QmlGraphicsItem *> *QmlGraphicsFlickable::flickableChildren()
+QmlListProperty<QmlGraphicsItem> QmlGraphicsFlickable::flickableChildren()
{
Q_D(QmlGraphicsFlickable);
return d->viewport->fxChildren();
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h
index 373815b..580d01e 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h
@@ -82,8 +82,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsFlickable : public QmlGraphicsItem
Q_PROPERTY(QmlGraphicsFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
- Q_PROPERTY(QmlList<QObject *>* flickableData READ flickableData)
- Q_PROPERTY(QmlList<QmlGraphicsItem *>* flickableChildren READ flickableChildren)
+ Q_PROPERTY(QmlListProperty<QObject> flickableData READ flickableData)
+ Q_PROPERTY(QmlListProperty<QmlGraphicsItem> flickableChildren READ flickableChildren)
Q_CLASSINFO("DefaultProperty", "flickableData")
Q_ENUMS(FlickDirection)
@@ -92,8 +92,8 @@ public:
QmlGraphicsFlickable(QmlGraphicsItem *parent=0);
~QmlGraphicsFlickable();
- QmlList<QObject *> *flickableData();
- QmlList<QmlGraphicsItem *> *flickableChildren();
+ QmlListProperty<QObject> flickableData();
+ QmlListProperty<QmlGraphicsItem> flickableChildren();
bool overShoot() const;
void setOverShoot(bool);
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
index 0c98f7b..e58cc0c 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
@@ -110,8 +110,6 @@ public:
qreal velocityX;
qreal velocityY;
QTime pressTime;
- QmlTimeLineEvent fixupXEvent;
- QmlTimeLineEvent fixupYEvent;
qreal deceleration;
qreal maxVelocity;
QTime velocityTime;
@@ -125,6 +123,9 @@ public:
int pressDelay;
int fixupDuration;
+ static void fixupY_callback(void *);
+ static void fixupX_callback(void *);
+
void updateVelocity();
struct Velocity : public QmlTimeLineValue
{
@@ -148,15 +149,7 @@ public:
void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *);
// flickableData property
- void data_removeAt(int);
- int data_count() const;
- void data_append(QObject *);
- void data_insert(int, QObject *);
- QObject *data_at(int) const;
- void data_clear();
-
- friend class QmlGraphicsFlickableVisibleArea;
- QML_DECLARE_LIST_PROXY(QmlGraphicsFlickablePrivate, QObject *, data)
+ static void data_append(QmlListProperty<QObject> *, QObject *);
};
class QmlGraphicsFlickableVisibleArea : public QObject
diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp
index be512fc..f51c203 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp
@@ -64,6 +64,7 @@ public:
/*!
\qmlclass Flipable QmlGraphicsFlipable
+ \since 4.7
\brief The Flipable item provides a surface that can be flipped.
\inherits Item
@@ -97,7 +98,7 @@ public:
NumberAnimation { properties: "angle"; duration: 2000 }
}
- MouseRegion {
+ MouseArea {
// change between default and 'back' states
onClicked: flipable.state = (flipable.state == 'back' ? '' : 'back')
anchors.fill: parent
@@ -149,7 +150,7 @@ void QmlGraphicsFlipable::setFront(QmlGraphicsItem *front)
return;
}
d->front = front;
- fxChildren()->append(d->front);
+ d->front->setParentItem(this);
if (Back == d->current)
d->front->setOpacity(0.);
}
@@ -168,7 +169,7 @@ void QmlGraphicsFlipable::setBack(QmlGraphicsItem *back)
return;
}
d->back = back;
- fxChildren()->append(d->back);
+ d->back->setParentItem(this);
if (Front == d->current)
d->back->setOpacity(0.);
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp b/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp
index d564e86..4d7af54 100644
--- a/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp
@@ -48,6 +48,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass FocusPanel QmlGraphicsFocusPanel
+ \since 4.7
\brief The FocusPanel item explicitly creates a focus panel.
\inherits Item
diff --git a/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp b/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp
index 9930396..bba471a 100644
--- a/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp
@@ -45,6 +45,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass FocusScope QmlGraphicsFocusScope
+ \since 4.7
\brief The FocusScope object explicitly creates a focus scope.
\inherits Item
diff --git a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp
index 497d950..692f7a9 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp
@@ -83,6 +83,7 @@ public:
/*!
\qmlclass GraphicsObjectContainer QmlGraphicsGraphicsObjectContainer
+ \since 4.7
\brief The GraphicsObjectContainer element allows you to add QGraphicsObjects into Fluid UI elements.
While any QObject based class can be exposed to QML, QmlGraphicsItem
diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
index c586452..6e93c52 100644
--- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
@@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass Image QmlGraphicsImage
+ \since 4.7
\brief The Image element allows you to add bitmaps to a scene.
\inherits Item
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
index 22beb12..fce4e36 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
@@ -73,6 +73,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass Transform QGraphicsTransform
+ \since 4.7
\brief The Transform elements provide a way of building advanced transformations on Items.
The Transform elements let you create and control advanced transformations that can be configured
@@ -86,6 +87,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass Scale QGraphicsScale
+ \since 4.7
\brief The Scale object provides a way to scale an Item.
The Scale object gives more control over scaling than using Item's scale property. Specifically,
@@ -124,6 +126,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass Rotation QGraphicsRotation
+ \since 4.7
\brief The Rotation object provides a way to rotate an Item.
The Rotation object gives more control over rotation than using Item's rotation property.
@@ -363,6 +366,7 @@ void QmlGraphicsItemKeyFilter::componentComplete()
/*!
\qmlclass KeyNavigation
+ \since 4.7
\brief The KeyNavigation attached property supports key navigation by arrow keys.
It is common in key-based UIs to use arrow keys to navigate
@@ -568,6 +572,7 @@ void QmlGraphicsKeyNavigationAttached::keyReleased(QKeyEvent *event)
/*!
\qmlclass Keys
+ \since 4.7
\brief The Keys attached property provides key handling to Items.
All visual primitives support key handling via the \e Keys
@@ -892,7 +897,6 @@ void QmlGraphicsKeyNavigationAttached::keyReleased(QKeyEvent *event)
parameter provides information about the event.
*/
-
const QmlGraphicsKeysAttached::SigMap QmlGraphicsKeysAttached::sigMap[] = {
{ Qt::Key_Left, "leftPressed" },
{ Qt::Key_Right, "rightPressed" },
@@ -1079,6 +1083,7 @@ QmlGraphicsKeysAttached *QmlGraphicsKeysAttached::qmlAttachedProperties(QObject
/*!
\class QmlGraphicsItem
+ \since 4.7
\brief The QmlGraphicsItem class provides the most basic of all visual items in QML.
All visual items in Qt Declarative inherit from QmlGraphicsItem. Although QmlGraphicsItem
@@ -1092,6 +1097,7 @@ QmlGraphicsKeysAttached *QmlGraphicsKeysAttached::qmlAttachedProperties(QObject
/*!
\qmlclass Item QmlGraphicsItem
+ \since 4.7
\brief The Item is the most basic of all visual items in QML.
All visual items in Qt Declarative inherit from Item. Although Item
@@ -1420,154 +1426,95 @@ QmlGraphicsAnchors *QmlGraphicsItem::anchors()
return d->anchors();
}
-void QmlGraphicsItemPrivate::data_removeAt(int)
-{
- // ###
-}
-
-int QmlGraphicsItemPrivate::data_count() const
+void QmlGraphicsItemPrivate::data_append(QmlListProperty<QObject> *prop, QObject *o)
{
- // ###
- return 0;
-}
-
-void QmlGraphicsItemPrivate::data_append(QObject *o)
-{
- Q_Q(QmlGraphicsItem);
QmlGraphicsItem *i = qobject_cast<QmlGraphicsItem *>(o);
- if (i)
- q->fxChildren()->append(i);
+ if (i)
+ i->setParentItem(static_cast<QmlGraphicsItem *>(prop->object));
else
- resources_append(o);
-}
-
-void QmlGraphicsItemPrivate::data_insert(int, QObject *)
-{
- // ###
-}
-
-QObject *QmlGraphicsItemPrivate::data_at(int) const
-{
- // ###
- return 0;
+ o->setParent(static_cast<QmlGraphicsItem *>(prop->object));
}
-void QmlGraphicsItemPrivate::data_clear()
+QObject *QmlGraphicsItemPrivate::resources_at(QmlListProperty<QObject> *prop, int index)
{
- // ###
-}
-
-void QmlGraphicsItemPrivate::resources_removeAt(int)
-{
- // ###
-}
-
-int QmlGraphicsItemPrivate::resources_count() const
-{
- Q_Q(const QmlGraphicsItem);
- return q->children().count();
-}
-
-void QmlGraphicsItemPrivate::resources_append(QObject *o)
-{
- Q_Q(QmlGraphicsItem);
- o->setParent(q);
-}
-
-void QmlGraphicsItemPrivate::resources_insert(int, QObject *)
-{
- // ###
-}
-
-QObject *QmlGraphicsItemPrivate::resources_at(int idx) const
-{
- Q_Q(const QmlGraphicsItem);
- QObjectList children = q->children();
- if (idx < children.count())
- return children.at(idx);
+ QObjectList children = prop->object->children();
+ if (index < children.count())
+ return children.at(index);
else
return 0;
}
-void QmlGraphicsItemPrivate::resources_clear()
+void QmlGraphicsItemPrivate::resources_append(QmlListProperty<QObject> *prop, QObject *o)
{
- // ###
+ o->setParent(prop->object);
}
-void QmlGraphicsItemPrivate::children_removeAt(int)
+int QmlGraphicsItemPrivate::resources_count(QmlListProperty<QObject> *prop)
{
- // ###
+ return prop->object->children().count();
}
-int QmlGraphicsItemPrivate::children_count() const
+QmlGraphicsItem *QmlGraphicsItemPrivate::children_at(QmlListProperty<QmlGraphicsItem> *prop, int index)
{
- Q_Q(const QmlGraphicsItem);
- return q->childItems().count();
-}
+ QList<QGraphicsItem *> children = static_cast<QmlGraphicsItem*>(prop->object)->childItems();
-void QmlGraphicsItemPrivate::children_append(QmlGraphicsItem *i)
-{
- Q_Q(QmlGraphicsItem);
- i->setParentItem(q);
-}
-
-void QmlGraphicsItemPrivate::children_insert(int, QmlGraphicsItem *)
-{
- // ###
-}
-
-QmlGraphicsItem *QmlGraphicsItemPrivate::children_at(int idx) const
-{
- Q_Q(const QmlGraphicsItem);
- QList<QGraphicsItem *> children = q->childItems();
- if (idx < children.count())
- return qobject_cast<QmlGraphicsItem *>(children.at(idx));
+ if (index < children.count())
+ return qobject_cast<QmlGraphicsItem *>(children.at(index));
else
return 0;
}
-void QmlGraphicsItemPrivate::children_clear()
+void QmlGraphicsItemPrivate::children_append(QmlListProperty<QmlGraphicsItem> *prop, QmlGraphicsItem *i)
{
- // ###
-}
-
-
-void QmlGraphicsItemPrivate::transform_removeAt(int i)
-{
- if (!transformData)
- return;
- transformData->graphicsTransforms.removeAt(i);
- dirtySceneTransform = 1;
+ if (i)
+ i->setParentItem(static_cast<QmlGraphicsItem*>(prop->object));
}
-int QmlGraphicsItemPrivate::transform_count() const
+int QmlGraphicsItemPrivate::children_count(QmlListProperty<QmlGraphicsItem> *prop)
{
- return transformData ? transformData->graphicsTransforms.size() : 0;
+ return static_cast<QmlGraphicsItem*>(prop->object)->childItems().count();
}
-void QmlGraphicsItemPrivate::transform_append(QGraphicsTransform *item)
+int QmlGraphicsItemPrivate::transform_count(QmlListProperty<QGraphicsTransform> *list)
{
- appendGraphicsTransform(item);
+ QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
+ if (object) {
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
+ return d->transformData ? d->transformData->graphicsTransforms.size() : 0;
+ } else {
+ return 0;
+ }
}
-void QmlGraphicsItemPrivate::transform_insert(int, QGraphicsTransform *)
+void QmlGraphicsItemPrivate::transform_append(QmlListProperty<QGraphicsTransform> *list, QGraphicsTransform *item)
{
- // ###
+ QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
+ if (object)
+ QGraphicsItemPrivate::get(object)->appendGraphicsTransform(item);
}
-QGraphicsTransform *QmlGraphicsItemPrivate::transform_at(int idx) const
+QGraphicsTransform *QmlGraphicsItemPrivate::transform_at(QmlListProperty<QGraphicsTransform> *list, int idx)
{
- if (!transformData)
+ QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
+ if (object) {
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
+ if (!d->transformData)
+ return 0;
+ return d->transformData->graphicsTransforms.at(idx);
+ } else {
return 0;
- return transformData->graphicsTransforms.at(idx);
+ }
}
-void QmlGraphicsItemPrivate::transform_clear()
+void QmlGraphicsItemPrivate::transform_clear(QmlListProperty<QGraphicsTransform> *list)
{
- if (!transformData)
- return;
- Q_Q(QmlGraphicsItem);
- q->setTransformations(QList<QGraphicsTransform *>());
+ QGraphicsObject *object = qobject_cast<QGraphicsObject *>(list->object);
+ if (object) {
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
+ if (!d->transformData)
+ return;
+ object->setTransformations(QList<QGraphicsTransform *>());
+ }
}
/*!
@@ -1610,10 +1557,9 @@ void QmlGraphicsItemPrivate::transform_clear()
*/
/*! \internal */
-QmlList<QObject *> *QmlGraphicsItem::data()
+QmlListProperty<QObject> QmlGraphicsItem::data()
{
- Q_D(QmlGraphicsItem);
- return &d->data;
+ return QmlListProperty<QObject>(this, 0, QmlGraphicsItemPrivate::data_append);
}
/*!
@@ -2215,17 +2161,19 @@ void QmlGraphicsItem::focusChanged(bool flag)
}
/*! \internal */
-QmlList<QmlGraphicsItem *> *QmlGraphicsItem::fxChildren()
+QmlListProperty<QmlGraphicsItem> QmlGraphicsItem::fxChildren()
{
- Q_D(QmlGraphicsItem);
- return &(d->children);
+ return QmlListProperty<QmlGraphicsItem>(this, 0, QmlGraphicsItemPrivate::children_append,
+ QmlGraphicsItemPrivate::children_count,
+ QmlGraphicsItemPrivate::children_at);
}
/*! \internal */
-QmlList<QObject *> *QmlGraphicsItem::resources()
+QmlListProperty<QObject> QmlGraphicsItem::resources()
{
- Q_D(QmlGraphicsItem);
- return &(d->resources);
+ return QmlListProperty<QObject>(this, 0, QmlGraphicsItemPrivate::resources_append,
+ QmlGraphicsItemPrivate::resources_count,
+ QmlGraphicsItemPrivate::resources_at);
}
/*!
@@ -2250,7 +2198,7 @@ QmlList<QObject *> *QmlGraphicsItem::resources()
\internal
*/
/*! \internal */
-QmlList<QmlState *>* QmlGraphicsItem::states()
+QmlListProperty<QmlState> QmlGraphicsItem::states()
{
Q_D(QmlGraphicsItem);
return d->states()->statesProperty();
@@ -2279,7 +2227,7 @@ QmlList<QmlState *>* QmlGraphicsItem::states()
*/
/*! \internal */
-QmlList<QmlTransition *>* QmlGraphicsItem::transitions()
+QmlListProperty<QmlTransition> QmlGraphicsItem::transitions()
{
Q_D(QmlGraphicsItem);
return d->states()->transitionsProperty();
@@ -2387,10 +2335,11 @@ void QmlGraphicsItem::setState(const QString &state)
*/
/*! \internal */
-QmlList<QGraphicsTransform *>* QmlGraphicsItem::transform()
+QmlListProperty<QGraphicsTransform> QmlGraphicsItem::transform()
{
Q_D(QmlGraphicsItem);
- return &(d->transform);
+ return QmlListProperty<QGraphicsTransform>(this, 0, d->transform_append, d->transform_count,
+ d->transform_at, d->transform_clear);
}
/*!
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.h b/src/declarative/graphicsitems/qmlgraphicsitem.h
index e1cf035..891fc88 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.h
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.h
@@ -70,11 +70,11 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsItem : public QGraphicsObject, public QmlP
Q_INTERFACES(QmlParserStatus)
Q_PROPERTY(QmlGraphicsItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL)
- Q_PROPERTY(QmlList<QObject *> *data READ data DESIGNABLE false)
- Q_PROPERTY(QmlList<QmlGraphicsItem *>* children READ fxChildren DESIGNABLE false NOTIFY childrenChanged)
- Q_PROPERTY(QmlList<QObject *>* resources READ resources DESIGNABLE false)
- Q_PROPERTY(QmlList<QmlState *>* states READ states DESIGNABLE false)
- Q_PROPERTY(QmlList<QmlTransition *>* transitions READ transitions DESIGNABLE false)
+ Q_PROPERTY(QmlListProperty<QObject> data READ data DESIGNABLE false)
+ Q_PROPERTY(QmlListProperty<QmlGraphicsItem> children READ fxChildren DESIGNABLE false NOTIFY childrenChanged)
+ Q_PROPERTY(QmlListProperty<QObject> resources READ resources DESIGNABLE false)
+ Q_PROPERTY(QmlListProperty<QmlState> states READ states DESIGNABLE false)
+ Q_PROPERTY(QmlListProperty<QmlTransition> transitions READ transitions DESIGNABLE false)
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL)
Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL)
@@ -91,7 +91,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsItem : public QGraphicsObject, public QmlP
Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged) // ### move to QGI/QGO, NOTIFY
Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
Q_PROPERTY(bool wantsFocus READ wantsFocus NOTIFY wantsFocusChanged)
- Q_PROPERTY(QmlList<QGraphicsTransform *>* transform READ transform DESIGNABLE false FINAL)
+ Q_PROPERTY(QmlListProperty<QGraphicsTransform> transform READ transform DESIGNABLE false FINAL)
Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged)
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect)
@@ -112,9 +112,9 @@ public:
void setParentItem(QmlGraphicsItem *parent);
void setParent(QmlGraphicsItem *parent) { setParentItem(parent); }
- QmlList<QObject *> *data();
- QmlList<QmlGraphicsItem *> *fxChildren();
- QmlList<QObject *> *resources();
+ QmlListProperty<QObject> data();
+ QmlListProperty<QmlGraphicsItem> fxChildren();
+ QmlListProperty<QObject> resources();
QmlGraphicsAnchors *anchors();
QRectF childrenRect();
@@ -122,8 +122,8 @@ public:
bool clip() const;
void setClip(bool);
- QmlList<QmlState *>* states();
- QmlList<QmlTransition *>* transitions();
+ QmlListProperty<QmlState> states();
+ QmlListProperty<QmlTransition> transitions();
QString state() const;
void setState(const QString &);
@@ -131,7 +131,7 @@ public:
qreal baselineOffset() const;
void setBaselineOffset(qreal);
- QmlList<QGraphicsTransform *> *transform();
+ QmlListProperty<QGraphicsTransform> transform();
qreal width() const;
void setWidth(qreal);
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h
index 7662a3b..4860b83 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h
@@ -137,40 +137,23 @@ public:
QString _id;
// data property
- void data_removeAt(int);
- int data_count() const;
- void data_append(QObject *);
- void data_insert(int, QObject *);
- QObject *data_at(int) const;
- void data_clear();
- QML_DECLARE_LIST_PROXY(QmlGraphicsItemPrivate, QObject *, data)
+ static void data_append(QmlListProperty<QObject> *, QObject *);
// resources property
- void resources_removeAt(int);
- int resources_count() const;
- void resources_append(QObject *);
- void resources_insert(int, QObject *);
- QObject *resources_at(int) const;
- void resources_clear();
- QML_DECLARE_LIST_PROXY(QmlGraphicsItemPrivate, QObject *, resources)
+ static QObject *resources_at(QmlListProperty<QObject> *, int);
+ static void resources_append(QmlListProperty<QObject> *, QObject *);
+ static int resources_count(QmlListProperty<QObject> *);
// children property
- void children_removeAt(int);
- int children_count() const;
- void children_append(QmlGraphicsItem *);
- void children_insert(int, QmlGraphicsItem *);
- QmlGraphicsItem *children_at(int) const;
- void children_clear();
- QML_DECLARE_LIST_PROXY(QmlGraphicsItemPrivate, QmlGraphicsItem *, children)
+ static QmlGraphicsItem *children_at(QmlListProperty<QmlGraphicsItem> *, int);
+ static void children_append(QmlListProperty<QmlGraphicsItem> *, QmlGraphicsItem *);
+ static int children_count(QmlListProperty<QmlGraphicsItem> *);
// transform property
- void transform_removeAt(int);
- int transform_count() const;
- void transform_append(QGraphicsTransform *);
- void transform_insert(int, QGraphicsTransform *);
- QGraphicsTransform *transform_at(int) const;
- void transform_clear();
- QML_DECLARE_LIST_PROXY(QmlGraphicsItemPrivate, QGraphicsTransform *, transform)
+ static int transform_count(QmlListProperty<QGraphicsTransform> *list);
+ static void transform_append(QmlListProperty<QGraphicsTransform> *list, QGraphicsTransform *);
+ static QGraphicsTransform *transform_at(QmlListProperty<QGraphicsTransform> *list, int);
+ static void transform_clear(QmlListProperty<QGraphicsTransform> *list);
QmlGraphicsAnchors *anchors() {
if (!_anchors) {
@@ -381,7 +364,7 @@ class QmlGraphicsKeysAttached : public QObject, public QmlGraphicsItemKeyFilter
Q_DECLARE_PRIVATE(QmlGraphicsKeysAttached)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(QList<QmlGraphicsItem *> *forwardTo READ forwardTo)
+ Q_PROPERTY(QmlListProperty<QmlGraphicsItem> forwardTo READ forwardTo)
public:
QmlGraphicsKeysAttached(QObject *parent=0);
@@ -396,9 +379,9 @@ public:
}
}
- QList<QmlGraphicsItem *> *forwardTo() {
+ QmlListProperty<QmlGraphicsItem> forwardTo() {
Q_D(QmlGraphicsKeysAttached);
- return &d->targets;
+ return QmlListProperty<QmlGraphicsItem>(this, d->targets);
}
virtual void componentComplete();
diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp
index 66d62f0..9263f49 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp
@@ -51,7 +51,7 @@
#include "qmlgraphicsanimatedimage_p.h"
#include "qmlgraphicsborderimage_p.h"
#include "qmlgraphicspositioners_p.h"
-#include "qmlgraphicsmouseregion_p.h"
+#include "qmlgraphicsmousearea_p.h"
#include "qmlgraphicsflickable_p.h"
#include "qmlgraphicsflickable_p_p.h"
#include "qmlgraphicsflipable_p.h"
@@ -64,7 +64,7 @@
#include "qmlgraphicslayoutitem_p.h"
#include "qmlgraphicslistview_p.h"
#include "qmlgraphicsloader_p.h"
-#include "qmlgraphicsmouseregion_p.h"
+#include "qmlgraphicsmousearea_p.h"
#include "qmlgraphicsparticles_p.h"
#include "qmlgraphicspath_p.h"
#include "qmlgraphicspathview_p.h"
@@ -112,7 +112,8 @@ void QmlGraphicsItemModule::defineModule()
QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QmlGraphicsLayoutItem);
QML_REGISTER_TYPE(Qt,4,6,ListView,QmlGraphicsListView);
QML_REGISTER_TYPE(Qt,4,6,Loader,QmlGraphicsLoader);
- QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QmlGraphicsMouseRegion);
+ QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QmlGraphicsMouseArea);
+ QML_REGISTER_TYPE(Qt,4,6,MouseArea,QmlGraphicsMouseArea);
QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect);
QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QmlGraphicsParticleMotion);
QML_REGISTER_TYPE(Qt,4,6,ParticleMotionGravity,QmlGraphicsParticleMotionGravity);
diff --git a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp b/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp
index 961065e..b55beda 100644
--- a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp
@@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass LayoutItem QmlGraphicsLayoutItem
+ \since 4.7
\brief The LayoutItem element allows you to place your Fluid UI elements inside a classical Qt layout.
LayoutItem is a variant of Item with a couple of additional properties. These properties provide the size hints
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index c646d49..28b21c9 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -1200,7 +1200,7 @@ void QmlGraphicsListViewPrivate::flickX(qreal velocity)
}
timeline.reset(_moveX);
timeline.accel(_moveX, v, accel, maxDistance + overshootDist);
- timeline.execute(fixupXEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this));
flicked = true;
emit q->flickingChanged();
emit q->flickStarted();
@@ -1226,7 +1226,7 @@ void QmlGraphicsListViewPrivate::flickX(qreal velocity)
}
timeline.reset(_moveX);
timeline.accelDistance(_moveX, v, -dist + (v < 0 ? -overshootDist : overshootDist));
- timeline.execute(fixupXEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this));
}
} else {
correctFlick = false;
@@ -1298,7 +1298,7 @@ void QmlGraphicsListViewPrivate::flickY(qreal velocity)
}
timeline.reset(_moveY);
timeline.accel(_moveY, v, accel, maxDistance + overshootDist);
- timeline.execute(fixupYEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this));
flicked = true;
emit q->flickingChanged();
emit q->flickStarted();
@@ -1324,7 +1324,7 @@ void QmlGraphicsListViewPrivate::flickY(qreal velocity)
}
timeline.reset(_moveY);
timeline.accelDistance(_moveY, v, -dist + (v < 0 ? -overshootDist : overshootDist));
- timeline.execute(fixupYEvent);
+ timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this));
}
} else {
correctFlick = false;
@@ -1337,6 +1337,7 @@ void QmlGraphicsListViewPrivate::flickY(qreal velocity)
/*!
\qmlclass ListView QmlGraphicsListView
+ \since 4.7
\inherits Flickable
\brief The ListView item provides a list view of items provided by a model.
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp
index 159ddc3..b9780f2 100644
--- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp
@@ -110,6 +110,7 @@ void QmlGraphicsLoaderPrivate::initResize()
/*!
\qmlclass Loader QmlGraphicsLoader
+ \since 4.7
\inherits Item
\brief The Loader item allows dynamically loading an Item-based
@@ -124,7 +125,7 @@ void QmlGraphicsLoaderPrivate::initResize()
\code
Loader { id: pageLoader }
Rectangle {
- MouseRegion { anchors.fill: parent; onClicked: pageLoader.source = "Page1.qml" }
+ MouseArea { anchors.fill: parent; onClicked: pageLoader.source = "Page1.qml" }
}
\endcode
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmousearea.cpp
index 3470d37..07354f4 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsmousearea.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include "qmlgraphicsmouseregion_p.h"
-#include "qmlgraphicsmouseregion_p_p.h"
+#include "qmlgraphicsmousearea_p.h"
+#include "qmlgraphicsmousearea_p_p.h"
#include "qmlgraphicsevents_p_p.h"
@@ -136,7 +136,7 @@ void QmlGraphicsDrag::setYmax(qreal m)
emit maximumYChanged();
}
-QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
+QmlGraphicsMouseAreaPrivate::~QmlGraphicsMouseAreaPrivate()
{
delete drag;
}
@@ -144,16 +144,17 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
/*!
\qmlclass MouseRegion QmlGraphicsMouseRegion
- \brief The MouseRegion item enables simple mouse handling.
+ \since 4.7
+ \brief The MouseArea item enables simple mouse handling.
\inherits Item
- A MouseRegion is typically used in conjunction with a visible item,
- where the MouseRegion effectively 'proxies' mouse handling for that
- item. For example, we can put a MouseRegion in a Rectangle that changes
+ A MouseArea is typically used in conjunction with a visible item,
+ where the MouseArea effectively 'proxies' mouse handling for that
+ item. For example, we can put a MouseArea in a Rectangle that changes
the Rectangle color to red when clicked:
\snippet doc/src/snippets/declarative/mouseregion.qml 0
- Many MouseRegion signals pass a \l {MouseEvent}{mouse} parameter that contains
+ Many MouseArea signals pass a \l {MouseEvent}{mouse} parameter that contains
additional information about the mouse event, such as the position, button,
and any key modifiers.
@@ -163,13 +164,13 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
For basic key handling, see the \l {Keys}{Keys attached property}.
- MouseRegion is an invisible item: it is never painted.
+ MouseArea is an invisible item: it is never painted.
\sa MouseEvent
*/
/*!
- \qmlsignal MouseRegion::onEntered()
+ \qmlsignal MouseArea::onEntered()
This handler is called when the mouse enters the mouse region.
@@ -181,7 +182,7 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
*/
/*!
- \qmlsignal MouseRegion::onExited()
+ \qmlsignal MouseArea::onExited()
This handler is called when the mouse exists the mouse region.
@@ -193,7 +194,7 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
*/
/*!
- \qmlsignal MouseRegion::onPositionChanged(MouseEvent mouse)
+ \qmlsignal MouseArea::onPositionChanged(MouseEvent mouse)
This handler is called when the mouse position changes.
@@ -208,10 +209,10 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
*/
/*!
- \qmlsignal MouseRegion::onClicked(mouse)
+ \qmlsignal MouseArea::onClicked(mouse)
This handler is called when there is a click. A click is defined as a press followed by a release,
- both inside the MouseRegion (pressing, moving outside the MouseRegion, and then moving back inside and
+ both inside the MouseArea (pressing, moving outside the MouseArea, and then moving back inside and
releasing is also considered a click).
The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
@@ -221,21 +222,21 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
*/
/*!
- \qmlsignal MouseRegion::onPressed(mouse)
+ \qmlsignal MouseArea::onPressed(mouse)
This handler is called when there is a press.
The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
position and which button was pressed.
- The \e accepted property of the MouseEvent parameter determines whether this MouseRegion
+ The \e accepted property of the MouseEvent parameter determines whether this MouseArea
will handle the press and all future mouse events until release. The default is to accept
- the event and not allow other MouseRegions beneath this one to handle the event. If \e accepted
- is set to false, no further events will be sent to this MouseRegion until the button is next
+ the event and not allow other MouseArea beneath this one to handle the event. If \e accepted
+ is set to false, no further events will be sent to this MouseArea until the button is next
pressed.
*/
/*!
- \qmlsignal MouseRegion::onReleased(mouse)
+ \qmlsignal MouseArea::onReleased(mouse)
This handler is called when there is a release.
The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
@@ -245,7 +246,7 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
*/
/*!
- \qmlsignal MouseRegion::onPressAndHold(mouse)
+ \qmlsignal MouseArea::onPressAndHold(mouse)
This handler is called when there is a long press (currently 800ms).
The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
@@ -255,7 +256,7 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
*/
/*!
- \qmlsignal MouseRegion::onDoubleClicked(mouse)
+ \qmlsignal MouseArea::onDoubleClicked(mouse)
This handler is called when there is a double-click (a press followed by a release followed by a press).
The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
@@ -266,30 +267,30 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
/*!
\internal
- \class QmlGraphicsMouseRegion
- \brief The QmlGraphicsMouseRegion class provides a simple mouse handling abstraction for use within Qml.
+ \class QmlGraphicsMouseArea
+ \brief The QmlGraphicsMouseArea class provides a simple mouse handling abstraction for use within Qml.
\ingroup group_coreitems
- All QmlGraphicsItem derived classes can do mouse handling but the QmlGraphicsMouseRegion class exposes mouse
+ All QmlGraphicsItem derived classes can do mouse handling but the QmlGraphicsMouseArea class exposes mouse
handling data as properties and tracks flicking and dragging of the mouse.
- A QmlGraphicsMouseRegion object can be instantiated in Qml using the tag \l MouseRegion.
+ A QmlGraphicsMouseArea object can be instantiated in Qml using the tag \l MouseArea.
*/
-QmlGraphicsMouseRegion::QmlGraphicsMouseRegion(QmlGraphicsItem *parent)
- : QmlGraphicsItem(*(new QmlGraphicsMouseRegionPrivate), parent)
+QmlGraphicsMouseArea::QmlGraphicsMouseArea(QmlGraphicsItem *parent)
+ : QmlGraphicsItem(*(new QmlGraphicsMouseAreaPrivate), parent)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
d->init();
}
-QmlGraphicsMouseRegion::~QmlGraphicsMouseRegion()
+QmlGraphicsMouseArea::~QmlGraphicsMouseArea()
{
}
/*!
- \qmlproperty real MouseRegion::mouseX
- \qmlproperty real MouseRegion::mouseY
+ \qmlproperty real MouseArea::mouseX
+ \qmlproperty real MouseArea::mouseY
These properties hold the coordinates of the mouse.
If the hoverEnabled property is false then these properties will only be valid
@@ -298,44 +299,44 @@ QmlGraphicsMouseRegion::~QmlGraphicsMouseRegion()
If hoverEnabled is true then these properties will be valid:
\list
- \i when no button is pressed, but the mouse is within the MouseRegion (containsMouse is true).
+ \i when no button is pressed, but the mouse is within the MouseArea (containsMouse is true).
\i if a button is pressed and held, even if it has since moved out of the region.
\endlist
- The coordinates are relative to the MouseRegion.
+ The coordinates are relative to the MouseArea.
*/
-qreal QmlGraphicsMouseRegion::mouseX() const
+qreal QmlGraphicsMouseArea::mouseX() const
{
- Q_D(const QmlGraphicsMouseRegion);
+ Q_D(const QmlGraphicsMouseArea);
return d->lastPos.x();
}
-qreal QmlGraphicsMouseRegion::mouseY() const
+qreal QmlGraphicsMouseArea::mouseY() const
{
- Q_D(const QmlGraphicsMouseRegion);
+ Q_D(const QmlGraphicsMouseArea);
return d->lastPos.y();
}
/*!
- \qmlproperty bool MouseRegion::enabled
+ \qmlproperty bool MouseArea::enabled
This property holds whether the item accepts mouse events.
*/
-bool QmlGraphicsMouseRegion::isEnabled() const
+bool QmlGraphicsMouseArea::isEnabled() const
{
- Q_D(const QmlGraphicsMouseRegion);
+ Q_D(const QmlGraphicsMouseArea);
return d->absorb;
}
-void QmlGraphicsMouseRegion::setEnabled(bool a)
+void QmlGraphicsMouseArea::setEnabled(bool a)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
if (a != d->absorb) {
d->absorb = a;
emit enabledChanged();
}
}
/*!
- \qmlproperty MouseButtons MouseRegion::pressedButtons
+ \qmlproperty MouseButtons MouseArea::pressedButtons
This property holds the mouse buttons currently pressed.
It contains a bitwise combination of:
@@ -351,7 +352,7 @@ void QmlGraphicsMouseRegion::setEnabled(bool a)
text: mr.pressedButtons & Qt.RightButton ? "right" : ""
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
- MouseRegion {
+ MouseArea {
id: mr
acceptedButtons: Qt.LeftButton | Qt.RightButton
anchors.fill: parent
@@ -361,15 +362,15 @@ void QmlGraphicsMouseRegion::setEnabled(bool a)
\sa acceptedButtons
*/
-Qt::MouseButtons QmlGraphicsMouseRegion::pressedButtons() const
+Qt::MouseButtons QmlGraphicsMouseArea::pressedButtons() const
{
- Q_D(const QmlGraphicsMouseRegion);
+ Q_D(const QmlGraphicsMouseArea);
return d->lastButtons;
}
-void QmlGraphicsMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
+void QmlGraphicsMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
d->moved = false;
if (!d->absorb)
QmlGraphicsItem::mousePressEvent(event);
@@ -392,9 +393,9 @@ void QmlGraphicsMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
}
-void QmlGraphicsMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+void QmlGraphicsMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
if (!d->absorb) {
QmlGraphicsItem::mouseMoveEvent(event);
return;
@@ -462,9 +463,9 @@ void QmlGraphicsMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
-void QmlGraphicsMouseRegion::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+void QmlGraphicsMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
if (!d->absorb) {
QmlGraphicsItem::mouseReleaseEvent(event);
} else {
@@ -477,9 +478,9 @@ void QmlGraphicsMouseRegion::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
}
-void QmlGraphicsMouseRegion::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+void QmlGraphicsMouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
if (!d->absorb) {
QmlGraphicsItem::mouseDoubleClickEvent(event);
} else {
@@ -493,18 +494,18 @@ void QmlGraphicsMouseRegion::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *eve
}
}
-void QmlGraphicsMouseRegion::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
+void QmlGraphicsMouseArea::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
if (!d->absorb)
QmlGraphicsItem::hoverEnterEvent(event);
else
setHovered(true);
}
-void QmlGraphicsMouseRegion::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
+void QmlGraphicsMouseArea::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
if (!d->absorb) {
QmlGraphicsItem::hoverEnterEvent(event);
} else {
@@ -514,20 +515,20 @@ void QmlGraphicsMouseRegion::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
}
}
-void QmlGraphicsMouseRegion::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+void QmlGraphicsMouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
if (!d->absorb)
QmlGraphicsItem::hoverLeaveEvent(event);
else
setHovered(false);
}
-bool QmlGraphicsMouseRegion::sceneEvent(QEvent *event)
+bool QmlGraphicsMouseArea::sceneEvent(QEvent *event)
{
bool rv = QmlGraphicsItem::sceneEvent(event);
if (event->type() == QEvent::UngrabMouse) {
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
if (d->pressed) {
// if our mouse grab has been removed (probably by Flickable), fix our
// state
@@ -540,9 +541,9 @@ bool QmlGraphicsMouseRegion::sceneEvent(QEvent *event)
return rv;
}
-void QmlGraphicsMouseRegion::timerEvent(QTimerEvent *event)
+void QmlGraphicsMouseArea::timerEvent(QTimerEvent *event)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
if (event->timerId() == d->pressAndHoldTimer.timerId()) {
d->pressAndHoldTimer.stop();
if (d->pressed && d->dragged == false && d->hovered == true) {
@@ -554,7 +555,7 @@ void QmlGraphicsMouseRegion::timerEvent(QTimerEvent *event)
}
/*!
- \qmlproperty bool MouseRegion::hoverEnabled
+ \qmlproperty bool MouseArea::hoverEnabled
This property holds whether hover events are handled.
By default, mouse events are only handled in response to a button event, or when a button is
@@ -565,31 +566,31 @@ void QmlGraphicsMouseRegion::timerEvent(QTimerEvent *event)
*/
/*!
- \qmlproperty bool MouseRegion::containsMouse
+ \qmlproperty bool MouseArea::containsMouse
This property holds whether the mouse is currently inside the mouse region.
\warning This property is not updated if the region moves under the mouse: \e containsMouse will not change.
In addition, if hoverEnabled is false, containsMouse will only be valid when the mouse is pressed.
*/
-bool QmlGraphicsMouseRegion::hovered() const
+bool QmlGraphicsMouseArea::hovered() const
{
- Q_D(const QmlGraphicsMouseRegion);
+ Q_D(const QmlGraphicsMouseArea);
return d->hovered;
}
/*!
- \qmlproperty bool MouseRegion::pressed
+ \qmlproperty bool MouseArea::pressed
This property holds whether the mouse region is currently pressed.
*/
-bool QmlGraphicsMouseRegion::pressed() const
+bool QmlGraphicsMouseArea::pressed() const
{
- Q_D(const QmlGraphicsMouseRegion);
+ Q_D(const QmlGraphicsMouseArea);
return d->pressed;
}
-void QmlGraphicsMouseRegion::setHovered(bool h)
+void QmlGraphicsMouseArea::setHovered(bool h)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
if (d->hovered != h) {
d->hovered = h;
emit hoveredChanged();
@@ -598,7 +599,7 @@ void QmlGraphicsMouseRegion::setHovered(bool h)
}
/*!
- \qmlproperty Qt::MouseButtons MouseRegion::acceptedButtons
+ \qmlproperty Qt::MouseButtons MouseArea::acceptedButtons
This property holds the mouse buttons that the mouse region reacts to.
The available buttons are:
@@ -612,17 +613,17 @@ void QmlGraphicsMouseRegion::setHovered(bool h)
"|" (or) operator:
\code
- MouseRegion { acceptedButtons: Qt.LeftButton | Qt.RightButton }
+ MouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton }
\endcode
The default is to accept the Left button.
*/
-Qt::MouseButtons QmlGraphicsMouseRegion::acceptedButtons() const
+Qt::MouseButtons QmlGraphicsMouseArea::acceptedButtons() const
{
return acceptedMouseButtons();
}
-void QmlGraphicsMouseRegion::setAcceptedButtons(Qt::MouseButtons buttons)
+void QmlGraphicsMouseArea::setAcceptedButtons(Qt::MouseButtons buttons)
{
if (buttons != acceptedMouseButtons()) {
setAcceptedMouseButtons(buttons);
@@ -630,9 +631,9 @@ void QmlGraphicsMouseRegion::setAcceptedButtons(Qt::MouseButtons buttons)
}
}
-bool QmlGraphicsMouseRegion::setPressed(bool p)
+bool QmlGraphicsMouseArea::setPressed(bool p)
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
bool isclick = d->pressed == true && p == false && d->dragged == false && d->hovered == true;
if (d->pressed != p) {
@@ -653,21 +654,21 @@ bool QmlGraphicsMouseRegion::setPressed(bool p)
return false;
}
-QmlGraphicsDrag *QmlGraphicsMouseRegion::drag()
+QmlGraphicsDrag *QmlGraphicsMouseArea::drag()
{
- Q_D(QmlGraphicsMouseRegion);
+ Q_D(QmlGraphicsMouseArea);
if (!d->drag)
d->drag = new QmlGraphicsDrag;
return d->drag;
}
/*!
- \qmlproperty Item MouseRegion::drag.target
- \qmlproperty Axis MouseRegion::drag.axis
- \qmlproperty real MouseRegion::drag.minimumX
- \qmlproperty real MouseRegion::drag.maximumX
- \qmlproperty real MouseRegion::drag.minimumY
- \qmlproperty real MouseRegion::drag.maximumY
+ \qmlproperty Item MouseArea::drag.target
+ \qmlproperty Axis MouseArea::drag.axis
+ \qmlproperty real MouseArea::drag.minimumX
+ \qmlproperty real MouseArea::drag.maximumX
+ \qmlproperty real MouseArea::drag.minimumY
+ \qmlproperty real MouseArea::drag.maximumY
drag provides a convenient way to make an item draggable.
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h b/src/declarative/graphicsitems/qmlgraphicsmousearea_p.h
index cccf90c..2e2f8c9 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsmousearea_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QMLGRAPHICSMOUSEREGION_H
-#define QMLGRAPHICSMOUSEREGION_H
+#ifndef QMLGRAPHICSMOUSEAREA_H
+#define QMLGRAPHICSMOUSEAREA_H
#include "qmlgraphicsitem.h"
@@ -102,8 +102,8 @@ private:
};
class QmlGraphicsMouseEvent;
-class QmlGraphicsMouseRegionPrivate;
-class Q_DECLARATIVE_EXPORT QmlGraphicsMouseRegion : public QmlGraphicsItem
+class QmlGraphicsMouseAreaPrivate;
+class Q_DECLARATIVE_EXPORT QmlGraphicsMouseArea : public QmlGraphicsItem
{
Q_OBJECT
@@ -118,8 +118,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsMouseRegion : public QmlGraphicsItem
Q_PROPERTY(QmlGraphicsDrag *drag READ drag CONSTANT) //### add flicking to QmlGraphicsDrag or add a QmlGraphicsFlick ???
public:
- QmlGraphicsMouseRegion(QmlGraphicsItem *parent=0);
- ~QmlGraphicsMouseRegion();
+ QmlGraphicsMouseArea(QmlGraphicsItem *parent=0);
+ ~QmlGraphicsMouseArea();
qreal mouseX() const;
qreal mouseY() const;
@@ -171,15 +171,15 @@ private:
void handleRelease();
private:
- Q_DISABLE_COPY(QmlGraphicsMouseRegion)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsMouseRegion)
+ Q_DISABLE_COPY(QmlGraphicsMouseArea)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsMouseArea)
};
QT_END_NAMESPACE
QML_DECLARE_TYPE(QmlGraphicsDrag)
-QML_DECLARE_TYPE(QmlGraphicsMouseRegion)
+QML_DECLARE_TYPE(QmlGraphicsMouseArea)
QT_END_HEADER
-#endif // QMLGRAPHICSMOUSEREGION_H
+#endif // QMLGRAPHICSMOUSEAREA_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p_p.h b/src/declarative/graphicsitems/qmlgraphicsmousearea_p_p.h
index be27176..fadb430 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsmousearea_p_p.h
@@ -61,21 +61,21 @@
QT_BEGIN_NAMESPACE
-class QmlGraphicsMouseRegionPrivate : public QmlGraphicsItemPrivate
+class QmlGraphicsMouseAreaPrivate : public QmlGraphicsItemPrivate
{
- Q_DECLARE_PUBLIC(QmlGraphicsMouseRegion)
+ Q_DECLARE_PUBLIC(QmlGraphicsMouseArea)
public:
- QmlGraphicsMouseRegionPrivate()
+ QmlGraphicsMouseAreaPrivate()
: absorb(true), hovered(false), pressed(false), longPress(false), drag(0)
{
}
- ~QmlGraphicsMouseRegionPrivate();
+ ~QmlGraphicsMouseAreaPrivate();
void init()
{
- Q_Q(QmlGraphicsMouseRegion);
+ Q_Q(QmlGraphicsMouseArea);
q->setAcceptedMouseButtons(Qt::LeftButton);
}
@@ -87,7 +87,7 @@ public:
}
bool isConnected(const char *signal) {
- Q_Q(QmlGraphicsMouseRegion);
+ Q_Q(QmlGraphicsMouseArea);
int idx = QObjectPrivate::get(q)->signalIndex(signal);
return QObjectPrivate::get(q)->isSignalConnected(idx);
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
index 08fce74..14c7c71 100644
--- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
@@ -155,6 +155,7 @@ void QmlGraphicsParticleMotion::destroy(QmlGraphicsParticle &particle)
/*!
\qmlclass ParticleMotionLinear
+ \since 4.7
\brief The ParticleMotionLinear object moves particles linearly.
\sa Particles
@@ -175,6 +176,7 @@ void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interv
/*!
\qmlclass ParticleMotionGravity
+ \since 4.7
\brief The ParticleMotionGravity object moves particles towards a point.
\sa Particles
@@ -230,6 +232,7 @@ void QmlGraphicsParticleMotionGravity::advance(QmlGraphicsParticle &p, int inter
/*!
\qmlclass ParticleMotionWander
+ \since 4.7
\brief The ParticleMotionWander object moves particles in a somewhat random fashion.
The particles will continue roughly in the original direction, however will randomly
@@ -555,19 +558,25 @@ void QmlGraphicsParticlesPrivate::updateOpacity(QmlGraphicsParticle &p, int age)
/*!
\qmlclass Particles
+ \since 4.7
\brief The Particles object generates and moves particles.
\inherits Item
- This element provides preliminary support for particles in QML, and may be heavily changed or removed in later versions.
+ This element provides preliminary support for particles in QML,
+ and may be heavily changed or removed in later versions.
- The particles created by this object cannot be dealt with directly, they can only be controlled through the parameters of the Particles object. The particles are all the same pixmap, specified by the user.
+ The particles created by this object cannot be dealt with
+ directly, they can only be controlled through the parameters of
+ the Particles object. The particles are all the same pixmap,
+ specified by the user.
- The particles are painted relative to the parent of the Particles object. Moving the
- Particles object will not move the particles already emitted.
+ The particles are painted relative to the parent of the Particles
+ object. Moving the Particles object will not move the particles
+ already emitted.
- The below example creates two differently behaving particle sources.
- The top one has particles falling from the top like snow,
- the lower one has particles expelled up like a fountain.
+ The below example creates two differently behaving particle
+ sources. The top one has particles falling from the top like
+ snow, the lower one has particles expelled up like a fountain.
\qml
Rectangle {
diff --git a/src/declarative/graphicsitems/qmlgraphicspath.cpp b/src/declarative/graphicsitems/qmlgraphicspath.cpp
index 7916bd3..0da246f 100644
--- a/src/declarative/graphicsitems/qmlgraphicspath.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspath.cpp
@@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass PathElement QmlGraphicsPathElement
+ \since 4.7
\brief PathElement is the base path type.
This type is the base for all path types. It cannot
@@ -68,6 +69,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass Path QmlGraphicsPath
+ \since 4.7
\brief A Path object defines a path for use by \l PathView.
A Path is composed of one or more path segments - PathLine, PathQuad,
@@ -155,10 +157,10 @@ bool QmlGraphicsPath::isClosed() const
\snippet doc/src/snippets/declarative/pathview/pathattributes.qml 2
*/
-QList<QmlGraphicsPathElement *>* QmlGraphicsPath::pathElements()
+QmlListProperty<QmlGraphicsPathElement> QmlGraphicsPath::pathElements()
{
Q_D(QmlGraphicsPath);
- return &(d->_pathElements);
+ return QmlListProperty<QmlGraphicsPathElement>(this, d->_pathElements);
}
void QmlGraphicsPath::interpolate(int idx, const QString &name, qreal value)
@@ -468,6 +470,7 @@ void QmlGraphicsCurve::setY(qreal y)
/*!
\qmlclass PathAttribute QmlGraphicsPathAttribute
+ \since 4.7
\brief The PathAttribute allows setting an attribute at a given position in a Path.
The PathAttribute object allows attibutes consisting of a name and
@@ -547,6 +550,7 @@ void QmlGraphicsPathAttribute::setValue(qreal value)
/*!
\qmlclass PathLine QmlGraphicsPathLine
+ \since 4.7
\brief The PathLine defines a straight line.
The example below creates a path consisting of a straight line from
@@ -587,6 +591,7 @@ void QmlGraphicsPathLine::addToPath(QPainterPath &path)
/*!
\qmlclass PathQuad QmlGraphicsPathQuad
+ \since 4.7
\brief The PathQuad defines a quadratic Bezier curve with a control point.
The following QML produces the path shown below:
@@ -671,6 +676,7 @@ void QmlGraphicsPathQuad::addToPath(QPainterPath &path)
/*!
\qmlclass PathCubic QmlGraphicsPathCubic
+ \since 4.7
\brief The PathCubic defines a cubic Bezier curve with two control points.
The following QML produces the path shown below:
@@ -781,6 +787,7 @@ void QmlGraphicsPathCubic::addToPath(QPainterPath &path)
/*!
\qmlclass PathPercent QmlGraphicsPathPercent
+ \since 4.7
\brief The PathPercent manipulates the way a path is interpreted.
The examples below show the normal distrubution of items along a path
diff --git a/src/declarative/graphicsitems/qmlgraphicspath_p.h b/src/declarative/graphicsitems/qmlgraphicspath_p.h
index 51b7262..7ba5bbc 100644
--- a/src/declarative/graphicsitems/qmlgraphicspath_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspath_p.h
@@ -189,7 +189,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsPath : public QObject, public QmlParserSta
Q_OBJECT
Q_INTERFACES(QmlParserStatus)
- Q_PROPERTY(QList<QmlGraphicsPathElement *>* pathElements READ pathElements)
+ Q_PROPERTY(QmlListProperty<QmlGraphicsPathElement> pathElements READ pathElements)
Q_PROPERTY(qreal startX READ startX WRITE setStartX)
Q_PROPERTY(qreal startY READ startY WRITE setStartY)
Q_PROPERTY(bool closed READ isClosed NOTIFY changed)
@@ -199,7 +199,7 @@ public:
QmlGraphicsPath(QObject *parent=0);
~QmlGraphicsPath();
- QList<QmlGraphicsPathElement *>* pathElements();
+ QmlListProperty<QmlGraphicsPathElement> pathElements();
qreal startX() const;
void setStartX(qreal x);
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp
index f862555..9a2c24d 100644
--- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp
@@ -135,6 +135,7 @@ void QmlGraphicsPathViewPrivate::releaseItem(QmlGraphicsItem *item)
/*!
\qmlclass PathView QmlGraphicsPathView
+ \since 4.7
\brief The PathView element lays out model-provided items on a path.
\inherits Item
@@ -524,7 +525,7 @@ void QmlGraphicsPathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *)
qreal dist = qAbs(velocity/2 - qmlMod(velocity/2, qreal(100.0 / d->model->count()) - inc));
d->moveOffset.setValue(d->_offset);
d->tl.accel(d->moveOffset, velocity, 10, dist);
- d->tl.execute(d->fixupOffsetEvent);
+ d->tl.callback(QmlTimeLineCallback(&d->moveOffset, d->fixOffsetCallback, d));
} else {
d->fixOffset();
}
@@ -886,6 +887,11 @@ void QmlGraphicsPathViewPrivate::updateCurrent()
}
}
+void QmlGraphicsPathViewPrivate::fixOffsetCallback(void *d)
+{
+ ((QmlGraphicsPathViewPrivate *)d)->fixOffset();
+}
+
void QmlGraphicsPathViewPrivate::fixOffset()
{
Q_Q(QmlGraphicsPathView);
@@ -938,7 +944,7 @@ void QmlGraphicsPathViewPrivate::snapToCurrent()
rounds++;
tl.move(moveOffset, targetOffset + 100.0*(-rounds), QEasingCurve(QEasingCurve::InOutQuad),
int(100*items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds))));
- tl.execute(fixupOffsetEvent);
+ tl.callback(QmlTimeLineCallback(&moveOffset, fixOffsetCallback, this));
return;
}
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h
index 723d2d5..c635833 100644
--- a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h
@@ -82,7 +82,6 @@ public:
, firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1)
, moveReason(Other)
{
- fixupOffsetEvent = QmlTimeLineEvent::timeLineEvent<QmlGraphicsPathViewPrivate, &QmlGraphicsPathViewPrivate::fixOffset>(&moveOffset, this);
}
void init()
@@ -104,6 +103,7 @@ public:
int calcCurrentIndex();
void updateCurrent();
+ static void fixOffsetCallback(void*);
void fixOffset();
void setOffset(qreal offset);
void regenerate();
@@ -127,7 +127,6 @@ public:
qreal dragMargin;
QmlTimeLine tl;
QmlTimeLineValueProxy<QmlGraphicsPathViewPrivate> moveOffset;
- QmlTimeLineEvent fixupOffsetEvent;
int firstIndex;
int pathItems;
int pathOffset;
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
index 8adf239..84af67d 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
@@ -290,6 +290,7 @@ void QmlGraphicsBasePositioner::finishApplyTransitions()
/*!
\qmlclass Column QmlGraphicsColumn
+ \since 4.7
\brief The Column item lines up its children vertically.
\inherits Item
@@ -339,19 +340,28 @@ Column {
*/
/*!
\qmlproperty Transition Column::add
- This property holds the transition to be applied when adding an item to the positioner. The transition will only be applied to the added item(s).
- Positioner transitions will only affect the position (x,y) of items.
- Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible.
+ This property holds the transition to be applied when adding an
+ item to the positioner. The transition will only be applied to the
+ added item(s). Positioner transitions will only affect the
+ position (x,y) of items.
+
+ Added can mean that either the object has been created or
+ reparented, and thus is now a child or the positioner, or that the
+ object has had its opacity increased from zero, and thus is now
+ visible.
*/
/*!
\qmlproperty Transition Column::move
- This property holds the transition to apply when moving an item within the positioner.
- Positioner transitions will only affect the position (x,y) of items.
- This can happen when other items are added or removed from the positioner, or when items resize themselves.
+ This property holds the transition to apply when moving an item
+ within the positioner. Positioner transitions will only affect
+ the position (x,y) of items.
+
+ This can happen when other items are added or removed from the
+ positioner, or when items resize themselves.
\table
\row
@@ -419,6 +429,7 @@ void QmlGraphicsColumn::doPositioning()
/*!
\qmlclass Row QmlGraphicsRow
+ \since 4.7
\brief The Row item lines up its children horizontally.
\inherits Item
@@ -454,16 +465,22 @@ Row {
The transition will only be applied to the added item(s).
Positioner transitions will only affect the position (x,y) of items.
- Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible.
+ Added can mean that either the object has been created or
+ reparented, and thus is now a child or the positioner, or that the
+ object has had its opacity increased from zero, and thus is now
+ visible.
*/
/*!
\qmlproperty Transition Row::move
- This property holds the transition to apply when moving an item within the positioner.
- Positioner transitions will only affect the position (x,y) of items.
- This can happen when other items are added or removed from the positioner, or when items resize themselves.
+ This property holds the transition to apply when moving an item
+ within the positioner. Positioner transitions will only affect
+ the position (x,y) of items.
+
+ This can happen when other items are added or removed from the
+ positioner, or when items resize themselves.
\qml
Row {
@@ -524,6 +541,7 @@ void QmlGraphicsRow::doPositioning()
/*!
\qmlclass Grid QmlGraphicsGrid
+ \since 4.7
\brief The Grid item positions its children in a grid.
\inherits Item
@@ -710,6 +728,7 @@ void QmlGraphicsGrid::doPositioning()
/*!
\qmlclass Flow QmlGraphicsFlow
+ \since 4.7
\brief The Flow item lines up its children side by side, wrapping as necessary.
\inherits Item
diff --git a/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp b/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp
index f357ed0..adc4cf3 100644
--- a/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp
@@ -83,6 +83,7 @@ void QmlGraphicsPen::setWidth(int w)
/*!
\qmlclass GradientStop QmlGraphicsGradientStop
+ \since 4.7
\brief The GradientStop item defines the color at a position in a Gradient
\sa Gradient
@@ -103,6 +104,7 @@ void QmlGraphicsGradientStop::updateGradient()
/*!
\qmlclass Gradient QmlGraphicsGradient
+ \since 4.7
\brief The Gradient item defines a gradient fill.
A gradient is defined by two or more colors, which will be blended seemlessly. The
@@ -149,6 +151,7 @@ void QmlGraphicsGradient::doUpdate()
/*!
\qmlclass Rectangle QmlGraphicsRectangle
+ \since 4.7
\brief The Rectangle item allows you to add rectangles to a scene.
\inherits Item
diff --git a/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h b/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h
index c566027..66552f6 100644
--- a/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h
@@ -107,14 +107,14 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsGradient : public QObject
{
Q_OBJECT
- Q_PROPERTY(QList<QmlGraphicsGradientStop *> *stops READ stops)
+ Q_PROPERTY(QmlListProperty<QmlGraphicsGradientStop> stops READ stops)
Q_CLASSINFO("DefaultProperty", "stops")
public:
QmlGraphicsGradient(QObject *parent=0) : QObject(parent), m_gradient(0) {}
~QmlGraphicsGradient() { delete m_gradient; }
- QList<QmlGraphicsGradientStop *> *stops() { return &m_stops; }
+ QmlListProperty<QmlGraphicsGradientStop> stops() { return QmlListProperty<QmlGraphicsGradientStop>(this, m_stops); }
const QGradient *gradient() const;
diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp
index fc78ef8..23c3aae 100644
--- a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp
@@ -62,6 +62,7 @@ QmlGraphicsRepeaterPrivate::~QmlGraphicsRepeaterPrivate()
/*!
\qmlclass Repeater QmlGraphicsRepeater
+ \since 4.7
\inherits Item
\brief The Repeater item allows you to repeat a component based on a model.
diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp
index ab2f9a3..57b44d2 100644
--- a/src/declarative/graphicsitems/qmlgraphicstext.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp
@@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass Text QmlGraphicsText
+ \since 4.7
\brief The Text item allows you to add formatted text to a scene.
\inherits Item
@@ -554,6 +555,7 @@ void QmlGraphicsTextPrivate::updateSize()
else
doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug)
dy -= (int)doc->size().height();
+ cachedLayoutSize = doc->size().toSize();
}
int yoff = 0;
@@ -769,7 +771,7 @@ void QmlGraphicsText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidg
{
Q_D(QmlGraphicsText);
- if (d->cache || d->richText || d->style != Normal) {
+ if (d->cache || d->style != Normal) {
d->checkImgCache();
if (d->imgCache.isNull())
return;
@@ -846,7 +848,15 @@ void QmlGraphicsText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidg
p->save();
p->setClipRect(boundingRect(), Qt::IntersectClip);
}
- d->drawWrappedText(p, QPointF(0,y), false);
+ if (d->richText) {
+ QAbstractTextDocumentLayout::PaintContext context;
+ context.palette.setColor(QPalette::Text, d->color);
+ p->translate(0, y);
+ d->doc->documentLayout()->draw(p, context);
+ p->translate(0, -y);
+ } else {
+ d->drawWrappedText(p, QPointF(0,y), false);
+ }
if (needClip)
p->restore();
}
diff --git a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h b/src/declarative/graphicsitems/qmlgraphicstext_p_p.h
index 46d2d0e..f67d57c 100644
--- a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicstext_p_p.h
@@ -75,7 +75,7 @@ public:
dirty(true), wrap(false), richText(false), singleline(false), cache(true), doc(0),
format(QmlGraphicsText::AutoText)
{
-#ifdef QML_NO_TEXT_CACHE
+#if defined(QML_NO_TEXT_CACHE)
cache = false;
#endif
}
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
index 3dadbe0..364751d 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
@@ -59,6 +59,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass TextEdit QmlGraphicsTextEdit
+ \since 4.7
\brief The TextEdit item allows you to add editable formatted text to a scene.
It can display both plain and rich text. For example:
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
index 6b4407f..d3c1f1f 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
@@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass TextInput QmlGraphicsTextInput
+ \since 4.7
The TextInput item allows you to add an editable line of text to a scene.
TextInput can only display a single line of text, and can only display
diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
index 4ced2c3..1928195 100644
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
@@ -71,16 +71,14 @@ class QmlGraphicsVisualItemModelPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlGraphicsVisualItemModel)
public:
- QmlGraphicsVisualItemModelPrivate() : QObjectPrivate(), children(this) {}
+ QmlGraphicsVisualItemModelPrivate() : QObjectPrivate() {}
- struct ItemList : public QmlConcreteList<QmlGraphicsItem *>
- {
- ItemList(QmlGraphicsVisualItemModelPrivate *m) : QmlConcreteList<QmlGraphicsItem *>(), model(m) {}
-
- void append(QmlGraphicsItem *item);
-
- QmlGraphicsVisualItemModelPrivate *model;
- };
+ static void children_append(QmlListProperty<QmlGraphicsItem> *prop, QmlGraphicsItem *item) {
+ item->QObject::setParent(prop->object);
+ static_cast<QmlGraphicsVisualItemModelPrivate *>(prop->data)->children.append(item);
+ static_cast<QmlGraphicsVisualItemModelPrivate *>(prop->data)->itemAppended();
+ static_cast<QmlGraphicsVisualItemModelPrivate *>(prop->data)->emitChildrenChanged();
+ }
void itemAppended() {
Q_Q(QmlGraphicsVisualItemModel);
@@ -94,12 +92,14 @@ public:
Q_Q(QmlGraphicsVisualItemModel);
emit q->childrenChanged();
}
- ItemList children;
+
+ QList<QmlGraphicsItem *> children;
};
/*!
\qmlclass VisualItemModel QmlGraphicsVisualItemModel
+ \since 4.7
\brief The VisualItemModel allows items to be provided to a view.
The children of the VisualItemModel are provided in a model which
@@ -132,10 +132,10 @@ QmlGraphicsVisualItemModel::QmlGraphicsVisualItemModel()
{
}
-QmlList<QmlGraphicsItem *> *QmlGraphicsVisualItemModel::children()
+QmlListProperty<QmlGraphicsItem> QmlGraphicsVisualItemModel::children()
{
Q_D(QmlGraphicsVisualItemModel);
- return &(d->children);
+ return QmlListProperty<QmlGraphicsItem>(this, d, QmlGraphicsVisualItemModelPrivate::children_append);
}
/*!
@@ -200,15 +200,6 @@ int QmlGraphicsVisualItemModel::indexOf(QmlGraphicsItem *item, QObject *) const
return d->children.indexOf(item);
}
-void QmlGraphicsVisualItemModelPrivate::ItemList::append(QmlGraphicsItem *item)
-{
- QmlConcreteList<QmlGraphicsItem*>::append(item);
- item->QObject::setParent(model->q_ptr);
- model->itemAppended();
-
- model->emitChildrenChanged();
-}
-
QmlGraphicsVisualItemModelAttached *QmlGraphicsVisualItemModel::qmlAttachedProperties(QObject *obj)
{
return QmlGraphicsVisualItemModelAttached::properties(obj);
@@ -422,8 +413,7 @@ int QmlGraphicsVisualDataModelDataMetaObject::createProperty(const char *name, c
QmlGraphicsVisualDataModelPrivate *model = QmlGraphicsVisualDataModelPrivate::get(data->m_model);
if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) {
- if (model->m_listAccessor->type() == QmlListAccessor::QmlList
- || model->m_listAccessor->type() == QmlListAccessor::QListPtr) {
+ if (model->m_listAccessor->type() == QmlListAccessor::ListProperty) {
model->ensureRoles();
QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>();
if (object && object->property(name).isValid())
@@ -685,7 +675,7 @@ void QmlGraphicsVisualDataModel::setModel(const QVariant &model)
}
d->m_listAccessor = new QmlListAccessor;
d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this));
- if (d->m_listAccessor->type() != QmlListAccessor::QmlList && d->m_listAccessor->type() != QmlListAccessor::QListPtr)
+ if (d->m_listAccessor->type() != QmlListAccessor::ListProperty)
d->m_metaDataCacheable = true;
if (d->m_delegate && d->modelCount()) {
emit itemsInserted(0, d->modelCount());
diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h
index c0ea499..49f9b27 100644
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h
@@ -109,7 +109,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsVisualItemModel : public QmlGraphicsVisual
Q_OBJECT
Q_DECLARE_PRIVATE(QmlGraphicsVisualItemModel)
- Q_PROPERTY(QmlList<QmlGraphicsItem *>* children READ children NOTIFY childrenChanged DESIGNABLE false)
+ Q_PROPERTY(QmlListProperty<QmlGraphicsItem> children READ children NOTIFY childrenChanged DESIGNABLE false)
Q_CLASSINFO("DefaultProperty", "children")
public:
@@ -126,7 +126,7 @@ public:
virtual int indexOf(QmlGraphicsItem *item, QObject *objectContext) const;
- QmlList<QmlGraphicsItem *> *children();
+ QmlListProperty<QmlGraphicsItem> children();
static QmlGraphicsVisualItemModelAttached *qmlAttachedProperties(QObject *obj);
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
index 515f896..7d9bf52 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
@@ -77,7 +77,6 @@ public:
progress(1.0), status(QmlGraphicsWebView::Null), pending(PendingNone),
newWindowComponent(0), newWindowParent(0),
pressTime(400),
- windowObjects(this),
rendering(true)
{
}
@@ -101,25 +100,21 @@ public:
QPoint pressPoint;
int pressTime; // milliseconds before it's a "hold"
+
+ static void windowObjects_append(QmlListProperty<QObject> *prop, QObject *o) {
+ static_cast<QmlGraphicsWebViewPrivate *>(prop->data)->windowObjects.append(o);
+ static_cast<QmlGraphicsWebViewPrivate *>(prop->data)->updateWindowObjects();
+ }
+
void updateWindowObjects();
- class WindowObjectList : public QmlConcreteList<QObject *>
- {
- public:
- WindowObjectList(QmlGraphicsWebViewPrivate *p)
- : priv(p) {}
- virtual void append(QObject *v) {
- QmlConcreteList<QObject *>::append(v);
- priv->updateWindowObjects();
- }
- private:
- QmlGraphicsWebViewPrivate *priv;
- } windowObjects;
+ QObjectList windowObjects;
bool rendering;
};
/*!
\qmlclass WebView QmlGraphicsWebView
+ \since 4.7
\brief The WebView item allows you to add web content to a canvas.
\inherits Item
@@ -451,10 +446,10 @@ void QmlGraphicsWebView::paintPage(const QRect& r)
If Javascript is not enabled for this page, then this property does nothing.
*/
-QmlList<QObject *> *QmlGraphicsWebView::javaScriptWindowObjects()
+QmlListProperty<QObject> QmlGraphicsWebView::javaScriptWindowObjects()
{
Q_D(QmlGraphicsWebView);
- return &d->windowObjects;
+ return QmlListProperty<QObject>(this, d, &QmlGraphicsWebViewPrivate::windowObjects_append);
}
QmlGraphicsWebViewAttached *QmlGraphicsWebView::qmlAttachedProperties(QObject *o)
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
index 1822ddb..30ba0e4 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
@@ -114,7 +114,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem
Q_PROPERTY(QmlGraphicsWebSettings* settings READ settingsObject CONSTANT)
- Q_PROPERTY(QmlList<QObject *>* javaScriptWindowObjects READ javaScriptWindowObjects CONSTANT)
+ Q_PROPERTY(QmlListProperty<QObject> javaScriptWindowObjects READ javaScriptWindowObjects CONSTANT)
Q_PROPERTY(QmlComponent* newWindowComponent READ newWindowComponent WRITE setNewWindowComponent)
Q_PROPERTY(QmlGraphicsItem* newWindowParent READ newWindowParent WRITE setNewWindowParent)
@@ -174,7 +174,7 @@ public:
bool renderingEnabled() const;
void setRenderingEnabled(bool);
- QmlList<QObject *> *javaScriptWindowObjects();
+ QmlListProperty<QObject> javaScriptWindowObjects();
static QmlGraphicsWebViewAttached *qmlAttachedProperties(QObject *);
diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h
index e5e7c59..163d198 100644
--- a/src/declarative/qml/qml.h
+++ b/src/declarative/qml/qml.h
@@ -55,16 +55,12 @@
QT_BEGIN_HEADER
-QT_MODULE(Declarative)
-
#define QML_DECLARE_TYPE(TYPE) \
Q_DECLARE_METATYPE(TYPE *) \
- Q_DECLARE_METATYPE(QList<TYPE *> *) \
- Q_DECLARE_METATYPE(QmlList<TYPE *> *)
+ Q_DECLARE_METATYPE(QmlListProperty<TYPE>)
#define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \
- Q_DECLARE_METATYPE(QList<TYPE *> *) \
- Q_DECLARE_METATYPE(QmlList<TYPE *> *)
+ Q_DECLARE_METATYPE(QmlListProperty<TYPE>)
#define QML_DECLARE_INTERFACE(INTERFACE) \
QML_DECLARE_TYPE(INTERFACE)
@@ -90,6 +86,8 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
+QT_MODULE(Declarative)
+
#if defined(Q_OS_SYMBIAN)
#define QML_DEFINE_INTERFACE(INTERFACE) \
static int defineInterface##INTERFACE = qmlRegisterInterface<INTERFACE>(#INTERFACE);
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index a8df61e..2313c37 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -51,7 +51,9 @@ SOURCES += \
$$PWD/qmllistscriptclass.cpp \
$$PWD/qmlworkerscript.cpp \
$$PWD/qmlimageprovider.cpp \
- $$PWD/qmlnetworkaccessmanagerfactory.cpp
+ $$PWD/qmlnetworkaccessmanagerfactory.cpp \
+ $$PWD/qmllist.cpp
+
HEADERS += \
$$PWD/qmlparser_p.h \
$$PWD/qmlglobal_p.h \
@@ -91,6 +93,7 @@ HEADERS += \
$$PWD/qmlcompositetypedata_p.h \
$$PWD/qmlcompositetypemanager_p.h \
$$PWD/qmllist.h \
+ $$PWD/qmllist_p.h \
$$PWD/qmldeclarativedata_p.h \
$$PWD/qmlerror.h \
$$PWD/qmlscriptparser_p.h \
diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp
index 0dbe63b..feadd0f 100644
--- a/src/declarative/qml/qmlbinding.cpp
+++ b/src/declarative/qml/qmlbinding.cpp
@@ -54,8 +54,6 @@
#include <QVariant>
#include <QtCore/qdebug.h>
-Q_DECLARE_METATYPE(QList<QObject *>);
-
QT_BEGIN_NAMESPACE
QML_DEFINE_NOCREATE_TYPE(QmlBinding);
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 2b1081e..bbae201 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -1495,8 +1495,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop,
COMPILE_CHECK(buildGroupedProperty(prop, obj, ctxt));
- } else if (QmlEnginePrivate::get(engine)->isQmlList(prop->type) ||
- QmlMetaType::isList(prop->type)) {
+ } else if (QmlEnginePrivate::get(engine)->isList(prop->type)) {
COMPILE_CHECK(buildListProperty(prop, obj, ctxt));
@@ -1552,8 +1551,7 @@ QmlCompiler::buildPropertyInNamespace(QmlEnginePrivate::ImportedNamespace *ns,
void QmlCompiler::genValueProperty(QmlParser::Property *prop,
QmlParser::Object *obj)
{
- if (QmlEnginePrivate::get(engine)->isQmlList(prop->type) ||
- QmlMetaType::isList(prop->type)) {
+ if (QmlEnginePrivate::get(engine)->isList(prop->type)) {
genListProperty(prop, obj);
} else {
genPropertyAssignment(prop, obj);
@@ -1563,22 +1561,10 @@ void QmlCompiler::genValueProperty(QmlParser::Property *prop,
void QmlCompiler::genListProperty(QmlParser::Property *prop,
QmlParser::Object *obj)
{
- QmlInstruction::Type fetchType;
- QmlInstruction::Type storeType;
- int listType;
-
- if (QmlEnginePrivate::get(engine)->isQmlList(prop->type)) {
- fetchType = QmlInstruction::FetchQmlList;
- storeType = QmlInstruction::StoreObjectQmlList;
- listType = QmlEnginePrivate::get(engine)->qmlListType(prop->type);
- } else {
- fetchType = QmlInstruction::FetchQList;
- storeType = QmlInstruction::StoreObjectQList;
- listType = QmlMetaType::listType(prop->type);
- }
+ int listType = QmlEnginePrivate::get(engine)->listType(prop->type);
QmlInstruction fetch;
- fetch.type = fetchType;
+ fetch.type = QmlInstruction::FetchQList;
fetch.line = prop->location.start.line;
fetch.fetchQmlList.property = prop->index;
bool listTypeIsInterface = QmlMetaType::isInterface(listType);
@@ -1598,7 +1584,7 @@ void QmlCompiler::genListProperty(QmlParser::Property *prop,
output->bytecode << assign;
} else {
QmlInstruction store;
- store.type = storeType;
+ store.type = QmlInstruction::StoreObjectQList;
store.line = prop->location.start.line;
output->bytecode << store;
}
@@ -1895,67 +1881,40 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop,
QmlParser::Object *obj,
const BindingContext &ctxt)
{
- Q_ASSERT(QmlMetaType::isList(prop->type) ||
- QmlEnginePrivate::get(engine)->isQmlList(prop->type));
+ Q_ASSERT(QmlEnginePrivate::get(engine)->isList(prop->type));
int t = prop->type;
obj->addValueProperty(prop);
- if (QmlEnginePrivate::get(engine)->isQmlList(t)) {
- int listType = QmlEnginePrivate::get(engine)->qmlListType(t);
- bool listTypeIsInterface = QmlMetaType::isInterface(listType);
-
- for (int ii = 0; ii < prop->values.count(); ++ii) {
- Value *v = prop->values.at(ii);
- 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, QCoreApplication::translate("QmlCompiler","Cannot assign object to list"));
- }
- }
+ int listType = QmlEnginePrivate::get(engine)->listType(t);
+ bool listTypeIsInterface = QmlMetaType::isInterface(listType);
- } else {
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Cannot assign primitives to lists"));
- }
- }
+ bool assignedBinding = false;
+ for (int ii = 0; ii < prop->values.count(); ++ii) {
+ Value *v = prop->values.at(ii);
+ if (v->object) {
+ v->type = Value::CreatedObject;
+ COMPILE_CHECK(buildObject(v->object, ctxt));
- } else {
- int listType = QmlMetaType::listType(t);
- bool listTypeIsInterface = QmlMetaType::isInterface(listType);
-
- bool assignedBinding = false;
- for (int ii = 0; ii < prop->values.count(); ++ii) {
- Value *v = prop->values.at(ii);
- 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, QCoreApplication::translate("QmlCompiler","Cannot assign object to list"));
- }
+ // We check object coercian here. We check interface assignment
+ // at runtime.
+ if (!listTypeIsInterface) {
+ if (!canCoerce(listType, v->object)) {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Cannot assign object to list"));
}
+ }
- } else if (v->value.isScript()) {
- if (assignedBinding)
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Can only assign one binding to lists"));
+ } else if (v->value.isScript()) {
+ if (assignedBinding)
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Can only assign one binding to lists"));
- assignedBinding = true;
- COMPILE_CHECK(buildBinding(v, prop, ctxt));
- v->type = Value::PropertyBinding;
- } else {
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Cannot assign primitives to lists"));
- }
+ assignedBinding = true;
+ COMPILE_CHECK(buildBinding(v, prop, ctxt));
+ v->type = Value::PropertyBinding;
+ } else {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Cannot assign primitives to lists"));
}
-
}
return true;
@@ -2335,10 +2294,10 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
propertyType = QMetaType::QObjectStar;
} else {
readonly = true;
- type = "QmlList<";
+ type = "QmlListProperty<";
type.append(customTypeName);
- type.append("*>*");
- propertyType = qMetaTypeId<QmlList<QObject*>* >();
+ type.append(">");
+ propertyType = qMetaTypeId<QmlListProperty<QObject> >();
}
}
break;
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 87ecb8a..1bdc883 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -69,12 +69,14 @@ int statusId = qRegisterMetaType<QmlComponent::Status>("QmlComponent::Status");
/*!
\class QmlComponent
+ \since 4.7
\brief The QmlComponent class encapsulates a QML component description.
\mainclass
*/
/*!
\qmlclass Component QmlComponent
+ \since 4.7
\brief The Component element encapsulates a QML component description.
Components are reusable, encapsulated Qml element with a well-defined interface.
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp
index 303af42..1718387 100644
--- a/src/declarative/qml/qmlcontext.cpp
+++ b/src/declarative/qml/qmlcontext.cpp
@@ -130,6 +130,7 @@ void QmlContextPrivate::init()
/*!
\class QmlContext
+ \since 4.7
\brief The QmlContext class defines a context within a QML engine.
\mainclass
@@ -544,5 +545,30 @@ QUrl QmlContext::baseUrl() const
return QUrl();
}
+int QmlContextPrivate::context_count(QmlListProperty<QObject> *prop)
+{
+ QmlContext *context = static_cast<QmlContext*>(prop->object);
+ QmlContextPrivate *d = QmlContextPrivate::get(context);
+ int contextProperty = (int)(intptr_t)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 *QmlContextPrivate::context_at(QmlListProperty<QObject> *prop, int index)
+{
+ QmlContext *context = static_cast<QmlContext*>(prop->object);
+ QmlContextPrivate *d = QmlContextPrivate::get(context);
+ int contextProperty = (int)(intptr_t)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);
+ }
+}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h
index 21b1a1e..e96ed84 100644
--- a/src/declarative/qml/qmlcontext.h
+++ b/src/declarative/qml/qmlcontext.h
@@ -45,6 +45,7 @@
#include <QtCore/qurl.h>
#include <QtCore/qobject.h>
#include <QtScript/qscriptvalue.h>
+#include <QtCore/qmetatype.h>
QT_BEGIN_HEADER
@@ -97,9 +98,10 @@ private:
QmlContext(QmlContext *parent, QObject *objParent, bool);
QmlContext(QmlEngine *, bool);
};
-
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QList<QObject*>);
+
QT_END_HEADER
#endif // QMLCONTEXT_H
diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h
index bd4f5d5..965eeed 100644
--- a/src/declarative/qml/qmlcontext_p.h
+++ b/src/declarative/qml/qmlcontext_p.h
@@ -152,6 +152,9 @@ public:
// Only used for debugging
QList<QPointer<QObject> > instances;
+
+ static int context_count(QmlListProperty<QObject> *);
+ static QObject *context_at(QmlListProperty<QObject> *, int);
};
QmlContextPrivate::IdNotifier::IdNotifier()
diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp
index be3bbc3..4c71903 100644
--- a/src/declarative/qml/qmlcontextscriptclass.cpp
+++ b/src/declarative/qml/qmlcontextscriptclass.cpp
@@ -44,6 +44,7 @@
#include "qmlengine_p.h"
#include "qmlcontext_p.h"
#include "qmltypenamescriptclass_p.h"
+#include "qmllistscriptclass_p.h"
#include "qmlguard_p.h"
QT_BEGIN_NAMESPACE
@@ -227,8 +228,12 @@ QmlContextScriptClass::property(Object *object, const Identifier &name)
if (lastPropertyIndex < cp->idValueCount) {
rv = ep->objectClass->newQObject(cp->idValues[lastPropertyIndex].data());
} else {
- QVariant value = cp->propertyValues.at(lastPropertyIndex);
- rv = ep->scriptValueFromVariant(value);
+ const QVariant &value = cp->propertyValues.at(lastPropertyIndex);
+ if (value.userType() == qMetaTypeId<QList<QObject*> >()) {
+ rv = ep->listClass->newList(QmlListProperty<QObject>(bindContext, (void*)lastPropertyIndex, 0, QmlContextPrivate::context_count, QmlContextPrivate::context_at), qMetaTypeId<QmlListProperty<QObject> >());
+ } else {
+ rv = ep->scriptValueFromVariant(value);
+ }
}
ep->capturedProperties <<
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index 01061ee..c75a299 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -1346,7 +1346,6 @@ QmlDomValue::Type QmlDomValue::type() const
{
if (d->property)
if (QmlMetaType::isList(d->property->type) ||
- QmlMetaType::isQmlList(d->property->type) ||
(d->property && d->property->values.count() > 1))
return List;
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index cf26f58..63ee7b1 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -66,6 +66,7 @@
#include "qmlscriptclass_p.h"
#include "qmlnetworkaccessmanagerfactory.h"
#include "qmlimageprovider.h"
+#include "qmllist_p.h"
#include <qfxperf_p_p.h>
@@ -107,7 +108,6 @@
#endif
Q_DECLARE_METATYPE(QmlMetaProperty)
-Q_DECLARE_METATYPE(QList<QObject *>);
QT_BEGIN_NAMESPACE
@@ -116,6 +116,7 @@ DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE)
QML_DEFINE_TYPE(Qt,4,6,QtObject,QObject)
/*!
\qmlclass QtObject QObject
+ \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
@@ -343,6 +344,7 @@ QmlWorkerScriptEngine *QmlEnginePrivate::getWorkerScriptEngine()
/*!
\class QmlEngine
+ \since 4.7
\brief The QmlEngine class provides an environment for instantiating QML components.
\mainclass
@@ -1170,6 +1172,15 @@ QScriptValue QmlEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine)
QScriptValue QmlEnginePrivate::scriptValueFromVariant(const QVariant &val)
{
+ if (val.userType() == qMetaTypeId<QmlListReference>()) {
+ QmlListReferencePrivate *p = QmlListReferencePrivate::get((QmlListReference*)val.constData());
+ if (p->object) {
+ return listClass->newList(p->property, p->propertyType);
+ } else {
+ return scriptEngine.nullValue();
+ }
+ }
+
bool objOk;
QObject *obj = QmlMetaType::toQObject(val, &objOk);
if (objOk) {
@@ -1667,7 +1678,7 @@ void QmlEnginePrivate::registerCompositeType(QmlCompiledData *data)
QByteArray name = data->root->className();
QByteArray ptr = name + '*';
- QByteArray lst = "QmlList<" + ptr + ">*";
+ QByteArray lst = "QmlListProperty<" + name + ">";
int ptr_type = QMetaType::registerType(ptr.constData(), voidptr_destructor,
voidptr_constructor);
@@ -1679,9 +1690,18 @@ void QmlEnginePrivate::registerCompositeType(QmlCompiledData *data)
data->addref();
}
-bool QmlEnginePrivate::isQmlList(int t) const
+bool QmlEnginePrivate::isList(int t) const
{
- return m_qmlLists.contains(t) || QmlMetaType::isQmlList(t);
+ return m_qmlLists.contains(t) || QmlMetaType::isList(t);
+}
+
+int QmlEnginePrivate::listType(int t) const
+{
+ QHash<int, int>::ConstIterator iter = m_qmlLists.find(t);
+ if (iter != m_qmlLists.end())
+ return *iter;
+ else
+ return QmlMetaType::listType(t);
}
bool QmlEnginePrivate::isQObject(int t)
@@ -1700,21 +1720,12 @@ QObject *QmlEnginePrivate::toQObject(const QVariant &v, bool *ok) const
}
}
-int QmlEnginePrivate::qmlListType(int t) const
-{
- QHash<int, int>::ConstIterator iter = m_qmlLists.find(t);
- if (iter != m_qmlLists.end())
- return *iter;
- else
- return QmlMetaType::qmlListType(t);
-}
-
QmlMetaType::TypeCategory QmlEnginePrivate::typeCategory(int t) const
{
if (m_compositeTypes.contains(t))
return QmlMetaType::Object;
else if (m_qmlLists.contains(t))
- return QmlMetaType::QmlList;
+ return QmlMetaType::List;
else
return QmlMetaType::typeCategory(t);
}
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index 7ec6dd6..3fe7991 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -274,11 +274,12 @@ public:
void registerCompositeType(QmlCompiledData *);
- bool isQmlList(int) const;
+
bool isQObject(int);
QObject *toQObject(const QVariant &, bool *ok = 0) const;
- int qmlListType(int) const;
QmlMetaType::TypeCategory typeCategory(int) const;
+ bool isList(int) const;
+ int listType(int) const;
const QMetaObject *rawMetaObjectForType(int) const;
const QMetaObject *metaObjectForType(int) const;
QHash<int, int> m_qmlLists;
@@ -322,7 +323,6 @@ public:
QmlContext *getContext(QScriptContext *);
};
-
QT_END_NAMESPACE
#endif // QMLENGINE_P_H
diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp
index d3caa95..654157c 100644
--- a/src/declarative/qml/qmlenginedebug.cpp
+++ b/src/declarative/qml/qmlenginedebug.cpp
@@ -119,8 +119,7 @@ QmlEngineDebugServer::propertyData(QObject *obj, int propIdx)
rv.type = QmlObjectProperty::Basic;
} else if (QmlMetaType::isQObject(prop.userType())) {
rv.type = QmlObjectProperty::Object;
- } else if (QmlMetaType::isList(prop.userType()) ||
- QmlMetaType::isQmlList(prop.userType())) {
+ } else if (QmlMetaType::isList(prop.userType())) {
rv.type = QmlObjectProperty::List;
}
@@ -133,14 +132,15 @@ QVariant QmlEngineDebugServer::valueContents(const QVariant &value) const
if (QVariant::Type(userType) < QVariant::UserType)
return value;
-
- if (QmlMetaType::isList(userType) || QmlMetaType::isQmlList(userType)) {
+ /*
+ if (QmlMetaType::isList(userType)) {
int count = QmlMetaType::listCount(value);
QVariantList contents;
for (int i=0; i<count; i++)
contents << valueContents(QmlMetaType::listAt(value, i));
return contents;
- } else if (QmlMetaType::isQObject(userType)) {
+ } else */
+ if (QmlMetaType::isQObject(userType)) {
QObject *o = QmlMetaType::toQObject(value);
if (o) {
QString name = o->objectName();
diff --git a/src/declarative/qml/qmlerror.cpp b/src/declarative/qml/qmlerror.cpp
index 5ba7719..fc4bcd5 100644
--- a/src/declarative/qml/qmlerror.cpp
+++ b/src/declarative/qml/qmlerror.cpp
@@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QmlError
+ \since 4.7
\brief The QmlError class encapsulates a QML error
*/
class QmlErrorPrivate
diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp
index d428377..3039fed 100644
--- a/src/declarative/qml/qmlexpression.cpp
+++ b/src/declarative/qml/qmlexpression.cpp
@@ -52,8 +52,6 @@
#include <private/qscriptdeclarativeclass_p.h>
-Q_DECLARE_METATYPE(QList<QObject *>);
-
QT_BEGIN_NAMESPACE
bool QmlDelayedError::addError(QmlEnginePrivate *e)
@@ -189,6 +187,7 @@ QScriptValue QmlExpressionPrivate::evalInObjectScope(QmlContext *context, QObjec
/*!
\class QmlExpression
+ \since 4.7
\brief The QmlExpression class evaluates JavaScript in a QML context.
*/
diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp
index de01bfe..e37ade7 100644
--- a/src/declarative/qml/qmlinstruction.cpp
+++ b/src/declarative/qml/qmlinstruction.cpp
@@ -171,9 +171,6 @@ void QmlCompiledData::dump(QmlInstruction *instr, int idx)
case QmlInstruction::BeginObject:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "BEGIN\t\t\t" << instr->begin.castValue;
break;
- case QmlInstruction::StoreObjectQmlList:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_OBJECT_QMLLIST";
- break;
case QmlInstruction::StoreObjectQList:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_OBJECT_QLIST";
break;
@@ -183,9 +180,6 @@ void QmlCompiledData::dump(QmlInstruction *instr, int idx)
case QmlInstruction::FetchAttached:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "FETCH_ATTACHED\t\t" << instr->fetchAttached.id;
break;
- case QmlInstruction::FetchQmlList:
- qWarning().nospace() << idx << "\t\t" << line << "\t" << "FETCH_QMLLIST\t\t" << instr->fetchQmlList.property << "\t" << instr->fetchQmlList.type;
- break;
case QmlInstruction::FetchQList:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "FETCH_QLIST\t\t" << instr->fetch.property;
break;
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 5613888..ea785b6 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -134,12 +134,10 @@ public:
BeginObject, /* begin */
- StoreObjectQmlList, /* NA */
StoreObjectQList, /* NA */
AssignObjectList, /* NA */
FetchAttached, /* fetchAttached */
- FetchQmlList, /* fetchQmlList */
FetchQList, /* fetch */
FetchObject, /* fetch */
FetchValueType, /* fetchValue */
diff --git a/src/declarative/qml/qmllist.cpp b/src/declarative/qml/qmllist.cpp
new file mode 100644
index 0000000..4cd2120
--- /dev/null
+++ b/src/declarative/qml/qmllist.cpp
@@ -0,0 +1,312 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmllist.h"
+#include "qmllist_p.h"
+#include "qmlengine_p.h"
+#include "qmlmetaproperty_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QmlListReferencePrivate::QmlListReferencePrivate()
+: propertyType(-1), refCount(1)
+{
+}
+
+QmlListReference QmlListReferencePrivate::init(const QmlListProperty<QObject> &prop, int propType, QmlEngine *engine)
+{
+ QmlListReference rv;
+
+ if (!prop.object) return rv;
+
+ QmlEnginePrivate *p = engine?QmlEnginePrivate::get(engine):0;
+
+ int listType = p?p->listType(propType):QmlMetaType::listType(propType);
+ if (listType == -1) return rv;
+
+ rv.d = new QmlListReferencePrivate;
+ rv.d->object = prop.object;
+ rv.d->elementType = p?p->rawMetaObjectForType(listType):QmlMetaType::qmlType(listType)->baseMetaObject();
+ rv.d->property = prop;
+ rv.d->propertyType = propType;
+
+ return rv;
+}
+
+void QmlListReferencePrivate::addref()
+{
+ Q_ASSERT(refCount > 0);
+ ++refCount;
+}
+
+void QmlListReferencePrivate::release()
+{
+ Q_ASSERT(refCount > 0);
+ --refCount;
+ if (!refCount)
+ delete this;
+}
+
+QmlListReference::QmlListReference()
+: d(0)
+{
+}
+
+QmlListReference::QmlListReference(QObject *o, const char *property, QmlEngine *engine)
+: d(0)
+{
+ if (!o || !property) return;
+
+ QmlPropertyCache::Data local;
+ QmlPropertyCache::Data *data = QmlPropertyCache::property(engine, o, QLatin1String(property), local);
+
+ if (!data || !(data->flags & QmlPropertyCache::Data::IsQList)) return;
+
+ QmlEnginePrivate *p = engine?QmlEnginePrivate::get(engine):0;
+
+ int listType = p?p->listType(data->propType):QmlMetaType::listType(data->propType);
+ if (listType == -1) return;
+
+ d = new QmlListReferencePrivate;
+ d->object = o;
+ d->elementType = p?p->rawMetaObjectForType(listType):QmlMetaType::qmlType(listType)->baseMetaObject();
+ d->propertyType = data->propType;
+
+ void *args[] = { &d->property, 0 };
+ QMetaObject::metacall(o, QMetaObject::ReadProperty, data->coreIndex, args);
+}
+
+QmlListReference::QmlListReference(const QmlListReference &o)
+: d(o.d)
+{
+ if (d) d->addref();
+}
+
+QmlListReference &QmlListReference::operator=(const QmlListReference &o)
+{
+ if (o.d) o.d->addref();
+ if (d) d->release();
+ d = o.d;
+ return *this;
+}
+
+QmlListReference::~QmlListReference()
+{
+ if (d) d->release();
+}
+
+bool QmlListReference::isValid() const
+{
+ return d && d->object;
+}
+
+QObject *QmlListReference::object() const
+{
+ if (isValid()) return d->object;
+ else return 0;
+}
+
+const QMetaObject *QmlListReference::listElementType() const
+{
+ if (isValid()) return d->elementType;
+ else return 0;
+}
+
+bool QmlListReference::canAppend() const
+{
+ return (isValid() && d->property.append);
+}
+
+bool QmlListReference::canAt() const
+{
+ return (isValid() && d->property.at);
+}
+
+bool QmlListReference::canClear() const
+{
+ return (isValid() && d->property.clear);
+}
+
+bool QmlListReference::canCount() const
+{
+ return (isValid() && d->property.count);
+}
+
+bool QmlListReference::append(QObject *o) const
+{
+ if (!canAppend()) return false;
+
+ if (o && !QmlMetaPropertyPrivate::canConvert(o->metaObject(), d->elementType))
+ return false;
+
+ d->property.append(&d->property, o);
+
+ return true;
+}
+
+QObject *QmlListReference::at(int index) const
+{
+ if (!canAt()) return 0;
+
+ return d->property.at(&d->property, index);
+}
+
+bool QmlListReference::clear() const
+{
+ if (!canClear()) return false;
+
+ d->property.clear(&d->property);
+
+ return true;
+}
+
+int QmlListReference::count() const
+{
+ if (!canCount()) return 0;
+
+ return d->property.count(&d->property);
+}
+
+/*!
+\class QmlListProperty
+\brief The QmlListProperty class allows applications to explose 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 QmlListProperty 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 QmlListProperty 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(QmlListProperty<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.
+*/
+
+/*!
+\fn QmlListProperty::QmlListProperty()
+\internal
+*/
+
+/*!
+\fn QmlListProperty::QmlListProperty(QObject *object, QList<T *> &list)
+
+Convenience constructor for making a QmlListProperty 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 QmlListProperty::QmlListProperty(QObject *object, void *data, AppendFunction append,
+ CountFunction count = 0, AtFunction at = 0,
+ ClearFunction clear = 0)
+
+Construct a QmlListProperty 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 QmlListProperty::AppendFunction
+
+Synonym for \c {void (*)(QmlListProperty<T> *property, T *value)}.
+
+Append the \a value to the list \a property.
+*/
+
+/*!
+\typedef QmlListProperty::CountFunction
+
+Synonym for \c {int (*)(QmlListProperty<T> *property)}.
+
+Return the number of elements in the list \a property.
+*/
+
+/*!
+\fn bool QmlListProperty::operator==(const QmlListProperty &other) const
+
+Returns true if this QmlListProperty is equal to \a other, otherwise false.
+*/
+
+/*!
+\typedef QmlListProperty::AtFunction
+
+Synonym for \c {T *(*)(QmlListProperty<T> *property, int index)}.
+
+Return the element at position \a index in the list \a property.
+*/
+
+/*!
+\typedef QmlListProperty::ClearFunction
+
+Synonym for \c {void (*)(QmlListProperty<T> *property)}.
+
+Clear the list \a property.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmllist.h b/src/declarative/qml/qmllist.h
index 261145d..cedc35b 100644
--- a/src/declarative/qml/qmllist.h
+++ b/src/declarative/qml/qmllist.h
@@ -51,73 +51,89 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
template<typename T>
-class QmlList : private QmlPrivate::ListInterface
-{
-public:
- virtual void append(T) = 0;
- virtual void insert(int, T) = 0;
- virtual void removeAt(int) = 0;
- virtual T at(int) const = 0;
- virtual int count() const = 0;
- virtual void clear() = 0;
- QmlList<T> &operator<<(T t) { append(t); return *this; }
-
-protected:
- virtual int type() const { return qMetaTypeId<T>(); }
- virtual void append(void *d) { const T &v = *(T *)d; append(v); }
- virtual void insert(int i, void *d) { const T &v = *(T *)d; insert(i, v); }
- virtual void at(int i, void *p) const { const T &v = at(i); *((T*)p) = v; }
+struct QmlListProperty {
+ typedef void (*AppendFunction)(QmlListProperty<T> *, T*);
+ typedef int (*CountFunction)(QmlListProperty<T> *);
+ typedef T *(*AtFunction)(QmlListProperty<T> *, int);
+ typedef void (*ClearFunction)(QmlListProperty<T> *);
+
+ QmlListProperty()
+ : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {}
+ QmlListProperty(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) {}
+ QmlListProperty(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 QmlListProperty &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(QmlListProperty *p, T *v) {
+ ((QList<T *> *)p->data)->append(v);
+ }
+ static int qlist_count(QmlListProperty *p) {
+ return ((QList<T *> *)p->data)->count();
+ }
+ static T *qlist_at(QmlListProperty *p, int idx) {
+ return ((QList<T *> *)p->data)->at(idx);
+ }
+ static void qlist_clear(QmlListProperty *p) {
+ return ((QList<T *> *)p->data)->clear();
+ }
};
-template<typename T>
-class QmlConcreteList : public QList<T>, public QmlList<T>
+class QmlEngine;
+class QmlListReferencePrivate;
+class Q_DECLARATIVE_EXPORT QmlListReference
{
public:
- virtual void append(T v) { QList<T>::append(v); }
- virtual void insert(int i, T v) { QList<T>::insert(i, v); }
- virtual void clear() { QList<T>::clear(); }
- virtual T at(int i) const { return QList<T>::at(i); }
- virtual void removeAt(int i) { QList<T>::removeAt(i); }
- virtual int count() const { return QList<T>::count(); }
-};
+ QmlListReference();
+ QmlListReference(QObject *, const char *property, QmlEngine * = 0);
+ QmlListReference(const QmlListReference &);
+ QmlListReference &operator=(const QmlListReference &);
+ ~QmlListReference();
+
+ bool isValid() const;
-#define QML_DECLARE_LIST_PROXY(ClassName, ListType, ListName) \
-class Qml_ProxyList_ ##ListName : public QmlList<ListType> \
-{ \
- public: \
- virtual void removeAt(int idx) \
- { \
- ClassName *p = (ClassName *)((char *)this + ((char *)(ClassName *)(0x10000000) - (char *)&((ClassName *)(0x10000000))->ListName)); \
- p->ListName ## _removeAt(idx); \
- } \
- virtual int count() const \
- { \
- ClassName *p = (ClassName *)((char *)this + ((char *)(ClassName *)(0x10000000) - (char *)&((ClassName *)(0x10000000))->ListName)); \
- return p->ListName ## _count(); \
- } \
- virtual void append(ListType v) \
- { \
- ClassName *p = (ClassName *)((char *)this + ((char *)(ClassName *)(0x10000000) - (char *)&((ClassName *)(0x10000000))->ListName)); \
- p->ListName ## _append(v); \
- } \
- virtual void insert(int idx, ListType v) \
- { \
- ClassName *p = (ClassName *)((char *)this + ((char *)(ClassName *)(0x10000000) - (char *)&((ClassName *)(0x10000000))->ListName)); \
- p->ListName ## _insert(idx, v); \
- } \
- virtual ListType at(int idx) const \
- { \
- ClassName *p = (ClassName *)((char *)this + ((char *)(ClassName *)(0x10000000) - (char *)&((ClassName *)(0x10000000))->ListName)); \
- return p->ListName ## _at(idx); \
- } \
- virtual void clear() \
- { \
- ClassName *p = (ClassName *)((char *)this + ((char *)(ClassName *)(0x10000000) - (char *)&((ClassName *)(0x10000000))->ListName)); \
- p->ListName ## _clear(); \
- } \
-}; \
-friend class Qml_ProxyList_ ##ListName ; \
-Qml_ProxyList_##ListName ListName;
+ 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 QmlListReferencePrivate;
+ QmlListReferencePrivate* d;
+};
+Q_DECLARE_METATYPE(QmlListReference);
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmllist_p.h b/src/declarative/qml/qmllist_p.h
new file mode 100644
index 0000000..4660e47
--- /dev/null
+++ b/src/declarative/qml/qmllist_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLLIST_P_H
+#define QMLLIST_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 "qmllist.h"
+#include "qmlguard_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QmlListReferencePrivate
+{
+public:
+ QmlListReferencePrivate();
+
+ static QmlListReference init(const QmlListProperty<QObject> &, int, QmlEngine *);
+
+ QmlGuard<QObject> object;
+ const QMetaObject *elementType;
+ QmlListProperty<QObject> property;
+ int propertyType;
+
+ void addref();
+ void release();
+ int refCount;
+
+ static inline QmlListReferencePrivate *get(QmlListReference *ref) {
+ return ref->d;
+ }
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QMLLIST_P_H
diff --git a/src/declarative/qml/qmllistscriptclass.cpp b/src/declarative/qml/qmllistscriptclass.cpp
index d74a9b0..bb29763 100644
--- a/src/declarative/qml/qmllistscriptclass.cpp
+++ b/src/declarative/qml/qmllistscriptclass.cpp
@@ -43,13 +43,13 @@
#include "qmlengine_p.h"
#include "qmlguard_p.h"
+#include "qmllist_p.h"
QT_BEGIN_NAMESPACE
struct ListData : public QScriptDeclarativeClass::Object {
QmlGuard<QObject> object;
- int propertyIdx;
- QmlListScriptClass::ListCategory type;
+ QmlListProperty<QObject> property;
int propertyType;
};
@@ -66,7 +66,7 @@ QmlListScriptClass::~QmlListScriptClass()
{
}
-QScriptValue QmlListScriptClass::newList(QObject *object, int propId, ListCategory type, int propType)
+QScriptValue QmlListScriptClass::newList(QObject *object, int propId, int propType)
{
QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
@@ -75,8 +75,20 @@ QScriptValue QmlListScriptClass::newList(QObject *object, int propId, ListCatego
ListData *data = new ListData;
data->object = object;
- data->propertyIdx = propId;
- data->type = type;
+ data->propertyType = propType;
+ void *args[] = { &data->property, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, propId, args);
+
+ return newObject(scriptEngine, this, data);
+}
+
+QScriptValue QmlListScriptClass::newList(const QmlListProperty<QObject> &prop, int propType)
+{
+ QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
+
+ ListData *data = new ListData;
+ data->object = prop.object;
+ data->property = prop;
data->propertyType = propType;
return newObject(scriptEngine, this, data);
@@ -111,39 +123,14 @@ QmlListScriptClass::ScriptValue QmlListScriptClass::property(Object *obj, const
if (!data->object)
return Value();
- void *list = 0;
- void *args[] = { &list, 0 };
- QMetaObject::metacall(data->object, QMetaObject::ReadProperty,
- data->propertyIdx, args);
+ quint32 count = data->property.count?data->property.count(&data->property):0;
- if (!list)
+ if (name == m_lengthId.identifier)
+ return Value(scriptEngine, count);
+ else if (lastIndex < count && data->property.at)
+ return Value(scriptEngine, enginePriv->objectClass->newQObject(data->property.at(&data->property, lastIndex)));
+ else
return Value();
-
- if (data->type == QListPtr) {
- const QList<QObject *> &qlist = *((QList<QObject *>*)list);
-
- quint32 count = qlist.count();
-
- if (name == m_lengthId.identifier)
- return Value(scriptEngine, count);
- else if (lastIndex < count)
- return Value(scriptEngine, enginePriv->objectClass->newQObject(qlist.at(lastIndex)));
- else
- return Value();
-
- } else {
- Q_ASSERT(data->type == QmlListPtr);
- const QmlList<QObject *> &qmllist = *((QmlList<QObject *>*)list);
-
- quint32 count = qmllist.count();
-
- if (name == m_lengthId.identifier)
- return Value(scriptEngine, count);
- else if (lastIndex < count)
- return Value(scriptEngine, enginePriv->objectClass->newQObject(qmllist.at(lastIndex)));
- else
- return Value();
- }
}
QVariant QmlListScriptClass::toVariant(Object *obj, bool *ok)
@@ -155,18 +142,7 @@ QVariant QmlListScriptClass::toVariant(Object *obj, bool *ok)
return QVariant();
}
- void *list = 0;
- void *args[] = { &list, 0 };
- QMetaObject::metacall(data->object, QMetaObject::ReadProperty,
- data->propertyIdx, args);
-
- if (!list) {
- if (ok) *ok = false;
- return QVariant();
- }
-
- if (ok) *ok = true;
- return QVariant(data->propertyType, &list);
+ return QVariant::fromValue(QmlListReferencePrivate::init(data->property, data->propertyType, engine));
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmllistscriptclass_p.h b/src/declarative/qml/qmllistscriptclass_p.h
index 92cf17f..07b09c3 100644
--- a/src/declarative/qml/qmllistscriptclass_p.h
+++ b/src/declarative/qml/qmllistscriptclass_p.h
@@ -54,6 +54,7 @@
//
#include <private/qmlscriptclass_p.h>
+#include "qmllist.h"
QT_BEGIN_NAMESPACE
@@ -64,8 +65,8 @@ public:
QmlListScriptClass(QmlEngine *);
~QmlListScriptClass();
- enum ListCategory { QListPtr, QmlListPtr };
- QScriptValue newList(QObject *, int, ListCategory, int);
+ QScriptValue newList(QObject *, int, int);
+ QScriptValue newList(const QmlListProperty<QObject> &, int);
protected:
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index d7d4a07..7c273dc 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -52,16 +52,13 @@
#include "qmlengine_p.h"
#include "qmldeclarativedata_p.h"
#include "qmlstringconverters_p.h"
-
-#include <qfxperf_p_p.h>
+#include "qmllist_p.h"
#include <QStringList>
#include <QtCore/qdebug.h>
#include <math.h>
-Q_DECLARE_METATYPE(QList<QObject *>);
-
QT_BEGIN_NAMESPACE
/*!
@@ -213,7 +210,6 @@ QmlMetaProperty::QmlMetaProperty(const QmlMetaProperty &other)
\value InvalidProperty The property is invalid.
\value Bindable The property is a QmlBinding.
\value List The property is a QList pointer
- \value QmlList The property is a QmlList pointer
\value Object The property is a QObject derived type pointer
\value Normal The property is none of the above.
*/
@@ -257,8 +253,6 @@ QmlMetaPropertyPrivate::propertyCategory() const
return QmlMetaProperty::Bindable;
else if (core.flags & QmlPropertyCache::Data::IsQObjectDerived)
return QmlMetaProperty::Object;
- else if (core.flags & QmlPropertyCache::Data::IsQmlList)
- return QmlMetaProperty::QmlList;
else if (core.flags & QmlPropertyCache::Data::IsQList)
return QmlMetaProperty::List;
else
@@ -401,7 +395,7 @@ bool QmlMetaProperty::isWritable() const
if (!d->object)
return false;
- if (category == List || category == QmlList)
+ if (category == List)
return true;
else if (type() & SignalProperty)
return false;
@@ -703,6 +697,13 @@ QVariant QmlMetaPropertyPrivate::readValueProperty()
if (!ep) delete valueType;
return rv;
+ } else if(core.flags & QmlPropertyCache::Data::IsQList) {
+
+ QmlListProperty<QObject> prop;
+ void *args[] = { &prop, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
+ return QVariant::fromValue(QmlListReferencePrivate::init(prop, core.propType, context?context->engine():0));
+
} else {
return object->metaObject()->property(core.coreIndex).read(object.data());
@@ -813,9 +814,7 @@ bool QmlMetaPropertyPrivate::write(QObject *object, const QmlPropertyCache::Data
int t = property.propType;
int vt = value.userType();
- QmlEnginePrivate *enginePriv = 0;
- if (context && context->engine())
- enginePriv = QmlEnginePrivate::get(context->engine());
+ QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(context);
if (t == QVariant::Url) {
@@ -880,55 +879,40 @@ bool QmlMetaPropertyPrivate::write(QObject *object, const QmlPropertyCache::Data
} else if (property.flags & QmlPropertyCache::Data::IsQList) {
- int listType = QmlMetaType::listType(t);
- QMetaProperty prop = object->metaObject()->property(property.coreIndex);
-
- if (value.userType() == qMetaTypeId<QList<QObject *> >()) {
- const QList<QObject *> &list =
- qvariant_cast<QList<QObject *> >(value);
- QVariant listVar = prop.read(object);
- QmlMetaType::clear(listVar);
- for (int ii = 0; ii < list.count(); ++ii) {
- QVariant v = QmlMetaType::qmlType(listType)->fromObject(list.at(ii));
- QmlMetaType::append(listVar, v);
- }
-
- } else if (vt == listType ||
- value.userType() == listType) {
- QVariant listVar = prop.read(object);
- QmlMetaType::append(listVar, value);
+ const QMetaObject *listType = 0;
+ if (enginePriv) {
+ listType = enginePriv->rawMetaObjectForType(enginePriv->listType(property.propType));
+ } else {
+ QmlType *type = QmlMetaType::qmlType(QmlMetaType::listType(property.propType));
+ if (!type) return false;
+ listType = type->baseMetaObject();
}
+ if (!listType) return false;
- } else if (property.flags & QmlPropertyCache::Data::IsQmlList) {
+ QmlListProperty<void> prop;
+ void *args[] = { &prop, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, coreIdx, args);
- // XXX - optimize!
- QMetaProperty prop = object->metaObject()->property(property.coreIndex);
- QVariant list = prop.read(object);
- QmlPrivate::ListInterface *li =
- *(QmlPrivate::ListInterface **)list.constData();
-
- int type = li->type();
-
- if (QObject *obj = QmlMetaType::toQObject(value)) {
- const QMetaObject *mo = rawMetaObjectForType(enginePriv, type);
-
- const QMetaObject *objMo = obj->metaObject();
- bool found = false;
- while(!found && objMo) {
- if (equal(objMo, mo))
- found = true;
- else
- objMo = objMo->superClass();
- }
+ if (!prop.clear) return false;
- if (!found)
- return false;
+ prop.clear(&prop);
+
+ if (value.userType() == qMetaTypeId<QList<QObject *> >()) {
+ const QList<QObject *> &list = qvariant_cast<QList<QObject *> >(value);
- // NOTE: This assumes a cast to QObject does not alter
- // the object pointer
- void *d = (void *)&obj;
- li->append(d);
+ for (int ii = 0; ii < list.count(); ++ii) {
+ QObject *o = list.at(ii);
+ if (!canConvert(o->metaObject(), listType))
+ o = 0;
+ prop.append(&prop, (void *)o);
+ }
+ } else {
+ QObject *o = enginePriv?enginePriv->toQObject(value):QmlMetaType::toQObject(value);
+ if (!canConvert(o->metaObject(), listType))
+ o = 0;
+ prop.append(&prop, (void *)o);
}
+
} else {
Q_ASSERT(vt != t);
diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h
index 723fc50..82266c8 100644
--- a/src/declarative/qml/qmlmetaproperty.h
+++ b/src/declarative/qml/qmlmetaproperty.h
@@ -68,7 +68,6 @@ public:
InvalidProperty,
Bindable,
List,
- QmlList, //XXX
Object,
Normal
};
diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp
index b94a815..6db70d4 100644
--- a/src/declarative/qml/qmlmetatype.cpp
+++ b/src/declarative/qml/qmlmetatype.cpp
@@ -100,7 +100,6 @@ struct QmlMetaTypeData
QBitArray objects;
QBitArray interfaces;
- QBitArray qmllists;
QBitArray lists;
};
Q_GLOBAL_STATIC(QmlMetaTypeData, metaTypeData)
@@ -124,8 +123,8 @@ public:
QByteArray m_name;
int m_version_maj;
int m_version_min;
- int m_typeId; int m_listId; int m_qmlListId;
- QmlPrivate::Func m_opFunc;
+ int m_typeId; int m_listId;
+ QObject *(*m_newFunc)();
const QMetaObject *m_baseMetaObject;
QmlAttachedPropertiesFunc m_attachedPropertiesFunc;
const QMetaObject *m_attachedPropertiesType;
@@ -141,32 +140,30 @@ public:
};
QmlTypePrivate::QmlTypePrivate()
-: m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0), m_qmlListId(0),
- m_opFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0), m_attachedPropertiesType(0),
+: m_isInterface(false), m_iid(0), m_typeId(0), m_listId(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)
{
}
-QmlType::QmlType(int type, int listType, int qmlListType,
- QmlPrivate::Func opFunc, const char *iid, int index)
+QmlType::QmlType(int type, int listType, const char *iid, int index)
: d(new QmlTypePrivate)
{
d->m_isInterface = true;
d->m_iid = iid;
d->m_typeId = type;
d->m_listId = listType;
- d->m_qmlListId = qmlListType;
- d->m_opFunc = opFunc;
+ d->m_newFunc = 0;
d->m_index = index;
d->m_isSetup = true;
d->m_version_maj = 0;
d->m_version_min = 0;
}
-QmlType::QmlType(int type, int listType, int qmlListType,
- QmlPrivate::Func opFunc, const char *qmlName,
+QmlType::QmlType(int type, int listType,
+ QObject *(*newFunc)(), const char *qmlName,
int version_maj, int version_min,
const QMetaObject *metaObject,
QmlAttachedPropertiesFunc attachedPropertiesFunc,
@@ -182,8 +179,7 @@ QmlType::QmlType(int type, int listType, int qmlListType,
d->m_version_min = version_min;
d->m_typeId = type;
d->m_listId = listType;
- d->m_qmlListId = qmlListType;
- d->m_opFunc = opFunc;
+ d->m_newFunc = newFunc;
d->m_baseMetaObject = metaObject;
d->m_attachedPropertiesFunc = attachedPropertiesFunc;
d->m_attachedPropertiesType = attachedType;
@@ -283,10 +279,7 @@ QObject *QmlType::create() const
{
d->init();
- QVariant v;
- QObject *rv = 0;
- d->m_opFunc(QmlPrivate::Create, 0, v, v, (void **)&rv);
-
+ QObject *rv = d->m_newFunc();
if (rv && !d->m_metaObjects.isEmpty())
(void *)new QmlProxyMetaObject(rv, &d->m_metaObjects);
@@ -313,39 +306,6 @@ int QmlType::qListTypeId() const
return d->m_listId;
}
-int QmlType::qmlListTypeId() const
-{
- return d->m_qmlListId;
-}
-
-void QmlType::listClear(const QVariant &list)
-{
- Q_ASSERT(list.userType() == qListTypeId());
- QVariant arg;
- d->m_opFunc(QmlPrivate::Clear, 0, list, arg, 0);
-}
-
-void QmlType::listAppend(const QVariant &list, const QVariant &item)
-{
- Q_ASSERT(list.userType() == qListTypeId());
- d->m_opFunc(QmlPrivate::Append, 0, list, item, 0);
-}
-
-QVariant QmlType::listAt(const QVariant &list, int idx)
-{
- Q_ASSERT(list.userType() == qListTypeId());
- QVariant rv;
- void *ptr = (void *)&rv;
- d->m_opFunc(QmlPrivate::Value, idx, list, QVariant(), &ptr);
- return rv;
-}
-
-int QmlType::listCount(const QVariant &list)
-{
- Q_ASSERT(list.userType() == qListTypeId());
- return d->m_opFunc(QmlPrivate::Length, 0, list, QVariant(), 0);
-}
-
const QMetaObject *QmlType::metaObject() const
{
d->init();
@@ -387,15 +347,6 @@ int QmlType::propertyValueInterceptorCast() const
return d->m_propertyValueInterceptorCast;
}
-QVariant QmlType::fromObject(QObject *obj) const
-{
- QVariant rv;
- QVariant *v_ptr = &rv;
- QVariant vobj = QVariant::fromValue(obj);
- d->m_opFunc(QmlPrivate::FromObject, 0, QVariant(), vobj, (void **)&v_ptr);
- return rv;
-}
-
const char *QmlType::interfaceIId() const
{
return d->m_iid;
@@ -407,7 +358,6 @@ int QmlType::index() const
}
int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id,
- QmlPrivate::Func listFunction,
const char *iid)
{
QWriteLocker lock(metaTypeDataLock());
@@ -415,31 +365,26 @@ int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id,
int index = data->types.count();
- QmlType *type = new QmlType(id.typeId, id.listId, id.qmlListId,
- listFunction, iid, index);
+ QmlType *type = new QmlType(id.typeId, id.listId, iid, index);
data->types.append(type);
data->idToType.insert(type->typeId(), type);
data->idToType.insert(type->qListTypeId(), type);
- data->idToType.insert(type->qmlListTypeId(), type);
// XXX No insertMulti, so no multi-version interfaces?
if (!type->qmlTypeName().isEmpty())
data->nameToType.insert(type->qmlTypeName(), type);
- if (data->interfaces.size() < id.typeId)
+ if (data->interfaces.size() <= id.typeId)
data->interfaces.resize(id.typeId + 16);
- if (data->qmllists.size() < id.qmlListId)
- data->qmllists.resize(id.qmlListId + 16);
- if (data->lists.size() < id.listId)
+ if (data->lists.size() <= id.listId)
data->lists.resize(id.listId + 16);
data->interfaces.setBit(id.typeId, true);
- data->qmllists.setBit(id.qmlListId, true);
data->lists.setBit(id.listId, true);
return index;
}
-int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Func func,
+int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QObject *(*func)(),
const char *uri, int version_maj, int version_min, const char *cname,
const QMetaObject *mo, QmlAttachedPropertiesFunc attach, const QMetaObject *attachMo,
int pStatus, int object, int valueSource, int valueInterceptor, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *parser)
@@ -464,14 +409,13 @@ int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Fun
name += '/';
name += cname;
- QmlType *type = new QmlType(id.typeId, id.listId, id.qmlListId,
+ QmlType *type = new QmlType(id.typeId, id.listId,
func, name, version_maj, version_min, mo, attach, attachMo, pStatus,
valueSource, valueInterceptor, extFunc, extmo, index, parser);
data->types.append(type);
data->idToType.insert(type->typeId(), type);
data->idToType.insert(type->qListTypeId(), type);
- data->idToType.insert(type->qmlListTypeId(), type);
if (!type->qmlTypeName().isEmpty())
data->nameToType.insertMulti(type->qmlTypeName(), type);
@@ -480,12 +424,9 @@ int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Fun
if (data->objects.size() <= id.typeId)
data->objects.resize(id.typeId + 16);
- if (data->qmllists.size() <= id.qmlListId)
- data->qmllists.resize(id.qmlListId + 16);
if (data->lists.size() <= id.listId)
data->lists.resize(id.listId + 16);
data->objects.setBit(id.typeId, true);
- data->qmllists.setBit(id.qmlListId, true);
data->lists.setBit(id.listId, true);
return index;
@@ -527,51 +468,6 @@ int QmlMetaType::listType(int id)
return 0;
}
-/*
- Returns the item type for a qml list of type \a id.
- */
-int QmlMetaType::qmlListType(int id)
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- QmlType *type = data->idToType.value(id);
- if (type && type->qmlListTypeId() == id)
- return type->typeId();
- else
- return 0;
-}
-
-bool QmlMetaType::clear(const QVariant &list)
-{
- int userType = list.userType();
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- QmlType *type = data->idToType.value(userType);
- lock.unlock();
- if (type && type->qListTypeId() == userType) {
- type->listClear(list);
- return true;
- } else {
- return false;
- }
-}
-
-bool QmlMetaType::append(const QVariant &list, const QVariant &item)
-{
- int userType = list.userType();
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- QmlType *type = data->idToType.value(userType);
- lock.unlock();
- if (type && type->qListTypeId() == userType &&
- item.userType() == type->typeId()) {
- type->listAppend(list, item);
- return true;
- } else {
- return false;
- }
-}
-
int QmlMetaType::attachedPropertiesFuncId(const QMetaObject *mo)
{
QReadLocker lock(metaTypeDataLock());
@@ -656,8 +552,6 @@ QmlMetaType::TypeCategory QmlMetaType::typeCategory(int userType)
QmlMetaTypeData *data = metaTypeData();
if (userType < data->objects.size() && data->objects.testBit(userType))
return Object;
- else if (userType < data->qmllists.size() && data->qmllists.testBit(userType))
- return QmlList;
else if (userType < data->lists.size() && data->lists.testBit(userType))
return List;
else
@@ -683,13 +577,6 @@ const char *QmlMetaType::interfaceIId(int userType)
return 0;
}
-bool QmlMetaType::isQmlList(int userType)
-{
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- return userType >= 0 && userType < data->qmllists.size() && data->qmllists.testBit(userType);
-}
-
bool QmlMetaType::isList(int userType)
{
QReadLocker lock(metaTypeDataLock());
@@ -697,44 +584,6 @@ bool QmlMetaType::isList(int userType)
return userType >= 0 && userType < data->lists.size() && data->lists.testBit(userType);
}
-bool QmlMetaType::isList(const QVariant &v)
-{
- return (v.type() == QVariant::UserType && isList(v.userType()));
-}
-
-int QmlMetaType::listCount(const QVariant &v)
-{
- int userType = v.userType();
-
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- QmlType *type = data->idToType.value(userType);
- lock.unlock();
-
- if (type && type->qListTypeId() == userType)
- return type->listCount(v);
- else
- return 0;
-}
-
-QVariant QmlMetaType::listAt(const QVariant &v, int idx)
-{
- if (idx < 0)
- return QVariant();
-
- int userType = v.userType();
-
- QReadLocker lock(metaTypeDataLock());
- QmlMetaTypeData *data = metaTypeData();
- QmlType *type = data->idToType.value(userType);
- lock.unlock();
-
- if (type && type->qListTypeId() == userType)
- return type->listAt(v, idx);
- else
- return QVariant();
-}
-
/*!
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
diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h
index 3d082f8..98d04c1 100644
--- a/src/declarative/qml/qmlmetatype.h
+++ b/src/declarative/qml/qmlmetatype.h
@@ -46,6 +46,7 @@
#include "qmlparserstatus.h"
#include "qmlpropertyvaluesource.h"
#include "qmlpropertyvalueinterceptor.h"
+#include "qmllist.h"
#include <QtCore/qglobal.h>
#include <QtCore/qvariant.h>
@@ -62,8 +63,8 @@ class QmlCustomParser;
class Q_DECLARATIVE_EXPORT QmlMetaType
{
public:
- static int registerType(const QmlPrivate::MetaTypeIds &, QmlPrivate::Func, const char *, int vmaj, int vmin, const char *qmlName, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int pStatus, int object, int valueSource, int valueInterceptor, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *);
- static int registerInterface(const QmlPrivate::MetaTypeIds &, QmlPrivate::Func, const char *);
+ static int registerType(const QmlPrivate::MetaTypeIds &, QObject *(*)(), const char *, int vmaj, int vmin, const char *qmlName, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int pStatus, int object, int valueSource, int valueInterceptor, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *);
+ static int registerInterface(const QmlPrivate::MetaTypeIds &, const char *);
static bool copy(int type, void *data, const void *copy = 0);
@@ -83,22 +84,15 @@ public:
static QObject *toQObject(const QVariant &, bool *ok = 0);
static int listType(int);
- static bool clear(const QVariant &);
- static bool append(const QVariant &, const QVariant &);
static int attachedPropertiesFuncId(const QMetaObject *);
static QmlAttachedPropertiesFunc attachedPropertiesFuncById(int);
- enum TypeCategory { Unknown, Object, List, QmlList };
+ enum TypeCategory { Unknown, Object, List };
static TypeCategory typeCategory(int);
static bool isInterface(int);
static const char *interfaceIId(int);
static bool isList(int);
- static bool isList(const QVariant &);
- static bool isQmlList(int);
- static int qmlListType(int);
- static int listCount(const QVariant &);
- static QVariant listAt(const QVariant &, int);
typedef QVariant (*StringConverter)(const QString &);
static void registerCustomStringConverter(int, StringConverter);
@@ -123,12 +117,6 @@ public:
bool isInterface() const;
int typeId() const;
int qListTypeId() const;
- int qmlListTypeId() const;
-
- void listClear(const QVariant &);
- void listAppend(const QVariant &, const QVariant &);
- QVariant listAt(const QVariant &, int);
- int listCount(const QVariant &);
const QMetaObject *metaObject() const;
const QMetaObject *baseMetaObject() const;
@@ -147,8 +135,8 @@ private:
friend class QmlMetaType;
friend class QmlTypePrivate;
friend struct QmlMetaTypeData;
- QmlType(int, int, int, QmlPrivate::Func, const char *, int);
- QmlType(int, int, int, QmlPrivate::Func, const char *, int, int, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int, int, int, QmlPrivate::CreateFunc, const QMetaObject *, int, QmlCustomParser *);
+ QmlType(int, int, const char *, int);
+ QmlType(int, int, QObject *(*)(), const char *, int, int, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int, int, int, QmlPrivate::CreateFunc, const QMetaObject *, int, QmlCustomParser *);
~QmlType();
QmlTypePrivate *d;
@@ -160,11 +148,10 @@ int qmlRegisterType(const char *typeName)
QByteArray name(typeName);
QmlPrivate::MetaTypeIds ids = {
qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<T *>(QByteArray("QList<" + name + "*>*").constData()),
- qRegisterMetaType<T *>(QByteArray("QmlList<" + name + "*>*").constData())
+ qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
};
- return QmlMetaType::registerType(ids, QmlPrivate::list_nocreate_op<T>, 0, 0, 0, 0,
+ return QmlMetaType::registerType(ids, 0, 0, 0, 0, 0,
&T::staticMetaObject,
QmlPrivate::attachedPropertiesFunc<T>(),
QmlPrivate::attachedPropertiesMetaObject<T>(),
@@ -181,11 +168,10 @@ int qmlRegisterType(const char *uri, int version_maj, int version_min, const cha
QByteArray name(typeName);
QmlPrivate::MetaTypeIds ids = {
qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<T *>(QByteArray("QList<" + name + "*>*").constData()),
- qRegisterMetaType<T *>(QByteArray("QmlList<" + name + "*>*").constData())
+ qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
};
- return QmlMetaType::registerType(ids, QmlPrivate::list_op<T>,
+ return QmlMetaType::registerType(ids, QmlPrivate::create<T>,
uri, version_maj, version_min, qmlName,
&T::staticMetaObject,
QmlPrivate::attachedPropertiesFunc<T>(),
@@ -203,8 +189,7 @@ int qmlRegisterExtendedType(const char *typeName)
QByteArray name(typeName);
QmlPrivate::MetaTypeIds ids = {
qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<T *>(QByteArray("QList<" + name + "*>*").constData()),
- qRegisterMetaType<T *>(QByteArray("QmlList<" + name + "*>*").constData())
+ qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
};
QmlAttachedPropertiesFunc attached =
@@ -216,7 +201,7 @@ int qmlRegisterExtendedType(const char *typeName)
attachedMo = QmlPrivate::attachedPropertiesMetaObject<T>();
}
- return QmlMetaType::registerType(ids, QmlPrivate::list_nocreate_op<T>, 0, 0, 0, 0,
+ return QmlMetaType::registerType(ids, 0, 0, 0, 0, 0,
&T::staticMetaObject, attached, attachedMo,
QmlPrivate::StaticCastSelector<T,QmlParserStatus>::cast(),
QmlPrivate::StaticCastSelector<T,QObject>::cast(),
@@ -231,8 +216,7 @@ int qmlRegisterExtendedType(const char *uri, int version_maj, int version_min, c
QByteArray name(typeName);
QmlPrivate::MetaTypeIds ids = {
qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<T *>(QByteArray("QList<" + name + "*>*").constData()),
- qRegisterMetaType<T *>(QByteArray("QmlList<" + name + "*>*").constData())
+ qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
};
QmlAttachedPropertiesFunc attached =
@@ -244,7 +228,7 @@ int qmlRegisterExtendedType(const char *uri, int version_maj, int version_min, c
attachedMo = QmlPrivate::attachedPropertiesMetaObject<T>();
}
- return QmlMetaType::registerType(ids, QmlPrivate::list_op<T>,
+ return QmlMetaType::registerType(ids, QmlPrivate::create<T>,
uri, version_maj, version_min, qmlName,
&T::staticMetaObject,
attached, attachedMo,
@@ -262,13 +246,10 @@ int qmlRegisterInterface(const char *typeName)
QByteArray name(typeName);
QmlPrivate::MetaTypeIds ids = {
qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<T *>(QByteArray("QList<" + name + "*>*").constData()),
- qRegisterMetaType<T *>(QByteArray("QmlList<" + name + "*>*").constData())
+ qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
};
- return QmlMetaType::registerInterface(ids,
- QmlPrivate::list_interface_op<T>,
- qobject_interface_iid<T *>());
+ return QmlMetaType::registerInterface(ids, qobject_interface_iid<T *>());
}
template<typename T>
@@ -277,11 +258,10 @@ int qmlRegisterCustomType(const char *uri, int version_maj, int version_min, con
QByteArray name(typeName);
QmlPrivate::MetaTypeIds ids = {
qRegisterMetaType<T *>(QByteArray(name + '*').constData()),
- qRegisterMetaType<T *>(QByteArray("QList<" + name + "*>*").constData()),
- qRegisterMetaType<T *>(QByteArray("QmlList<" + name + "*>*").constData())
+ qRegisterMetaType<QmlListProperty<T> >(QByteArray("QmlListProperty<" + name + ">").constData()),
};
- return QmlMetaType::registerType(ids, QmlPrivate::list_op<T>,
+ return QmlMetaType::registerType(ids, QmlPrivate::create<T>,
uri, version_maj, version_min, qmlName,
&T::staticMetaObject,
QmlPrivate::attachedPropertiesFunc<T>(),
diff --git a/src/declarative/qml/qmlmoduleplugin.cpp b/src/declarative/qml/qmlmoduleplugin.cpp
index 8019805..342074a 100644
--- a/src/declarative/qml/qmlmoduleplugin.cpp
+++ b/src/declarative/qml/qmlmoduleplugin.cpp
@@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QmlModulePlugin
+ \since 4.7
\brief The QmlModulePlugin class provides an abstract base for custom QML module plugins.
\reentrant
\ingroup plugins
diff --git a/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp b/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp
index 1ba0694..455d09e 100644
--- a/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp
+++ b/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp
@@ -45,6 +45,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QmlNetworkAccessManagerFactory
+ \since 4.7
\brief The QmlNetworkAccessManagerFactory class provides a factory for QNetworkAccessManager
QNetworkAccessManager is used for all network access by QML.
diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp
index 76d1837..15ece1d 100644
--- a/src/declarative/qml/qmlobjectscriptclass.cpp
+++ b/src/declarative/qml/qmlobjectscriptclass.cpp
@@ -239,9 +239,7 @@ QmlObjectScriptClass::property(QObject *obj, const Identifier &name)
}
if (lastData->flags & QmlPropertyCache::Data::IsQList) {
- return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, QmlListScriptClass::QListPtr, lastData->propType));
- } else if (lastData->flags & QmlPropertyCache::Data::IsQmlList) {
- return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, QmlListScriptClass::QmlListPtr, lastData->propType));
+ return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, lastData->propType));
} else if (lastData->flags & QmlPropertyCache::Data::IsQObjectDerived) {
QObject *rv = 0;
void *args[] = { &rv, 0 };
diff --git a/src/declarative/qml/qmlparserstatus.cpp b/src/declarative/qml/qmlparserstatus.cpp
index 435d620..315bc75 100644
--- a/src/declarative/qml/qmlparserstatus.cpp
+++ b/src/declarative/qml/qmlparserstatus.cpp
@@ -45,6 +45,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QmlParserStatus
+ \since 4.7
\brief The QmlParserStatus class provides updates on the parser state.
*/
diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h
index e087788..e5ea07f 100644
--- a/src/declarative/qml/qmlprivate.h
+++ b/src/declarative/qml/qmlprivate.h
@@ -72,39 +72,8 @@ public:
namespace QmlPrivate
{
- class ListInterface
- {
- public:
- virtual ~ListInterface() {}
- virtual int type() const = 0;
- virtual void append(void *) = 0;
- virtual void insert(int, void *) = 0;
- virtual void removeAt(int) = 0;
- virtual void at(int, void *) const = 0;
- virtual int count() const = 0;
- virtual void clear() = 0;
- };
-
- enum ListOp { Append, Set, Insert, Prepend, Length, FromObject,
- Object, Create, Value, Clear };
-
template<typename T>
- int list_op(ListOp op, int val,
- const QVariant &vlist,
- const QVariant &value,
- void **out);
-
- template<typename T>
- int list_nocreate_op(ListOp op, int val,
- const QVariant &vlist,
- const QVariant &value,
- void **out);
-
- template<typename T>
- int list_interface_op(ListOp op, int val,
- const QVariant &vlist,
- const QVariant &value,
- void **out);
+ QObject *create() { return new T; }
template<class From, class To, int N>
struct StaticCastSelectorClass
@@ -201,9 +170,7 @@ namespace QmlPrivate
struct MetaTypeIds {
int typeId;
int listId;
- int qmlListId;
};
- typedef int (*Func)(QmlPrivate::ListOp, int, const QVariant &, const QVariant &, void **);
typedef QObject *(*CreateFunc)(QObject *);
template<typename T>
@@ -237,148 +204,6 @@ namespace QmlPrivate
};
}
-template<typename T>
-int QmlPrivate::list_op(QmlPrivate::ListOp op, int val,
- const QVariant &vlist,
- const QVariant &value,
- void **out)
-{
- if (op == QmlPrivate::Create) {
- QObject *obj = static_cast<QObject *>(new T);
- *((QObject **)out) = obj;
- return 0;
- }
- QList<T *> *list = vlist.value<QList<T *> *>();
- switch(op) {
- case QmlPrivate::Append:
- list->append(value.value<T *>());
- break;
- case QmlPrivate::Set:
- (*list)[val] = value.value<T *>();
- break;
- case QmlPrivate::Insert:
- list->insert(val, value.value<T *>());
- break;
- case QmlPrivate::Prepend:
- list->prepend(value.value<T *>());
- break;
- case QmlPrivate::Length:
- return list->count();
- break;
- case QmlPrivate::Clear:
- list->clear();
- return 0;
- break;
- case QmlPrivate::Create:
- break;
- case QmlPrivate::Object:
- *out = static_cast<QObject *>(value.value<T *>());
- break;
- case QmlPrivate::FromObject:
- {
- QObject *fromObj = value.value<QObject *>();
- T *me = qobject_cast<T *>(fromObj);
- if (me) {
- *((QVariant *)*out) = QVariant::fromValue(me);
- }
- }
- break;
- case QmlPrivate::Value:
- if (list->count() <= val) *((QVariant *)*out) = QVariant();
- else *((QVariant *)*out) = QVariant::fromValue(list->at(val));
- break;
- }
- return 0;
-}
-
-template<typename T>
-int QmlPrivate::list_nocreate_op(QmlPrivate::ListOp op, int val,
- const QVariant &vlist,
- const QVariant &value,
- void **out)
-{
- QList<T *> *list = vlist.value<QList<T *> *>();
- switch(op) {
- case QmlPrivate::Append:
- list->append(value.value<T *>());
- break;
- case QmlPrivate::Set:
- (*list)[val] = value.value<T *>();
- break;
- case QmlPrivate::Insert:
- list->insert(val, value.value<T *>());
- break;
- case QmlPrivate::Prepend:
- list->prepend(value.value<T *>());
- break;
- case QmlPrivate::Length:
- return list->count();
- break;
- case QmlPrivate::Clear:
- list->clear();
- return 0;
- break;
- case QmlPrivate::Create:
- break;
- case QmlPrivate::Object:
- *out = static_cast<QObject *>(value.value<T *>());
- break;
- case QmlPrivate::FromObject:
- {
- QObject *fromObj = value.value<QObject *>();
- T *me = qobject_cast<T *>(fromObj);
- if (me) {
- *((QVariant *)*out) = QVariant::fromValue(me);
- }
- }
- break;
- case QmlPrivate::Value:
- *((QVariant *)*out) = QVariant::fromValue(list->at(val));
- break;
- }
- return 0;
-}
-
-template<typename T>
-int QmlPrivate::list_interface_op(QmlPrivate::ListOp op, int val,
- const QVariant &vlist,
- const QVariant &value,
- void **out)
-{
- QList<T *> *list = vlist.value<QList<T *> *>();
- switch(op) {
- case QmlPrivate::Append:
- list->append(value.value<T *>());
- break;
- case QmlPrivate::Set:
- (*list)[val] = value.value<T *>();
- break;
- case QmlPrivate::Insert:
- list->insert(val, value.value<T *>());
- break;
- case QmlPrivate::Prepend:
- list->prepend(value.value<T *>());
- break;
- case QmlPrivate::Length:
- return list->count();
- break;
- case QmlPrivate::Clear:
- list->clear();
- return 0;
- break;
- case QmlPrivate::Create:
- break;
- case QmlPrivate::Object:
- break;
- case QmlPrivate::FromObject:
- break;
- case QmlPrivate::Value:
- *((QVariant *)*out) = QVariant::fromValue(list->at(val));
- break;
- }
- return 0;
-}
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp
index e567fd2..a3e655b 100644
--- a/src/declarative/qml/qmlpropertycache.cpp
+++ b/src/declarative/qml/qmlpropertycache.cpp
@@ -77,8 +77,6 @@ void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine)
flags |= Data::IsQObjectDerived;
else if (cat == QmlMetaType::List)
flags |= Data::IsQList;
- else if (cat == QmlMetaType::QmlList)
- flags |= Data::IsQmlList;
}
}
diff --git a/src/declarative/qml/qmlpropertycache_p.h b/src/declarative/qml/qmlpropertycache_p.h
index 34b648d..18eea80 100644
--- a/src/declarative/qml/qmlpropertycache_p.h
+++ b/src/declarative/qml/qmlpropertycache_p.h
@@ -86,7 +86,6 @@ public:
IsFunction = 0x00000008,
IsQObjectDerived = 0x00000010,
IsEnumType = 0x00000020,
- IsQmlList = 0x00000040,
IsQList = 0x00000080,
IsQmlBinding = 0x00000100,
IsQScriptValue = 0x00000200,
diff --git a/src/declarative/qml/qmlscript.cpp b/src/declarative/qml/qmlscript.cpp
index c0320cd..ef142a5 100644
--- a/src/declarative/qml/qmlscript.cpp
+++ b/src/declarative/qml/qmlscript.cpp
@@ -58,7 +58,7 @@
console.log(otherinterestingitem.property);
}
}
- MouseRegion { onClicked: debugMyComponent() }
+ MouseArea { onClicked: debugMyComponent() }
\endqml
\note While it is possible to use any JavaScript code within a Script element,
diff --git a/src/declarative/qml/qmlscriptstring.cpp b/src/declarative/qml/qmlscriptstring.cpp
index 29118e6..a80f66b 100644
--- a/src/declarative/qml/qmlscriptstring.cpp
+++ b/src/declarative/qml/qmlscriptstring.cpp
@@ -55,6 +55,7 @@ public:
/*!
\class QmlScriptString
+ \since 4.7
\brief The QmlScriptString class encapsulates a script and its context.
The QmlScriptString is used by properties that want to accept a script "assignment" from QML.
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 39de062..8655809 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -91,15 +91,13 @@ QmlVME::QmlVME()
struct ListInstance
{
- ListInstance() {}
- ListInstance(QList<void *> *q, int t)
- : type(t), qListInterface(q), qmlListInterface(0) {}
- ListInstance(QmlPrivate::ListInterface *q, int t)
- : type(t), qListInterface(0), qmlListInterface(q) {}
+ ListInstance()
+ : type(0) {}
+ ListInstance(int t)
+ : type(t) {}
int type;
- QList<void *> *qListInterface;
- QmlPrivate::ListInterface *qmlListInterface;
+ QmlListProperty<void> qListProperty;
};
QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledData *comp,
@@ -654,22 +652,12 @@ QObject *QmlVME::run(QmlVMEStack<QObject *> &stack, QmlContext *ctxt,
}
break;
- case QmlInstruction::StoreObjectQmlList:
- {
- QObject *assign = stack.pop();
- const ListInstance &list = qliststack.top();
-
- void *d = (void *)&assign;
- list.qmlListInterface->append(d);
- }
- break;
-
case QmlInstruction::StoreObjectQList:
{
QObject *assign = stack.pop();
const ListInstance &list = qliststack.top();
- list.qListInterface->append((void *)assign);
+ list.qListProperty.append((QmlListProperty<void>*)&list.qListProperty, assign);
}
break;
@@ -690,12 +678,7 @@ QObject *QmlVME::run(QmlVMEStack<QObject *> &stack, QmlContext *ctxt,
VME_EXCEPTION(QCoreApplication::translate("QmlVME","Cannot assign object to list"));
- if (list.qmlListInterface) {
- void *d = (void *)&ptr;
- list.qmlListInterface->append(d);
- } else {
- list.qListInterface->append(ptr);
- }
+ list.qListProperty.append((QmlListProperty<void>*)&list.qListProperty, ptr);
}
break;
@@ -750,39 +733,16 @@ QObject *QmlVME::run(QmlVMEStack<QObject *> &stack, QmlContext *ctxt,
}
break;
- case QmlInstruction::FetchQmlList:
- {
- QObject *target = stack.top();
-
- void *a[1];
- // We know that QmlList<*> can be converted to
- // QmlPrivate::ListInterface
- QmlPrivate::ListInterface *list = 0;
- a[0] = &list;
- QMetaObject::metacall(target, QMetaObject::ReadProperty,
- instr.fetchQmlList.property, a);
- if (!list)
- VME_EXCEPTION(QCoreApplication::translate("QmlVME","Cannot assign to null list"));
-
- qliststack.push(ListInstance(list, instr.fetchQmlList.type));
- }
- break;
-
case QmlInstruction::FetchQList:
{
QObject *target = stack.top();
+ qliststack.push(ListInstance(instr.fetchQmlList.type));
+
void *a[1];
- // We know that QList<T *>* can be converted to
- // QList<void *>*
- QList<void *> *list = 0;
- a[0] = &list;
+ a[0] = (void *)&(qliststack.top().qListProperty);
QMetaObject::metacall(target, QMetaObject::ReadProperty,
instr.fetchQmlList.property, a);
- if (!list)
- VME_EXCEPTION(QCoreApplication::translate("QmlVME","Cannot assign to null list"));
-
- qliststack.push(ListInstance(list, instr.fetchQmlList.type));
}
break;
diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp
index 3858138..4886680 100644
--- a/src/declarative/qml/qmlvmemetaobject.cpp
+++ b/src/declarative/qml/qmlvmemetaobject.cpp
@@ -77,13 +77,14 @@ QmlVMEMetaObject::QmlVMEMetaObject(QObject *obj,
data = new QVariant[metaData->propertyCount];
aConnected.resize(metaData->aliasCount);
- int list_type = qMetaTypeId<QmlList<QObject*>* >();
+ int list_type = qMetaTypeId<QmlListProperty<QObject> >();
// ### Optimize
for (int ii = 0; ii < metaData->propertyCount; ++ii) {
int t = (metaData->propertyData() + ii)->propertyType;
if (t == list_type) {
- listProperties.append(new List(this, ii));
- data[ii] = QVariant::fromValue((QmlList<QObject *>*)listProperties.last());
+ listProperties.append(new List(methodOffset + ii));
+ data[ii] = QVariant::fromValue(QmlListProperty<QObject>(obj, listProperties.last(), list_append,
+ list_count, list_at, list_clear));
} else if (t != -1) {
data[ii] = QVariant((QVariant::Type)t);
}
@@ -182,8 +183,9 @@ int QmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
default:
break;
}
- if (t == qMetaTypeId<QmlList<QObject*>* >()) {
- *reinterpret_cast<QmlList<QObject *> **>(a[0]) = data[id].value<QmlList<QObject*>*>();
+ if (t == qMetaTypeId<QmlListProperty<QObject> >()) {
+ *reinterpret_cast<QmlListProperty<QObject> *>(a[0]) =
+ data[id].value<QmlListProperty<QObject> >();
}
} else if (c == QMetaObject::WriteProperty) {
@@ -318,6 +320,30 @@ void QmlVMEMetaObject::listChanged(int id)
activate(object, methodOffset + id, 0);
}
+void QmlVMEMetaObject::list_append(QmlListProperty<QObject> *prop, QObject *o)
+{
+ List *list = static_cast<List *>(prop->data);
+ list->append(o);
+ QMetaObject::activate(prop->object, list->notifyIndex, 0);
+}
+
+int QmlVMEMetaObject::list_count(QmlListProperty<QObject> *prop)
+{
+ return static_cast<List *>(prop->data)->count();
+}
+
+QObject *QmlVMEMetaObject::list_at(QmlListProperty<QObject> *prop, int index)
+{
+ return static_cast<List *>(prop->data)->at(index);
+}
+
+void QmlVMEMetaObject::list_clear(QmlListProperty<QObject> *prop)
+{
+ List *list = static_cast<List *>(prop->data);
+ list->clear();
+ QMetaObject::activate(prop->object, list->notifyIndex, 0);
+}
+
void QmlVMEMetaObject::registerInterceptor(int index, int valueIndex, QmlPropertyValueInterceptor *interceptor)
{
if (aInterceptors.isEmpty())
diff --git a/src/declarative/qml/qmlvmemetaobject_p.h b/src/declarative/qml/qmlvmemetaobject_p.h
index 7fa46fd..3eb776e 100644
--- a/src/declarative/qml/qmlvmemetaobject_p.h
+++ b/src/declarative/qml/qmlvmemetaobject_p.h
@@ -138,33 +138,18 @@ private:
QAbstractDynamicMetaObject *parent;
void listChanged(int);
- class List : public QmlConcreteList<QObject*>
+ class List : public QList<QObject*>
{
public:
- List(QmlVMEMetaObject *p, int propIdx)
- : parent(p), parentProperty(propIdx) { }
-
- virtual void append(QObject *v) {
- QmlConcreteList<QObject*>::append(v);
- parent->listChanged(parentProperty);
- }
- virtual void insert(int i, QObject *v) {
- QmlConcreteList<QObject*>::insert(i, v);
- parent->listChanged(parentProperty);
- }
- virtual void clear() {
- QmlConcreteList<QObject*>::clear();
- parent->listChanged(parentProperty);
- }
- virtual void removeAt(int i) {
- QmlConcreteList<QObject*>::removeAt(i);
- parent->listChanged(parentProperty);
- }
- private:
- QmlVMEMetaObject *parent;
- int parentProperty;
+ List(int lpi) : notifyIndex(lpi) {}
+ int notifyIndex;
};
QList<List *> listProperties;
+
+ static void list_append(QmlListProperty<QObject> *, QObject *);
+ static int list_count(QmlListProperty<QObject> *);
+ static QObject *list_at(QmlListProperty<QObject> *, int);
+ static void list_clear(QmlListProperty<QObject> *);
};
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 82bd33e..1be95df 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -143,6 +143,7 @@ QML_DEFINE_NOCREATE_TYPE(QmlAbstractAnimation)
/*!
\qmlclass Animation QmlAbstractAnimation
+ \since 4.7
\brief The Animation element is the base of all QML animations.
The Animation element cannot be used directly in a QML file. It exists
@@ -176,7 +177,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj
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 MouseRegion is pressed.
+ whenever the \l MouseArea is pressed.
\code
Rectangle {
@@ -185,7 +186,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj
running: myMouse.pressed
from: 0; to: 100
}
- MouseRegion { id: myMouse }
+ MouseArea { id: myMouse }
}
\endcode
@@ -589,6 +590,7 @@ void QmlAbstractAnimation::timelineComplete()
/*!
\qmlclass PauseAnimation QmlPauseAnimation
+ \since 4.7
\inherits Animation
\brief The PauseAnimation element provides a pause for an animation.
@@ -662,6 +664,7 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation()
/*!
\qmlclass ColorAnimation QmlColorAnimation
+ \since 4.7
\inherits PropertyAnimation
\brief The ColorAnimation element allows you to animate color changes.
@@ -725,6 +728,7 @@ QML_DEFINE_TYPE(Qt,4,6,ColorAnimation,QmlColorAnimation)
/*!
\qmlclass ScriptAction QmlScriptAction
+ \since 4.7
\inherits Animation
\brief The ScriptAction element allows scripts to be run during an animation.
@@ -831,6 +835,7 @@ QML_DEFINE_TYPE(Qt,4,6,ScriptAction,QmlScriptAction)
/*!
\qmlclass PropertyAction QmlPropertyAction
+ \since 4.7
\inherits Animation
\brief The PropertyAction element allows immediate property changes during animation.
@@ -937,10 +942,10 @@ void QmlPropertyAction::setProperties(const QString &p)
emit propertiesChanged(p);
}
-QList<QObject *> *QmlPropertyAction::targets()
+QmlListProperty<QObject> QmlPropertyAction::targets()
{
Q_D(QmlPropertyAction);
- return &d->targets;
+ return QmlListProperty<QObject>(this, d->targets);
}
/*!
@@ -948,10 +953,10 @@ QList<QObject *> *QmlPropertyAction::targets()
This property holds the objects not to be affected by this animation.
\sa targets
*/
-QList<QObject *> *QmlPropertyAction::exclude()
+QmlListProperty<QObject> QmlPropertyAction::exclude()
{
Q_D(QmlPropertyAction);
- return &d->exclude;
+ return QmlListProperty<QObject>(this, d->exclude);
}
/*!
@@ -1079,6 +1084,7 @@ QML_DEFINE_TYPE(Qt,4,6,PropertyAction,QmlPropertyAction)
/*!
\qmlclass ParentAction QmlParentAction
+ \since 4.7
\inherits Animation
\brief The ParentAction element allows parent changes during animation.
@@ -1282,6 +1288,7 @@ QML_DEFINE_TYPE(Qt,4,6,ParentAction,QmlParentAction)
/*!
\qmlclass NumberAnimation QmlNumberAnimation
+ \since 4.7
\inherits PropertyAnimation
\brief The NumberAnimation element allows you to animate changes in properties of type qreal.
@@ -1345,6 +1352,7 @@ QML_DEFINE_TYPE(Qt,4,6,NumberAnimation,QmlNumberAnimation)
/*!
\qmlclass Vector3dAnimation QmlVector3dAnimation
+ \since 4.7
\inherits PropertyAnimation
\brief The Vector3dAnimation element allows you to animate changes in properties of type QVector3d.
*/
@@ -1520,7 +1528,7 @@ void QmlRotationAnimation::setTo(qreal t)
Possible values are Numerical, Clockwise, Counterclockwise,
or Shortest.
- \list
+ \table
\row
\o Numerical
\o Rotate by linearly interpolating between the two numbers.
@@ -1535,7 +1543,7 @@ void QmlRotationAnimation::setTo(qreal t)
\o Shortest
\o Rotate in the direction that produces the shortest animation path.
A rotation from 10 to 350 will rotate 20 degrees counterclockwise.
- \list
+ \endtable
The default direction is Shortest.
*/
@@ -1577,18 +1585,41 @@ QmlAnimationGroup::QmlAnimationGroup(QObject *parent)
{
}
+void QmlAnimationGroupPrivate::append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a)
+{
+ QmlAnimationGroup *q = qobject_cast<QmlAnimationGroup *>(list->object);
+ if (q) {
+ q->d_func()->animations.append(a);
+ a->setGroup(q);
+ }
+}
+
+void QmlAnimationGroupPrivate::clear_animation(QmlListProperty<QmlAbstractAnimation> *list)
+{
+ QmlAnimationGroup *q = qobject_cast<QmlAnimationGroup *>(list->object);
+ if (q) {
+ for (int i = 0; i < q->d_func()->animations.count(); ++i)
+ q->d_func()->animations.at(i)->setGroup(0);
+ q->d_func()->animations.clear();
+ }
+}
+
QmlAnimationGroup::~QmlAnimationGroup()
{
}
-QmlList<QmlAbstractAnimation *> *QmlAnimationGroup::animations()
+QmlListProperty<QmlAbstractAnimation> QmlAnimationGroup::animations()
{
Q_D(QmlAnimationGroup);
- return &d->animations;
+ QmlListProperty<QmlAbstractAnimation> list(this, d->animations);
+ list.append = &QmlAnimationGroupPrivate::append_animation;
+ list.clear = &QmlAnimationGroupPrivate::clear_animation;
+ return list;
}
/*!
\qmlclass SequentialAnimation QmlSequentialAnimation
+ \since 4.7
\inherits Animation
\brief The SequentialAnimation element allows you to run animations sequentially.
@@ -1649,6 +1680,7 @@ QML_DEFINE_TYPE(Qt,4,6,SequentialAnimation,QmlSequentialAnimation)
/*!
\qmlclass ParallelAnimation QmlParallelAnimation
+ \since 4.7
\inherits Animation
\brief The ParallelAnimation element allows you to run animations in parallel.
@@ -1757,6 +1789,7 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
/*!
\qmlclass PropertyAnimation QmlPropertyAnimation
+ \since 4.7
\inherits Animation
\brief The PropertyAnimation element allows you to animate property changes.
@@ -1794,7 +1827,7 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
Fade out \c theObject when clicked:
\qml
- MouseRegion {
+ MouseArea {
anchors.fill: theObject
onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 }
}
@@ -2214,7 +2247,7 @@ void QmlPropertyAnimation::setProperties(const QString &prop)
color: Qt.rgba(0,0,1)
//need to explicitly specify target and property
NumberAnimation { id: theAnim; target: theRect; property: "x" to: 500 }
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: theAnim.start()
}
@@ -2226,10 +2259,10 @@ void QmlPropertyAnimation::setProperties(const QString &prop)
\sa exclude
*/
-QList<QObject *> *QmlPropertyAnimation::targets()
+QmlListProperty<QObject> QmlPropertyAnimation::targets()
{
Q_D(QmlPropertyAnimation);
- return &d->targets;
+ return QmlListProperty<QObject>(this, d->targets);
}
/*!
@@ -2237,10 +2270,10 @@ QList<QObject *> *QmlPropertyAnimation::targets()
This property holds the items not to be affected by this animation.
\sa targets
*/
-QList<QObject *> *QmlPropertyAnimation::exclude()
+QmlListProperty<QObject> QmlPropertyAnimation::exclude()
{
Q_D(QmlPropertyAnimation);
- return &d->exclude;
+ return QmlListProperty<QObject>(this, d->exclude);
}
QAbstractAnimation *QmlPropertyAnimation::qtAnimation()
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 50eb577..623ad8d 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -190,8 +190,8 @@ class QmlPropertyAction : public QmlAbstractAnimation
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QList<QObject *>* targets READ targets)
- Q_PROPERTY(QList<QObject *>* exclude READ exclude)
+ Q_PROPERTY(QmlListProperty<QObject> targets READ targets)
+ Q_PROPERTY(QmlListProperty<QObject> exclude READ exclude)
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
public:
@@ -207,8 +207,8 @@ public:
QString properties() const;
void setProperties(const QString &);
- QList<QObject *> *targets();
- QList<QObject *> *exclude();
+ QmlListProperty<QObject> targets();
+ QmlListProperty<QObject> exclude();
QVariant value() const;
void setValue(const QVariant &);
@@ -265,8 +265,8 @@ class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QList<QObject *>* targets READ targets)
- Q_PROPERTY(QList<QObject *>* exclude READ exclude)
+ Q_PROPERTY(QmlListProperty<QObject> targets READ targets)
+ Q_PROPERTY(QmlListProperty<QObject> exclude READ exclude)
public:
QmlPropertyAnimation(QObject *parent=0);
@@ -293,8 +293,8 @@ public:
QString properties() const;
void setProperties(const QString &);
- QList<QObject *> *targets();
- QList<QObject *> *exclude();
+ QmlListProperty<QObject> targets();
+ QmlListProperty<QObject> exclude();
protected:
QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent);
@@ -404,13 +404,13 @@ class QmlAnimationGroup : public QmlAbstractAnimation
Q_DECLARE_PRIVATE(QmlAnimationGroup)
Q_CLASSINFO("DefaultProperty", "animations")
- Q_PROPERTY(QmlList<QmlAbstractAnimation *> *animations READ animations)
+ Q_PROPERTY(QmlListProperty<QmlAbstractAnimation> animations READ animations)
public:
QmlAnimationGroup(QObject *parent);
virtual ~QmlAnimationGroup();
- QmlList<QmlAbstractAnimation *>* animations();
+ QmlListProperty<QmlAbstractAnimation> animations();
friend class QmlAbstractAnimation;
};
diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h
index b2ce297..056ce82 100644
--- a/src/declarative/util/qmlanimation_p_p.h
+++ b/src/declarative/util/qmlanimation_p_p.h
@@ -304,37 +304,13 @@ class QmlAnimationGroupPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlAnimationGroup)
public:
QmlAnimationGroupPrivate()
- : QmlAbstractAnimationPrivate(), animations(this), ag(0) {}
+ : QmlAbstractAnimationPrivate(), ag(0) {}
- struct AnimationList : public QmlConcreteList<QmlAbstractAnimation *>
- {
- AnimationList(QmlAnimationGroupPrivate *p)
- : anim(p) {}
- virtual void append(QmlAbstractAnimation *a) {
- QmlConcreteList<QmlAbstractAnimation *>::append(a);
- a->setGroup(anim->q_func());
- }
- virtual void clear()
- {
- for (int i = 0; i < count(); ++i)
- at(i)->setGroup(0);
- QmlConcreteList<QmlAbstractAnimation *>::clear();
- }
- virtual void removeAt(int i)
- {
- at(i)->setGroup(0);
- QmlConcreteList<QmlAbstractAnimation *>::removeAt(i);
- }
- virtual void insert(int i, QmlAbstractAnimation *a)
- {
- QmlConcreteList<QmlAbstractAnimation *>::insert(i, a);
- a->setGroup(anim->q_func());
- }
-
- QmlAnimationGroupPrivate *anim;
- };
-
- AnimationList animations;
+ static void append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *role);
+ static void clear_animation(QmlListProperty<QmlAbstractAnimation> *list);
+ static void removeAt_animation(QmlListProperty<QmlAbstractAnimation> *list, int i);
+ static void insert_animation(QmlListProperty<QmlAbstractAnimation> *list, int i, QmlAbstractAnimation *role);
+ QList<QmlAbstractAnimation *> animations;
QAnimationGroup *ag;
};
diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp
index fc1562b..6743edd 100644
--- a/src/declarative/util/qmlbind.cpp
+++ b/src/declarative/util/qmlbind.cpp
@@ -71,6 +71,7 @@ public:
QML_DEFINE_TYPE(Qt,4,6,Binding,QmlBind)
/*!
\qmlclass Binding QmlBind
+ \since 4.7
\brief The Binding element allows arbitrary property bindings to be created.
Sometimes it is necessary to bind to a property of an object that wasn't
diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp
index 9bec3bb..204377c 100644
--- a/src/declarative/util/qmlconnection.cpp
+++ b/src/declarative/util/qmlconnection.cpp
@@ -66,13 +66,14 @@ public:
/*!
\qmlclass Connection QmlConnection
+ \since 4.7
\brief A Connection object describes generalized connections to signals.
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
- MouseRegion {
+ MouseArea {
onClicked: { foo(x+123,y+456) }
}
\endqml
@@ -94,7 +95,7 @@ public:
like this:
\qml
- MouseRegion {
+ MouseArea {
Connection {
signal: "clicked(x,y)"
script: { foo(x+123,y+456) }
@@ -106,7 +107,7 @@ public:
the sender of the signal, and the script is the default attribute:
\qml
- MouseRegion {
+ MouseArea {
id: mr
}
...
diff --git a/src/declarative/util/qmldatetimeformatter.cpp b/src/declarative/util/qmldatetimeformatter.cpp
index c44ca5e..4b8fb00 100644
--- a/src/declarative/util/qmldatetimeformatter.cpp
+++ b/src/declarative/util/qmldatetimeformatter.cpp
@@ -74,6 +74,7 @@ public:
/*!
\qmlclass DateTimeFormatter QmlDateTimeFormatter
+ \since 4.7
\brief The DateTimeFormatter allows you to control the format of a date string.
\code
diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qmleasefollow.cpp
index efa6faf..deb474a 100644
--- a/src/declarative/util/qmleasefollow.cpp
+++ b/src/declarative/util/qmleasefollow.cpp
@@ -300,6 +300,13 @@ Rectangle {
}
\endcode
+ The default velocity of EaseFollow 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.
+
\sa SpringFollow
*/
@@ -415,7 +422,7 @@ void QmlEaseFollow::setSourceValue(qreal s)
This property holds the animation duration used when tracking the source.
- Setting this to -1 disables the duration value.
+ Setting this to -1 (the default) disables the duration value.
*/
qreal QmlEaseFollow::duration() const
{
@@ -449,6 +456,8 @@ qreal QmlEaseFollow::velocity() const
This property holds the average velocity allowed when tracking the source.
+ The default velocity of EaseFollow is 200 units/second.
+
Setting this to -1 disables the velocity value.
*/
void QmlEaseFollow::setVelocity(qreal v)
diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp
index c1b9247..abdb626 100644
--- a/src/declarative/util/qmllistaccessor.cpp
+++ b/src/declarative/util/qmllistaccessor.cpp
@@ -84,11 +84,8 @@ void QmlListAccessor::setList(const QVariant &v, QmlEngine *engine)
QObject *data = enginePrivate?enginePrivate->toQObject(v):QmlMetaType::toQObject(v);
d = QVariant::fromValue(data);
m_type = Instance;
- } else if ((!enginePrivate && QmlMetaType::isQmlList(d.userType())) ||
- (enginePrivate && enginePrivate->isQmlList(d.userType()))) {
- m_type = QmlList;
- } else if (QmlMetaType::isList(d.userType())) {
- m_type = QListPtr;
+ } else if (d.userType() == qMetaTypeId<QmlListReference>()) {
+ m_type = ListProperty;
} else {
m_type = Instance;
}
@@ -101,16 +98,8 @@ int QmlListAccessor::count() const
return qvariant_cast<QStringList>(d).count();
case VariantList:
return qvariant_cast<QVariantList>(d).count();
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- return li->count();
- }
- case QListPtr:
- {
- QList<void *> *li = *(QList<void *> **)d.constData();
- return li->count();
- }
+ case ListProperty:
+ return ((QmlListReference *)d.constData())->count();
case Instance:
return 1;
case Integer:
@@ -129,19 +118,8 @@ QVariant QmlListAccessor::at(int idx) const
return QVariant::fromValue(qvariant_cast<QStringList>(d).at(idx));
case VariantList:
return qvariant_cast<QVariantList>(d).at(idx);
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- void *ptr[1];
- li->at(idx, ptr);
- return QVariant::fromValue((QObject*)ptr[0]);
- }
- case QListPtr:
- {
- QList<void *> *li = *(QList<void *> **)d.constData();
- void *ptr = li->at(idx);
- return QVariant::fromValue((QObject*)ptr);
- }
+ case ListProperty:
+ return QVariant::fromValue(((QmlListReference *)d.constData())->at(idx));
case Instance:
return d;
case Integer:
@@ -152,106 +130,6 @@ QVariant QmlListAccessor::at(int idx) const
}
}
-bool QmlListAccessor::append(const QVariant &value)
-{
- switch(m_type) {
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- li->append(const_cast<void *>(value.constData())); //XXX Typesafety
- return true;
- }
- case QListPtr:
- {
- QList<void *> *li = *(QList<void *> **)d.constData();
- li->append(*reinterpret_cast<void **>(const_cast<void *>(value.constData()))); //XXX Typesafety
- return true;
- }
- case StringList:
- case VariantList:
- case Invalid:
- case Instance:
- case Integer:
- default:
- return false;
- }
-}
-
-bool QmlListAccessor::insert(int index, const QVariant &value)
-{
- switch(m_type) {
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- li->insert(index, const_cast<void *>(value.constData())); //XXX Typesafety
- return true;
- }
- case QListPtr:
- {
- QList<void *> *li = *(QList<void *>**)d.constData();
- li->insert(index, *reinterpret_cast<void **>(const_cast<void *>(value.constData()))); //XXX Typesafety
- return true;
- }
- case StringList:
- case VariantList:
- case Invalid:
- case Instance:
- case Integer:
- default:
- return false;
- }
-}
-
-bool QmlListAccessor::removeAt(int index)
-{
- switch(m_type) {
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- li->removeAt(index);
- return true;
- }
- case QListPtr:
- {
- QList<void *> *li = *(QList<void *>**)d.constData();
- li->removeAt(index);
- return true;
- }
- case StringList:
- case VariantList:
- case Invalid:
- case Instance:
- case Integer:
- default:
- return false;
- }
-}
-
-bool QmlListAccessor::clear()
-{
- switch(m_type) {
- case QmlList:
- {
- QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
- li->clear();
- return true;
- }
- case QListPtr:
- {
- QList<void *> *li = *(QList<void *>**)d.constData();
- li->clear();
- return true;
- }
- case StringList:
- case VariantList:
- case Invalid:
- case Instance:
- case Integer:
- default:
- return false;
- }
-}
-
bool QmlListAccessor::isValid() const
{
return m_type != Invalid;
diff --git a/src/declarative/util/qmllistaccessor_p.h b/src/declarative/util/qmllistaccessor_p.h
index 8a0b06c..611eebb 100644
--- a/src/declarative/util/qmllistaccessor_p.h
+++ b/src/declarative/util/qmllistaccessor_p.h
@@ -65,12 +65,7 @@ public:
int count() const;
QVariant at(int) const;
- bool append(const QVariant &);
- bool insert(int, const QVariant &);
- bool removeAt(int);
- bool clear();
-
- enum Type { Invalid, StringList, VariantList, QmlList, QListPtr, Instance, Integer };
+ enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer };
Type type() const { return m_type; }
private:
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index af41dfd..8fda3ae 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -188,7 +188,7 @@ static void dump(ModelNode *node, int ind);
Text { text: '$'+cost; anchors.right: parent.right }
// Double the price when clicked.
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: fruitModel.set(index, "cost", cost*2)
}
diff --git a/src/declarative/util/qmlnumberformatter.cpp b/src/declarative/util/qmlnumberformatter.cpp
index f78abdf..0845d0c 100644
--- a/src/declarative/util/qmlnumberformatter.cpp
+++ b/src/declarative/util/qmlnumberformatter.cpp
@@ -67,6 +67,7 @@ public:
};
/*!
\qmlclass NumberFormatter
+ \since 4.7
\brief The NumberFormatter allows you to control the format of a number string.
The format property documentation has more details on how the format can be manipulated.
diff --git a/src/declarative/util/qmlpackage.cpp b/src/declarative/util/qmlpackage.cpp
index 115f2fd..82f776f 100644
--- a/src/declarative/util/qmlpackage.cpp
+++ b/src/declarative/util/qmlpackage.cpp
@@ -51,28 +51,33 @@ class QmlPackagePrivate : public QObjectPrivate
public:
QmlPackagePrivate() {}
- class DataList;
struct DataGuard : public QmlGuard<QObject>
{
- DataGuard(QObject *obj, DataList *l) : list(l) { (QmlGuard<QObject>&)*this = obj; }
- DataList *list;
+ DataGuard(QObject *obj, QList<DataGuard> *l) : list(l) { (QmlGuard<QObject>&)*this = obj; }
+ QList<DataGuard> *list;
void objectDestroyed(QObject *) {
// we assume priv will always be destroyed after objectDestroyed calls
list->removeOne(*this);
}
};
- class DataList : public QList<DataGuard>, public QmlList<QObject*>
- {
- public:
- virtual void append(QObject* v) { QList<DataGuard>::append(DataGuard(v, this)); }
- virtual void insert(int i, QObject* v) { QList<DataGuard>::insert(i, DataGuard(v, this)); }
- virtual void clear() { QList<DataGuard>::clear(); }
- virtual QObject* at(int i) const { return QList<DataGuard>::at(i); }
- virtual void removeAt(int i) { QList<DataGuard>::removeAt(i); }
- virtual int count() const { return QList<DataGuard>::count(); }
- };
- DataList dataList;
+ QList<DataGuard> dataList;
+ static void data_append(QmlListProperty<QObject> *prop, QObject *o) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ list->append(DataGuard(o, list));
+ }
+ static void data_clear(QmlListProperty<QObject> *prop) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ list->clear();
+ }
+ static QObject *data_at(QmlListProperty<QObject> *prop, int index) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ return list->at(index);
+ }
+ static int data_count(QmlListProperty<QObject> *prop) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ return list->count();
+ }
};
class QmlPackageAttached : public QObject
@@ -128,10 +133,13 @@ QmlPackage::~QmlPackage()
}
}
-QmlList<QObject *> *QmlPackage::data()
+QmlListProperty<QObject> QmlPackage::data()
{
Q_D(QmlPackage);
- return &d->dataList;
+ return QmlListProperty<QObject>(this, &d->dataList, QmlPackagePrivate::data_append,
+ QmlPackagePrivate::data_count,
+ QmlPackagePrivate::data_at,
+ QmlPackagePrivate::data_clear);
}
bool QmlPackage::hasPart(const QString &name)
diff --git a/src/declarative/util/qmlpackage_p.h b/src/declarative/util/qmlpackage_p.h
index 2538bb9..29b6bbe 100644
--- a/src/declarative/util/qmlpackage_p.h
+++ b/src/declarative/util/qmlpackage_p.h
@@ -64,13 +64,13 @@ class QmlPackage : public QObject
Q_DECLARE_PRIVATE(QmlPackage)
Q_CLASSINFO("DefaultProperty", "data")
- Q_PROPERTY(QmlList<QObject *> *data READ data SCRIPTABLE false)
+ Q_PROPERTY(QmlListProperty<QObject> data READ data SCRIPTABLE false)
public:
QmlPackage(QObject *parent=0);
virtual ~QmlPackage();
- QmlList<QObject *> *data();
+ QmlListProperty<QObject> data();
QObject *part(const QString & = QString());
bool hasPart(const QString &);
diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp
index 56903ce..2459651 100644
--- a/src/declarative/util/qmlpixmapcache.cpp
+++ b/src/declarative/util/qmlpixmapcache.cpp
@@ -179,11 +179,19 @@ bool QmlImageRequestHandler::event(QEvent *event)
if (reader->cancelled.count()) {
for (int i = 0; i < reader->cancelled.count(); ++i) {
QmlPixmapReply *job = reader->cancelled.at(i);
+ // cancel any jobs already started
QNetworkReply *reply = replies.key(job, 0);
if (reply && reply->isRunning()) {
replies.remove(reply);
reply->close();
- job->release(true);
+ }
+ // remove from pending job list
+ for (int j = 0; j < reader->jobs.count(); ++j) {
+ if (reader->jobs.at(j) == job) {
+ reader->jobs.removeAt(j);
+ job->release(true);
+ break;
+ }
}
}
reader->cancelled.clear();
@@ -195,8 +203,6 @@ bool QmlImageRequestHandler::event(QEvent *event)
}
QmlPixmapReply *runningJob = reader->jobs.takeLast();
- runningJob->addRef();
- runningJob->setLoading();
QUrl url = runningJob->url();
reader->mutex.unlock();
@@ -292,6 +298,8 @@ QmlPixmapReply *QmlImageReader::getImage(const QUrl &url)
{
mutex.lock();
QmlPixmapReply *reply = new QmlPixmapReply(this, url);
+ reply->addRef();
+ reply->setLoading();
jobs.append(reply);
if (jobs.count() == 1 && handler)
QCoreApplication::postEvent(handler, new QEvent(QEvent::User));
@@ -303,21 +311,10 @@ void QmlImageReader::cancel(QmlPixmapReply *reply)
{
mutex.lock();
if (reply->isLoading()) {
- // Already requested. Add to cancel list to be cancelled in reader thread.
+ // Add to cancel list to be cancelled in reader thread.
cancelled.append(reply);
if (cancelled.count() == 1 && handler)
QCoreApplication::postEvent(handler, new QEvent(QEvent::User));
- } else {
- // Not yet processed - just remove from waiting list
- QList<QmlPixmapReply*>::iterator it = jobs.begin();
- while (it != jobs.end()) {
- QmlPixmapReply *job = *it;
- if (job == reply) {
- jobs.erase(it);
- break;
- }
- ++it;
- }
}
mutex.unlock();
}
@@ -482,8 +479,6 @@ bool QmlPixmapReply::release(bool defer)
--d->refCount;
if (d->refCount == 0) {
qmlActivePixmapReplies()->remove(d->url);
- if (d->status == Loading && !d->loading)
- d->reader->cancel(this);
if (defer)
deleteLater();
else
diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp
index 84f1e9a..fba22f9 100644
--- a/src/declarative/util/qmlpropertychanges.cpp
+++ b/src/declarative/util/qmlpropertychanges.cpp
@@ -59,6 +59,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass PropertyChanges QmlPropertyChanges
+ \since 4.7
\brief The PropertyChanges element describes new property values for a state.
PropertyChanges provides a state change that modifies the properties of an item.
@@ -83,7 +84,7 @@ QT_BEGIN_NAMESPACE
}
}
- MouseRegion { anchors.fill: parent; onClicked: myText.state = 'myState' }
+ MouseArea { anchors.fill: parent; onClicked: myText.state = 'myState' }
}
\endqml
@@ -91,7 +92,7 @@ QT_BEGIN_NAMESPACE
\qml
PropertyChanges {
- target: myMouseRegion
+ target: myMouseArea
onClicked: doSomethingDifferent()
}
\endqml
diff --git a/src/declarative/util/qmlpropertymap.cpp b/src/declarative/util/qmlpropertymap.cpp
index ccbec6f..317896e 100644
--- a/src/declarative/util/qmlpropertymap.cpp
+++ b/src/declarative/util/qmlpropertymap.cpp
@@ -90,6 +90,7 @@ void QmlPropertyMapMetaObject::propertyWrite(int index)
/*!
\class QmlPropertyMap
+ \since 4.7
\brief The QmlPropertyMap class allows you to set key-value pairs that can be used in bindings.
QmlPropertyMap provides a convenient way to expose domain data to the UI layer.
diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp
index 7ecbd79..c743e0b 100644
--- a/src/declarative/util/qmlstate.cpp
+++ b/src/declarative/util/qmlstate.cpp
@@ -130,6 +130,7 @@ QmlStateOperation::QmlStateOperation(QObjectPrivate &dd, QObject *parent)
/*!
\qmlclass State QmlState
+ \since 4.7
\brief The State element defines configurations of objects and properties.
A state is specified as a set of batched changes from the default configuration.
@@ -242,16 +243,30 @@ void QmlState::setExtends(const QString &extends)
extends another state, then the changes are applied against the state being
extended.
*/
-QmlList<QmlStateOperation *> *QmlState::changes()
+QmlListProperty<QmlStateOperation> QmlState::changes()
{
Q_D(QmlState);
- return &d->operations;
+ return QmlListProperty<QmlStateOperation>(this, &d->operations, QmlStatePrivate::operations_append,
+ QmlStatePrivate::operations_count, QmlStatePrivate::operations_at,
+ QmlStatePrivate::operations_clear);
+}
+
+int QmlState::operationCount() const
+{
+ Q_D(const QmlState);
+ return d->operations.count();
+}
+
+QmlStateOperation *QmlState::operationAt(int index) const
+{
+ Q_D(const QmlState);
+ return d->operations.at(index);
}
QmlState &QmlState::operator<<(QmlStateOperation *op)
{
Q_D(QmlState);
- d->operations.append(op);
+ d->operations.append(QmlStatePrivate::OperationGuard(op, &d->operations));
return *this;
}
diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h
index 785a175..2c92387 100644
--- a/src/declarative/util/qmlstate_p.h
+++ b/src/declarative/util/qmlstate_p.h
@@ -131,7 +131,7 @@ class Q_DECLARATIVE_EXPORT QmlState : public QObject
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QmlBinding *when READ when WRITE setWhen)
Q_PROPERTY(QString extend READ extends WRITE setExtends)
- Q_PROPERTY(QmlList<QmlStateOperation *>* changes READ changes)
+ Q_PROPERTY(QmlListProperty<QmlStateOperation> changes READ changes)
Q_CLASSINFO("DefaultProperty", "changes")
Q_CLASSINFO("DeferredPropertyNames", "changes")
@@ -151,7 +151,10 @@ public:
QString extends() const;
void setExtends(const QString &);
- QmlList<QmlStateOperation *> *changes();
+ QmlListProperty<QmlStateOperation> changes();
+ int operationCount() const;
+ QmlStateOperation *operationAt(int) const;
+
QmlState &operator<<(QmlStateOperation *);
void apply(QmlStateGroup *, QmlTransition *, QmlState *revert);
diff --git a/src/declarative/util/qmlstate_p_p.h b/src/declarative/util/qmlstate_p_p.h
index c389846..d138e4e 100644
--- a/src/declarative/util/qmlstate_p_p.h
+++ b/src/declarative/util/qmlstate_p_p.h
@@ -107,28 +107,33 @@ public:
QString name;
QmlBinding *when;
- class OperationList;
struct OperationGuard : public QmlGuard<QmlStateOperation>
{
- OperationGuard(QObject *obj, OperationList *l) : list(l) { (QmlGuard<QObject>&)*this = obj; }
- OperationList *list;
+ OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) { (QmlGuard<QObject>&)*this = obj; }
+ QList<OperationGuard> *list;
void objectDestroyed(QmlStateOperation *) {
// we assume priv will always be destroyed after objectDestroyed calls
list->removeOne(*this);
}
};
+ QList<OperationGuard> operations;
- class OperationList : public QList<OperationGuard>, public QmlList<QmlStateOperation*>
- {
- public:
- virtual void append(QmlStateOperation* v) { QList<OperationGuard>::append(OperationGuard(v, this)); }
- virtual void insert(int i, QmlStateOperation* v) { QList<OperationGuard>::insert(i, OperationGuard(v, this)); }
- virtual void clear() { QList<OperationGuard>::clear(); }
- virtual QmlStateOperation* at(int i) const { return QList<OperationGuard>::at(i); }
- virtual void removeAt(int i) { QList<OperationGuard>::removeAt(i); }
- virtual int count() const { return QList<OperationGuard>::count(); }
- };
- OperationList operations;
+ static void operations_append(QmlListProperty<QmlStateOperation> *prop, QmlStateOperation *op) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ list->append(OperationGuard(op, list));
+ }
+ static void operations_clear(QmlListProperty<QmlStateOperation> *prop) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ list->clear();
+ }
+ static int operations_count(QmlListProperty<QmlStateOperation> *prop) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ return list->count();
+ }
+ static QmlStateOperation *operations_at(QmlListProperty<QmlStateOperation> *prop, int index) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ return list->at(index);
+ }
QmlTransitionManager transitionManager;
diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp
index d289e17..4ad77c8 100644
--- a/src/declarative/util/qmlstategroup.cpp
+++ b/src/declarative/util/qmlstategroup.cpp
@@ -60,26 +60,19 @@ class QmlStateGroupPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QmlStateGroup)
public:
QmlStateGroupPrivate(QmlStateGroup *p)
- : nullState(0), states(p), componentComplete(true),
+ : nullState(0), componentComplete(true),
ignoreTrans(false), applyingState(false) {}
QString currentState;
QmlState *nullState;
- struct StateList : public QmlConcreteList<QmlState *>
- {
- StateList(QmlStateGroup *g)
- :group(g) {}
- void append(QmlState *s) {
- QmlConcreteList<QmlState *>::append(s);
- if (s) s->setStateGroup(group);
- }
- private:
- QmlStateGroup *group;
- };
- StateList states;
+ static void append_state(QmlListProperty<QmlState> *list, QmlState *state);
+ static int count_state(QmlListProperty<QmlState> *list);
+ static QmlState *at_state(QmlListProperty<QmlState> *list, int index);
+
+ QList<QmlState *> states;
+ QList<QmlTransition *> transitions;
- QmlConcreteList<QmlTransition *> transitions;
bool componentComplete;
bool ignoreTrans;
bool applyingState;
@@ -151,10 +144,34 @@ QList<QmlState *> QmlStateGroup::states() const
\sa {qmlstate}{States}
*/
-QmlList<QmlState *>* QmlStateGroup::statesProperty()
+QmlListProperty<QmlState> QmlStateGroup::statesProperty()
{
Q_D(QmlStateGroup);
- return &(d->states);
+ return QmlListProperty<QmlState>(this, &d->states, &QmlStateGroupPrivate::append_state,
+ &QmlStateGroupPrivate::count_state,
+ &QmlStateGroupPrivate::at_state);
+}
+
+void QmlStateGroupPrivate::append_state(QmlListProperty<QmlState> *list, QmlState *state)
+{
+ QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object);
+ if (state) {
+ _this->d_func()->states.append(state);
+ state->setStateGroup(_this);
+ }
+
+}
+
+int QmlStateGroupPrivate::count_state(QmlListProperty<QmlState> *list)
+{
+ QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object);
+ return _this->d_func()->states.count();
+}
+
+QmlState *QmlStateGroupPrivate::at_state(QmlListProperty<QmlState> *list, int index)
+{
+ QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object);
+ return _this->d_func()->states.at(index);
}
/*!
@@ -173,10 +190,10 @@ QmlList<QmlState *>* QmlStateGroup::statesProperty()
\sa {state-transitions}{Transitions}
*/
-QmlList<QmlTransition *>* QmlStateGroup::transitionsProperty()
+QmlListProperty<QmlTransition> QmlStateGroup::transitionsProperty()
{
Q_D(QmlStateGroup);
- return &(d->transitions);
+ return QmlListProperty<QmlTransition>(this, d->transitions);
}
/*!
diff --git a/src/declarative/util/qmlstategroup_p.h b/src/declarative/util/qmlstategroup_p.h
index 48b9c66..d39ca03 100644
--- a/src/declarative/util/qmlstategroup_p.h
+++ b/src/declarative/util/qmlstategroup_p.h
@@ -58,8 +58,8 @@ class Q_DECLARATIVE_EXPORT QmlStateGroup : public QObject, public QmlParserStatu
Q_DECLARE_PRIVATE(QmlStateGroup)
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
- Q_PROPERTY(QmlList<QmlState *>* states READ statesProperty DESIGNABLE false)
- Q_PROPERTY(QmlList<QmlTransition *>* transitions READ transitionsProperty DESIGNABLE false)
+ Q_PROPERTY(QmlListProperty<QmlState> states READ statesProperty DESIGNABLE false)
+ Q_PROPERTY(QmlListProperty<QmlTransition> transitions READ transitionsProperty DESIGNABLE false)
public:
QmlStateGroup(QObject * = 0);
@@ -68,10 +68,10 @@ public:
QString state() const;
void setState(const QString &);
- QmlList<QmlState *>* statesProperty();
+ QmlListProperty<QmlState> statesProperty();
QList<QmlState *> states() const;
- QmlList<QmlTransition *>* transitionsProperty();
+ QmlListProperty<QmlTransition> transitionsProperty();
QmlState *findState(const QString &name) const;
diff --git a/src/declarative/util/qmltimeline.cpp b/src/declarative/util/qmltimeline.cpp
index 58c87e8..5c5df40 100644
--- a/src/declarative/util/qmltimeline.cpp
+++ b/src/declarative/util/qmltimeline.cpp
@@ -55,12 +55,12 @@ QT_BEGIN_NAMESPACE
struct Update {
Update(QmlTimeLineValue *_g, qreal _v)
: g(_g), v(_v) {}
- Update(const QmlTimeLineEvent &_e)
+ Update(const QmlTimeLineCallback &_e)
: g(0), v(0), e(_e) {}
QmlTimeLineValue *g;
qreal v;
- QmlTimeLineEvent e;
+ QmlTimeLineCallback e;
};
struct QmlTimeLinePrivate
@@ -79,7 +79,7 @@ struct QmlTimeLinePrivate
};
Op() {}
Op(Type t, int l, qreal v, qreal v2, int o,
- const QmlTimeLineEvent &ev = QmlTimeLineEvent(), const QEasingCurve &es = QEasingCurve())
+ const QmlTimeLineCallback &ev = QmlTimeLineCallback(), const QEasingCurve &es = QEasingCurve())
: type(t), length(l), value(v), value2(v2), order(o), event(ev),
easing(es) {}
Op(const Op &o)
@@ -98,7 +98,7 @@ struct QmlTimeLinePrivate
qreal value2;
int order;
- QmlTimeLineEvent event;
+ QmlTimeLineCallback event;
QEasingCurve easing;
};
struct TimeLine
@@ -244,7 +244,7 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change
}
case Op::Execute:
- op.event.execute();
+ op.event.d0(op.event.d1);
*changed = false;
return -1;
}
@@ -364,10 +364,10 @@ void QmlTimeLine::pause(QmlTimeLineObject &obj, int time)
/*!
Execute the \a event.
*/
-void QmlTimeLine::execute(const QmlTimeLineEvent &event)
+void QmlTimeLine::callback(const QmlTimeLineCallback &callback)
{
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, event);
- d->add(*event.eventObject(), op);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback);
+ d->add(*callback.callbackObject(), op);
}
/*!
@@ -466,7 +466,7 @@ void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, int t
void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time)
{
if (time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineCallback(), easing);
d->add(timeLineValue, op);
}
@@ -488,7 +488,7 @@ void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, int time
void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time)
{
if (time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineCallback(), easing);
d->add(timeLineValue, op);
}
@@ -805,10 +805,11 @@ int QmlTimeLinePrivate::advance(int t)
updateQueue = &updates;
for (int ii = 0; ii < updates.count(); ++ii) {
const Update &v = updates.at(ii).second;
- if (v.g)
+ if (v.g) {
v.g->setValue(v.v);
- else
- v.e.execute();
+ } else {
+ v.e.d0(v.e.d1);
+ }
}
updateQueue = 0;
} while(t);
@@ -854,7 +855,7 @@ void QmlTimeLine::remove(QmlTimeLineObject *v)
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.eventObject() == v) {
+ d->updateQueue->at(ii).second.e.callbackObject() == v) {
d->updateQueue->removeAt(ii);
--ii;
}
@@ -910,17 +911,22 @@ QmlTimeLineObject::~QmlTimeLineObject()
}
}
-QmlTimeLineEvent::QmlTimeLineEvent()
+QmlTimeLineCallback::QmlTimeLineCallback()
: d0(0), d1(0), d2(0)
{
}
-QmlTimeLineEvent::QmlTimeLineEvent(const QmlTimeLineEvent &o)
+QmlTimeLineCallback::QmlTimeLineCallback(QmlTimeLineObject *b, Callback f, void *d)
+: d0(f), d1(d), d2(b)
+{
+}
+
+QmlTimeLineCallback::QmlTimeLineCallback(const QmlTimeLineCallback &o)
: d0(o.d0), d1(o.d1), d2(o.d2)
{
}
-QmlTimeLineEvent &QmlTimeLineEvent::operator=(const QmlTimeLineEvent &o)
+QmlTimeLineCallback &QmlTimeLineCallback::operator=(const QmlTimeLineCallback &o)
{
d0 = o.d0;
d1 = o.d1;
@@ -928,12 +934,7 @@ QmlTimeLineEvent &QmlTimeLineEvent::operator=(const QmlTimeLineEvent &o)
return *this;
}
-void QmlTimeLineEvent::execute() const
-{
- d0(d1);
-}
-
-QmlTimeLineObject *QmlTimeLineEvent::eventObject() const
+QmlTimeLineObject *QmlTimeLineCallback::callbackObject() const
{
return d2;
}
diff --git a/src/declarative/util/qmltimeline_p_p.h b/src/declarative/util/qmltimeline_p_p.h
index f271a3f..076355d 100644
--- a/src/declarative/util/qmltimeline_p_p.h
+++ b/src/declarative/util/qmltimeline_p_p.h
@@ -60,10 +60,10 @@ QT_BEGIN_NAMESPACE
class QEasingCurve;
class QmlTimeLineValue;
-class QmlTimeLineEvent;
+class QmlTimeLineCallback;
struct QmlTimeLinePrivate;
class QmlTimeLineObject;
-class Q_DECLARATIVE_EXPORT QmlTimeLine : public QAbstractAnimation
+class QmlTimeLine : public QAbstractAnimation
{
Q_OBJECT
public:
@@ -75,7 +75,7 @@ public:
void setSyncMode(SyncMode);
void pause(QmlTimeLineObject &, int);
- void execute(const QmlTimeLineEvent &);
+ void callback(const QmlTimeLineCallback &);
void set(QmlTimeLineValue &, qreal);
int accel(QmlTimeLineValue &, qreal velocity, qreal accel);
@@ -117,7 +117,7 @@ private:
QmlTimeLinePrivate *d;
};
-class Q_DECLARATIVE_EXPORT QmlTimeLineObject
+class QmlTimeLineObject
{
public:
QmlTimeLineObject();
@@ -129,7 +129,7 @@ protected:
QmlTimeLine *_t;
};
-class Q_DECLARATIVE_EXPORT QmlTimeLineValue : public QmlTimeLineObject
+class QmlTimeLineValue : public QmlTimeLineObject
{
public:
QmlTimeLineValue(qreal v = 0.) : _v(v) {}
@@ -147,36 +147,21 @@ private:
qreal _v;
};
-class Q_DECLARATIVE_EXPORT QmlTimeLineEvent
+class QmlTimeLineCallback
{
public:
- QmlTimeLineEvent();
- QmlTimeLineEvent(const QmlTimeLineEvent &o);
+ typedef void (*Callback)(void *);
- template<class T, void (T::*method)()>
- static QmlTimeLineEvent timeLineEvent(QmlTimeLineObject *b, T *c)
- {
- QmlTimeLineEvent rv;
- rv.d0 = &callFunc<T, method>;
- rv.d1 = (void *)c;
- rv.d2 = b;
- return rv;
- }
+ QmlTimeLineCallback();
+ QmlTimeLineCallback(QmlTimeLineObject *b, Callback, void * = 0);
+ QmlTimeLineCallback(const QmlTimeLineCallback &o);
- QmlTimeLineEvent &operator=(const QmlTimeLineEvent &o);
- void execute() const;
- QmlTimeLineObject *eventObject() const;
+ QmlTimeLineCallback &operator=(const QmlTimeLineCallback &o);
+ QmlTimeLineObject *callbackObject() const;
private:
- typedef void (*CallFunc)(void *c);
-
- template <class T, void (T::*method)()>
- static void callFunc(void *c)
- {
- T *cls = (T *)c;
- (cls->*method)();
- }
- CallFunc d0;
+ friend class QmlTimeLinePrivate;
+ Callback d0;
void *d1;
QmlTimeLineObject *d2;
};
diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp
index e4e53d6..e2ce417 100644
--- a/src/declarative/util/qmltransition.cpp
+++ b/src/declarative/util/qmltransition.cpp
@@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass Transition QmlTransition
+ \since 4.7
\brief The Transition element defines animated transitions that occur on state changes.
\sa {qmlstates}{States}, {state-transitions}{Transitions}
@@ -82,10 +83,10 @@ class QmlTransitionPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlTransition)
public:
- QmlTransitionPrivate() : fromState(QLatin1String("*")), toState(QLatin1String("*"))
- , reversed(false), reversible(false), endState(0)
+ QmlTransitionPrivate()
+ : fromState(QLatin1String("*")), toState(QLatin1String("*")),
+ reversed(false), reversible(false), endState(0)
{
- animations.parent = this;
group.trans = this;
}
@@ -100,23 +101,15 @@ public:
{
endState->complete();
}
-
- class AnimationList : public QmlConcreteList<QmlAbstractAnimation *>
- {
- public:
- AnimationList() : parent(0) {}
- virtual void append(QmlAbstractAnimation *a);
- virtual void clear() { QmlConcreteList<QmlAbstractAnimation *>::clear(); } //###
-
- QmlTransitionPrivate *parent;
- };
- AnimationList animations;
+ static void append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a);
+ QList<QmlAbstractAnimation *> animations;
};
-void QmlTransitionPrivate::AnimationList::append(QmlAbstractAnimation *a)
+void QmlTransitionPrivate::append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a)
{
- QmlConcreteList<QmlAbstractAnimation *>::append(a);
- parent->group.addAnimation(a->qtAnimation());
+ QmlTransition *q = static_cast<QmlTransition *>(list->object);
+ q->d_func()->animations.append(a);
+ q->d_func()->group.addAnimation(a->qtAnimation());
a->setDisableUserControl();
}
@@ -245,10 +238,10 @@ void QmlTransition::setToState(const QString &t)
and assign that to animations the animations property.
\default
*/
-QmlList<QmlAbstractAnimation *>* QmlTransition::animations()
+QmlListProperty<QmlAbstractAnimation> QmlTransition::animations()
{
Q_D(QmlTransition);
- return &d->animations;
+ return QmlListProperty<QmlAbstractAnimation>(this, &d->animations, QmlTransitionPrivate::append_animation);
}
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmltransition_p.h b/src/declarative/util/qmltransition_p.h
index 5a989bc..ea02a33 100644
--- a/src/declarative/util/qmltransition_p.h
+++ b/src/declarative/util/qmltransition_p.h
@@ -65,7 +65,7 @@ class Q_DECLARATIVE_EXPORT QmlTransition : public QObject
Q_PROPERTY(QString from READ fromState WRITE setFromState)
Q_PROPERTY(QString to READ toState WRITE setToState)
Q_PROPERTY(bool reversible READ reversible WRITE setReversible)
- Q_PROPERTY(QmlList<QmlAbstractAnimation *>* animations READ animations)
+ Q_PROPERTY(QmlListProperty<QmlAbstractAnimation> animations READ animations)
Q_CLASSINFO("DefaultProperty", "animations")
Q_CLASSINFO("DeferredPropertyNames", "animations")
@@ -82,7 +82,7 @@ public:
bool reversible() const;
void setReversible(bool);
- QmlList<QmlAbstractAnimation *>* animations();
+ QmlListProperty<QmlAbstractAnimation> animations();
void prepare(QmlStateOperation::ActionList &actions,
QList<QmlMetaProperty> &after,
diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp
index 4a6d697..632e8e2 100644
--- a/src/declarative/util/qmlview.cpp
+++ b/src/declarative/util/qmlview.cpp
@@ -126,12 +126,13 @@ void FrameBreakAnimation::updateCurrentTime(int msecs)
server->frameBreak();
}
-class QmlViewPrivate : public QGraphicsViewPrivate
+class QmlViewPrivate
{
- Q_DECLARE_PUBLIC(QmlView)
public:
- QmlViewPrivate()
- : root(0), component(0), resizeMode(QmlView::SizeViewToRootObject) {}
+ QmlViewPrivate(QmlView *view)
+ : q(view), root(0), component(0), resizeMode(QmlView::SizeViewToRootObject) {}
+
+ QmlView *q;
QGuard<QGraphicsObject> root;
QGuard<QmlGraphicsItem> qmlRoot;
@@ -153,6 +154,7 @@ public:
/*!
\class QmlView
+ \since 4.7
\brief The QmlView class provides a widget for displaying a Qt Declarative user interface.
Any QGraphicsObject or QmlGraphicsItem
@@ -213,16 +215,14 @@ public:
Constructs a QmlView with the given \a parent.
*/
QmlView::QmlView(QWidget *parent)
-: QGraphicsView(*(new QmlViewPrivate), parent)
+: QGraphicsView(parent), d(new QmlViewPrivate(this))
{
- Q_D(QmlView);
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
d->init();
}
void QmlViewPrivate::init()
{
- Q_Q(QmlView);
#ifdef Q_ENABLE_PERFORMANCE_LOG
{
QmlPerfTimer<QmlPerf::FontDatabase> perf;
@@ -251,7 +251,6 @@ void QmlViewPrivate::init()
*/
QmlView::~QmlView()
{
- Q_D(QmlView);
delete d->root;
}
@@ -264,7 +263,6 @@ QmlView::~QmlView()
*/
void QmlView::setSource(const QUrl& url)
{
- Q_D(QmlView);
d->source = url;
}
@@ -275,7 +273,6 @@ void QmlView::setSource(const QUrl& url)
*/
QUrl QmlView::source() const
{
- Q_D(const QmlView);
return d->source;
}
@@ -285,7 +282,6 @@ QUrl QmlView::source() const
*/
QmlEngine* QmlView::engine()
{
- Q_D(QmlView);
return &d->engine;
}
@@ -298,7 +294,6 @@ QmlEngine* QmlView::engine()
*/
QmlContext* QmlView::rootContext()
{
- Q_D(QmlView);
return d->engine.rootContext();
}
@@ -309,7 +304,6 @@ QmlContext* QmlView::rootContext()
*/
void QmlView::execute()
{
- Q_D(QmlView);
delete d->root;
delete d->component;
d->component = new QmlComponent(&d->engine, d->source, this);
@@ -339,7 +333,6 @@ void QmlView::execute()
QmlView::Status QmlView::status() const
{
- Q_D(const QmlView);
if (!d->component)
return QmlView::Null;
@@ -352,7 +345,6 @@ QmlView::Status QmlView::status() const
*/
QList<QmlError> QmlView::errors() const
{
- Q_D(const QmlView);
if (d->component)
return d->component->errors();
return QList<QmlError>();
@@ -378,7 +370,6 @@ QList<QmlError> QmlView::errors() const
void QmlView::setResizeMode(ResizeMode mode)
{
- Q_D(QmlView);
if (d->resizeMode == mode)
return;
@@ -396,7 +387,6 @@ void QmlView::setResizeMode(ResizeMode mode)
QmlView::ResizeMode QmlView::resizeMode() const
{
- Q_D(const QmlView);
return d->resizeMode;
}
@@ -405,7 +395,6 @@ QmlView::ResizeMode QmlView::resizeMode() const
*/
void QmlView::continueExecute()
{
- Q_D(QmlView);
disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute()));
@@ -482,7 +471,6 @@ void QmlView::continueExecute()
*/
void QmlView::sizeChanged()
{
- Q_D(QmlView);
// delay, so we catch both width and height changing.
d->resizetimer.start(0,this);
}
@@ -494,7 +482,6 @@ void QmlView::sizeChanged()
*/
void QmlView::timerEvent(QTimerEvent* e)
{
- Q_D(QmlView);
if (!e || e->timerId() == d->resizetimer.timerId()) {
if (d->qmlRoot) {
QSize sz(d->qmlRoot->width(),d->qmlRoot->height());
@@ -513,7 +500,6 @@ void QmlView::timerEvent(QTimerEvent* e)
*/
QSize QmlView::sizeHint() const
{
- Q_D(const QmlView);
if (d->qmlRoot) {
if (d->initialSize.width() <= 0)
d->initialSize.setWidth(d->qmlRoot->width());
@@ -528,7 +514,6 @@ QSize QmlView::sizeHint() const
*/
QGraphicsObject *QmlView::rootObject() const
{
- Q_D(const QmlView);
return d->root;
}
@@ -539,7 +524,6 @@ QGraphicsObject *QmlView::rootObject() const
*/
void QmlView::resizeEvent(QResizeEvent *e)
{
- Q_D(QmlView);
if (d->resizeMode == SizeRootObjectToView && d->qmlRoot) {
d->qmlRoot->setWidth(width());
d->qmlRoot->setHeight(height());
@@ -559,7 +543,6 @@ void QmlView::resizeEvent(QResizeEvent *e)
*/
void QmlView::paintEvent(QPaintEvent *event)
{
- Q_D(QmlView);
int time = 0;
if (frameRateDebug() || QmlViewDebugServer::isDebuggingEnabled())
time = d->frameTimer.restart();
diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h
index 1c6d865..1d6ef1c 100644
--- a/src/declarative/util/qmlview.h
+++ b/src/declarative/util/qmlview.h
@@ -65,8 +65,6 @@ class Q_DECLARATIVE_EXPORT QmlView : public QGraphicsView
Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_DECLARE_PRIVATE(QmlView)
-
public:
explicit QmlView(QWidget *parent = 0);
virtual ~QmlView();
@@ -103,6 +101,8 @@ protected:
virtual void resizeEvent(QResizeEvent *);
virtual void paintEvent(QPaintEvent *event);
void timerEvent(QTimerEvent*);
+
+ QmlViewPrivate *d;
};
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qmlxmllistmodel.cpp
index 0e939bf..58caf12 100644
--- a/src/declarative/util/qmlxmllistmodel.cpp
+++ b/src/declarative/util/qmlxmllistmodel.cpp
@@ -65,6 +65,7 @@ QML_DEFINE_TYPE(Qt,4,6,XmlListModel,QmlXmlListModel)
/*!
\qmlclass XmlRole QmlXmlListModelRole
+ \since 4.7
\brief The XmlRole element allows you to specify a role for an XmlListModel.
*/
@@ -130,19 +131,6 @@ QML_DECLARE_TYPE(QmlXmlListModelRole)
QT_BEGIN_NAMESPACE
-class QmlXmlListModelPrivate;
-struct QmlXmlRoleList : public QmlConcreteList<QmlXmlListModelRole *>
-{
- QmlXmlRoleList(QmlXmlListModelPrivate *p)
- : model(p) {}
- virtual void append(QmlXmlListModelRole *role);
- virtual void clear();
- virtual void removeAt(int i);
- virtual void insert(int i, QmlXmlListModelRole *role);
-
- QmlXmlListModelPrivate *model;
-};
-
class QmlXmlQuery : public QThread
{
Q_OBJECT
@@ -164,7 +152,7 @@ public:
m_abort = true;
}
- int doQuery(QString query, QString namespaces, QByteArray data, QmlXmlRoleList *roleObjects) {
+ int doQuery(QString query, QString namespaces, QByteArray data, QList<QmlXmlListModelRole *> *roleObjects) {
QMutexLocker locker(&m_mutex);
m_modelData.clear();
m_size = 0;
@@ -229,7 +217,7 @@ private:
QString m_prefix;
int m_size;
int m_queryId;
- const QmlXmlRoleList *m_roleObjects;
+ const QList<QmlXmlListModelRole *> *m_roleObjects;
QList<QList<QVariant> > m_modelData;
};
@@ -347,7 +335,7 @@ public:
QmlXmlListModelPrivate()
: isComponentComplete(true), size(-1), highestRole(Qt::UserRole)
, reply(0), status(QmlXmlListModel::Null), progress(0.0)
- , queryId(-1), roleObjects(this) {}
+ , queryId(-1), roleObjects() {}
bool isComponentComplete;
QUrl src;
@@ -363,42 +351,39 @@ public:
qreal progress;
QmlXmlQuery qmlXmlQuery;
int queryId;
- QmlXmlRoleList roleObjects;
+ QList<QmlXmlListModelRole *> roleObjects;
+ static void append_role(QmlListProperty<QmlXmlListModelRole> *list, QmlXmlListModelRole *role);
+ static void clear_role(QmlListProperty<QmlXmlListModelRole> *list);
+ static void removeAt_role(QmlListProperty<QmlXmlListModelRole> *list, int i);
+ static void insert_role(QmlListProperty<QmlXmlListModelRole> *list, int i, QmlXmlListModelRole *role);
QList<QList<QVariant> > data;
};
-void QmlXmlRoleList::append(QmlXmlListModelRole *role)
+void QmlXmlListModelPrivate::append_role(QmlListProperty<QmlXmlListModelRole> *list, QmlXmlListModelRole *role)
{
- insert(size(), role);
+ QmlXmlListModel *_this = qobject_cast<QmlXmlListModel *>(list->object);
+ if (_this) {
+ 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, removeAt, and insert need to invalidate any cached data (in data table) as well
+//### clear needs to invalidate any cached data (in data table) as well
// (and the model should emit the appropriate signals)
-void QmlXmlRoleList::clear()
-{
- model->roles.clear();
- model->roleNames.clear();
- QmlConcreteList<QmlXmlListModelRole *>::clear();
-}
-
-void QmlXmlRoleList::removeAt(int i)
+void QmlXmlListModelPrivate::clear_role(QmlListProperty<QmlXmlListModelRole> *list)
{
- model->roles.removeAt(i);
- model->roleNames.removeAt(i);
- QmlConcreteList<QmlXmlListModelRole *>::removeAt(i);
-}
-
-void QmlXmlRoleList::insert(int i, QmlXmlListModelRole *role)
-{
- QmlConcreteList<QmlXmlListModelRole *>::insert(i, role);
- if (model->roleNames.contains(role->name())) {
- qmlInfo(role) << QCoreApplication::translate("QmlXmlRoleList", "\"%1\" duplicates a previous role name and will be disabled.").arg(role->name());
- return;
- }
- model->roles.insert(i, model->highestRole);
- model->roleNames.insert(i, role->name());
- ++model->highestRole;
+ QmlXmlListModel *_this = static_cast<QmlXmlListModel *>(list->object);
+ _this->d_func()->roles.clear();
+ _this->d_func()->roleNames.clear();
+ _this->d_func()->roleObjects.clear();
}
/*!
@@ -408,6 +393,7 @@ void QmlXmlRoleList::insert(int i, QmlXmlListModelRole *role)
/*!
\qmlclass XmlListModel QmlXmlListModel
+ \since 4.7
\brief The XmlListModel element allows you to specify a model using XPath expressions.
XmlListModel allows you to construct a model from XML data that can then be used as a data source
@@ -446,10 +432,13 @@ QmlXmlListModel::~QmlXmlListModel()
The roles to make available for this model.
*/
-QmlList<QmlXmlListModelRole *> *QmlXmlListModel::roleObjects()
+QmlListProperty<QmlXmlListModelRole> QmlXmlListModel::roleObjects()
{
Q_D(QmlXmlListModel);
- return &d->roleObjects;
+ QmlListProperty<QmlXmlListModelRole> list(this, d->roleObjects);
+ list.append = &QmlXmlListModelPrivate::append_role;
+ list.clear = &QmlXmlListModelPrivate::clear_role;
+ return list;
}
QHash<int,QVariant> QmlXmlListModel::data(int index, const QList<int> &roles) const
diff --git a/src/declarative/util/qmlxmllistmodel_p.h b/src/declarative/util/qmlxmllistmodel_p.h
index 51d942d..a6627e2 100644
--- a/src/declarative/util/qmlxmllistmodel_p.h
+++ b/src/declarative/util/qmlxmllistmodel_p.h
@@ -70,7 +70,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public
Q_PROPERTY(QString xml READ xml WRITE setXml)
Q_PROPERTY(QString query READ query WRITE setQuery)
Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations)
- Q_PROPERTY(QmlList<QmlXmlListModelRole *> *roles READ roleObjects)
+ Q_PROPERTY(QmlListProperty<QmlXmlListModelRole> roles READ roleObjects)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "roles")
@@ -84,7 +84,7 @@ public:
virtual QList<int> roles() const;
virtual QString toString(int role) const;
- QmlList<QmlXmlListModelRole *> *roleObjects();
+ QmlListProperty<QmlXmlListModelRole> roleObjects();
QUrl source() const;
void setSource(const QUrl&);
diff --git a/src/declarative/widgets/graphicslayouts.cpp b/src/declarative/widgets/graphicslayouts.cpp
index a8b5f70..62e941a 100644
--- a/src/declarative/widgets/graphicslayouts.cpp
+++ b/src/declarative/widgets/graphicslayouts.cpp
@@ -109,7 +109,7 @@ QSizeF QGraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, cons
QGraphicsLinearLayoutObject::QGraphicsLinearLayoutObject(QObject *parent)
-: QObject(parent), _children(this)
+: QObject(parent)
{
}
@@ -246,7 +246,7 @@ private:
QGraphicsGridLayoutObject::QGraphicsGridLayoutObject(QObject *parent)
-: QObject(parent), _children(this)
+: QObject(parent)
{
}
diff --git a/src/declarative/widgets/graphicslayouts_p.h b/src/declarative/widgets/graphicslayouts_p.h
index 030be90..3076af1 100644
--- a/src/declarative/widgets/graphicslayouts_p.h
+++ b/src/declarative/widgets/graphicslayouts_p.h
@@ -69,7 +69,7 @@ class QGraphicsLinearLayoutObject : public QObject, public QGraphicsLinearLayout
Q_OBJECT
Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem)
- Q_PROPERTY(QmlList<QGraphicsLayoutItem *> *children READ children)
+ Q_PROPERTY(QmlListProperty<QGraphicsLayoutItem> children READ children)
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing)
Q_CLASSINFO("DefaultProperty", "children")
@@ -77,7 +77,7 @@ public:
QGraphicsLinearLayoutObject(QObject * = 0);
~QGraphicsLinearLayoutObject();
- QmlList<QGraphicsLayoutItem *> *children() { return &_children; }
+ QmlListProperty<QGraphicsLayoutItem> children() { return QmlListProperty<QGraphicsLayoutItem>(this, 0, children_append, children_count, children_at, children_clear); }
static LinearLayoutAttached *qmlAttachedProperties(QObject *);
@@ -91,27 +91,21 @@ private:
void insertLayoutItem(int, QGraphicsLayoutItem *);
static QHash<QGraphicsLayoutItem*, LinearLayoutAttached*> attachedProperties;
- class ChildList : public QmlList<QGraphicsLayoutItem *>
- {
- public:
- ChildList(QGraphicsLinearLayoutObject *o)
- : obj(o) {}
-
- virtual void append(QGraphicsLayoutItem *item)
- {
- insert(-1, item);
- }
- virtual void clear() { obj->clearChildren(); }
- virtual int count() const { return obj->count(); }
- virtual void removeAt(int i) { obj->removeAt(i); }
- virtual QGraphicsLayoutItem *at(int i) const { return obj->itemAt(i); }
- virtual void insert(int i, QGraphicsLayoutItem *item) { obj->insertLayoutItem(i, item); }
-
- private:
- QGraphicsLinearLayoutObject *obj;
- };
-
- ChildList _children;
+ static void children_append(QmlListProperty<QGraphicsLayoutItem> *prop, QGraphicsLayoutItem *item) {
+ static_cast<QGraphicsLinearLayoutObject*>(prop->object)->insertLayoutItem(-1, item);
+ }
+
+ static void children_clear(QmlListProperty<QGraphicsLayoutItem> *prop) {
+ static_cast<QGraphicsLinearLayoutObject*>(prop->object)->clearChildren();
+ }
+
+ static int children_count(QmlListProperty<QGraphicsLayoutItem> *prop) {
+ return static_cast<QGraphicsLinearLayoutObject*>(prop->object)->count();
+ }
+
+ static QGraphicsLayoutItem *children_at(QmlListProperty<QGraphicsLayoutItem> *prop, int index) {
+ return static_cast<QGraphicsLinearLayoutObject*>(prop->object)->itemAt(index);
+ }
};
class GridLayoutAttached;
@@ -120,7 +114,7 @@ class QGraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout
Q_OBJECT
Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem)
- Q_PROPERTY(QmlList<QGraphicsLayoutItem *> *children READ children)
+ Q_PROPERTY(QmlListProperty<QGraphicsLayoutItem> children READ children)
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing)
Q_PROPERTY(qreal verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
Q_PROPERTY(qreal horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
@@ -129,7 +123,7 @@ public:
QGraphicsGridLayoutObject(QObject * = 0);
~QGraphicsGridLayoutObject();
- QmlList<QGraphicsLayoutItem *> *children() { return &_children; }
+ QmlListProperty<QGraphicsLayoutItem> children() { return QmlListProperty<QGraphicsLayoutItem>(this, 0, children_append, children_count, children_at, children_clear); }
qreal spacing() const;
@@ -142,30 +136,21 @@ private:
void addLayoutItem(QGraphicsLayoutItem *);
static QHash<QGraphicsLayoutItem*, GridLayoutAttached*> attachedProperties;
- class ChildList : public QmlList<QGraphicsLayoutItem *>
- {
- public:
- ChildList(QGraphicsGridLayoutObject *o)
- : obj(o) {}
-
- virtual void append(QGraphicsLayoutItem *o)
- {
- obj->addLayoutItem(o);
- }
- virtual void clear() { obj->clearChildren(); }
- virtual int count() const { return obj->count(); }
- virtual void removeAt(int i) { obj->removeAt(i); }
- virtual QGraphicsLayoutItem *at(int i) const { return obj->itemAt(i); }
- //### GridLayout doesn't have an insert, so for now we treat it as an append.
- // this is obviously potenitally dangerous -- perhaps should be a concrete
- // list with no relation to layout index, etc at all.
- virtual void insert(int, QGraphicsLayoutItem *item) { append(item); }
-
- private:
- QGraphicsGridLayoutObject *obj;
- };
-
- ChildList _children;
+ static void children_append(QmlListProperty<QGraphicsLayoutItem> *prop, QGraphicsLayoutItem *item) {
+ static_cast<QGraphicsGridLayoutObject*>(prop->object)->addLayoutItem(item);
+ }
+
+ static void children_clear(QmlListProperty<QGraphicsLayoutItem> *prop) {
+ static_cast<QGraphicsGridLayoutObject*>(prop->object)->clearChildren();
+ }
+
+ static int children_count(QmlListProperty<QGraphicsLayoutItem> *prop) {
+ return static_cast<QGraphicsGridLayoutObject*>(prop->object)->count();
+ }
+
+ static QGraphicsLayoutItem *children_at(QmlListProperty<QGraphicsLayoutItem> *prop, int index) {
+ return static_cast<QGraphicsGridLayoutObject*>(prop->object)->itemAt(index);
+ }
};
QT_END_NAMESPACE
diff --git a/src/declarative/widgets/graphicswidgets.cpp b/src/declarative/widgets/graphicswidgets.cpp
index 5c7f093..bb4dc74 100644
--- a/src/declarative/widgets/graphicswidgets.cpp
+++ b/src/declarative/widgets/graphicswidgets.cpp
@@ -63,63 +63,31 @@ class QGraphicsSceneDeclarativeUI : public QObject
{
Q_OBJECT
- Q_PROPERTY(QmlList<QObject *> *children READ children)
+ Q_PROPERTY(QmlListProperty<QObject> children READ children)
Q_CLASSINFO("DefaultProperty", "children")
public:
- QGraphicsSceneDeclarativeUI(QObject *other) : QObject(other), _children(other) {}
+ QGraphicsSceneDeclarativeUI(QObject *other) : QObject(other) {}
- QmlList<QObject *> *children() { return &_children; }
+ QmlListProperty<QObject> children() { return QmlListProperty<QObject>(this->parent(), 0, children_append); }
private:
- class Children : public QmlConcreteList<QObject *>
- {
- public:
- Children(QObject *scene) : q(scene) {}
- virtual void append(QObject *o)
- {
- insert(-1, o);
- }
- virtual void clear()
- {
- for (int i = 0; i < count(); ++i)
- if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(at(i)))
- static_cast<QGraphicsScene *>(q)->removeItem(go);
- QmlConcreteList<QObject *>::clear();
- }
- virtual void removeAt(int i)
- {
- if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(at(i)))
- static_cast<QGraphicsScene *>(q)->removeItem(go);
- QmlConcreteList<QObject *>::removeAt(i);
- }
- virtual void insert(int i, QObject *o)
- {
- QmlConcreteList<QObject *>::insert(i, o);
- if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o))
- static_cast<QGraphicsScene *>(q)->addItem(go);
- //else if (QWidget *w = qobject_cast<QWidget *>(o))
- // static_cast<QGraphicsScene *>(q)->addWidget(w);
- }
- private:
- QObject *q;
- };
- Children _children;
+ static void children_append(QmlListProperty<QObject> *prop, QObject *o) {
+ if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o))
+ static_cast<QGraphicsScene *>(prop->object)->addItem(go);
+ }
};
class QGraphicsWidgetDeclarativeUI : public QObject
{
Q_OBJECT
- Q_PROPERTY(QmlList<QObject *> *data READ data)
- Q_PROPERTY(QmlList<QGraphicsItem *> *children READ children)
+ Q_PROPERTY(QmlListProperty<QGraphicsItem> children READ children)
Q_PROPERTY(QGraphicsLayout *layout READ layout WRITE setLayout)
Q_CLASSINFO("DefaultProperty", "children")
public:
- QGraphicsWidgetDeclarativeUI(QObject *other) : QObject(other), _widgets(this) {}
-
- QmlList<QObject *> *data() { return &_data; }
+ QGraphicsWidgetDeclarativeUI(QObject *other) : QObject(other) {}
- QmlList<QGraphicsItem *> *children() { return &_widgets; }
+ QmlListProperty<QGraphicsItem> children() { return QmlListProperty<QGraphicsItem>(this, 0, children_append); }
QGraphicsLayout *layout() const { return static_cast<QGraphicsWidget *>(parent())->layout(); }
void setLayout(QGraphicsLayout *lo)
@@ -128,28 +96,14 @@ public:
}
private:
- friend class WidgetList;
void setItemParent(QGraphicsItem *wid)
{
wid->setParentItem(static_cast<QGraphicsWidget *>(parent()));
}
- class WidgetList : public QmlConcreteList<QGraphicsItem *>
- {
- public:
- WidgetList(QGraphicsWidgetDeclarativeUI *o)
- : obj(o) {}
-
- virtual void append(QGraphicsItem *w) { QmlConcreteList<QGraphicsItem *>::append(w); obj->setItemParent(w); }
- virtual void clear() { QmlConcreteList<QGraphicsItem *>::clear(); } //###
- virtual void removeAt(int i) { QmlConcreteList<QGraphicsItem *>::removeAt(i); } //###
- virtual void insert(int i, QGraphicsItem *item) { QmlConcreteList<QGraphicsItem *>::insert(i, item); obj->setItemParent(item); }
-
- private:
- QGraphicsWidgetDeclarativeUI *obj;
- };
- WidgetList _widgets;
- QmlConcreteList<QObject *> _data;
+ static void children_append(QmlListProperty<QGraphicsItem> *prop, QGraphicsItem *i) {
+ static_cast<QGraphicsWidgetDeclarativeUI*>(prop->object)->setItemParent(i);
+ }
};
QML_DEFINE_EXTENDED_TYPE(Qt,4,6,QGraphicsView,QGraphicsView,QGraphicsViewDeclarativeUI)
diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h
index 9d3edcb..729837a 100644
--- a/src/gui/graphicsview/qgraphicsview_p.h
+++ b/src/gui/graphicsview/qgraphicsview_p.h
@@ -65,7 +65,7 @@
QT_BEGIN_NAMESPACE
-class Q_AUTOTEST_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
+class Q_GUI_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
{
Q_DECLARE_PUBLIC(QGraphicsView)
public:
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 34865b5..c6e192b 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -208,11 +208,8 @@ static const char * x11_atomnames = {
"_MOTIF_WM_HINTS\0"
"DTWM_IS_RUNNING\0"
- "KDE_FULL_SESSION\0"
- "KWIN_RUNNING\0"
- "KWM_RUNNING\0"
- "GNOME_BACKGROUND_PROPERTIES\0"
"ENLIGHTENMENT_DESKTOP\0"
+ "_DT_SAVE_MODE\0"
"_SGI_DESKS_MANAGER\0"
// EWMH (aka NETWM)
@@ -626,8 +623,6 @@ static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
|| err->resourceid == XA_RGB_DEFAULT_MAP
|| err->resourceid == ATOM(_NET_SUPPORTED)
|| err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK)
- || err->resourceid == ATOM(KDE_FULL_SESSION)
- || err->resourceid == ATOM(KWIN_RUNNING)
|| err->resourceid == ATOM(XdndProxy)
|| err->resourceid == ATOM(XdndAware))) {
// Perhaps we're running under SECURITY reduction? :/
@@ -2222,87 +2217,36 @@ void qt_init(QApplicationPrivate *priv, int,
X11->desktopEnvironment = DE_UNKNOWN;
X11->desktopVersion = 0;
- // See if the current window manager is using the freedesktop.org spec to give its name
- Window windowManagerWindow = XNone;
- Atom typeReturned;
- int formatReturned;
- unsigned long nitemsReturned;
- unsigned long unused;
- unsigned char *data = 0;
- if (XGetWindowProperty(QX11Info::display(), QX11Info::appRootWindow(),
- ATOM(_NET_SUPPORTING_WM_CHECK),
- 0, 1024, False, XA_WINDOW, &typeReturned,
- &formatReturned, &nitemsReturned, &unused, &data)
- == Success) {
- if (typeReturned == XA_WINDOW && formatReturned == 32)
- windowManagerWindow = *((Window*) data);
- if (data)
- XFree(data);
-
- if (windowManagerWindow != XNone) {
- QString wmName;
- Atom utf8atom = ATOM(UTF8_STRING);
- if (XGetWindowProperty(QX11Info::display(), windowManagerWindow, ATOM(_NET_WM_NAME),
- 0, 1024, False, utf8atom, &typeReturned,
- &formatReturned, &nitemsReturned, &unused, &data)
- == Success) {
- if (typeReturned == utf8atom && formatReturned == 8)
- wmName = QString::fromUtf8((const char*)data);
- if (data)
- XFree(data);
- if (wmName == QLatin1String("KWin"))
- X11->desktopEnvironment = DE_KDE;
- if (wmName == QLatin1String("Metacity"))
- X11->desktopEnvironment = DE_GNOME;
- }
- }
- }
-
- // Running a different/newer/older window manager? Try some other things
- if (X11->desktopEnvironment == DE_UNKNOWN){
- Atom type;
- int format;
- unsigned long length, after;
- uchar *data = 0;
-
- QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION"));
- if (session == QLatin1String("kde")) {
- X11->desktopEnvironment = DE_KDE;
- } else if (session == QLatin1String("gnome") || session == QLatin1String("xfce")) {
- X11->desktopEnvironment = DE_GNOME;
- } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING),
- 0, 1, False, AnyPropertyType, &type, &format, &length,
- &after, &data) == Success && length) {
- // DTWM is running, meaning most likely CDE is running...
- X11->desktopEnvironment = DE_CDE;
- } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(),
- ATOM(GNOME_BACKGROUND_PROPERTIES), 0, 1, False, AnyPropertyType,
- &type, &format, &length, &after, &data) == Success && length) {
- X11->desktopEnvironment = DE_GNOME;
- } else if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty()) {
- X11->desktopEnvironment = DE_GNOME;
- } else if ((XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KDE_FULL_SESSION),
- 0, 1, False, AnyPropertyType, &type, &format, &length, &after, &data) == Success
- && length)
- || (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KWIN_RUNNING),
- 0, 1, False, AnyPropertyType, &type, &format, &length,
- &after, &data) == Success
- && length)
- || (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KWM_RUNNING),
- 0, 1, False, AnyPropertyType, &type, &format, &length,
- &after, &data) == Success && length)) {
- X11->desktopEnvironment = DE_KDE;
- } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_SGI_DESKS_MANAGER),
- 0, 1, False, XA_WINDOW, &type, &format, &length, &after, &data) == Success
- && length) {
- X11->desktopEnvironment = DE_4DWM;
- }
- if (data)
- XFree((char *)data);
+ Atom type;
+ int format;
+ unsigned long length, after;
+ uchar *data = 0;
+
+ if (!qgetenv("KDE_FULL_SESSION").isEmpty()) {
+ X11->desktopEnvironment = DE_KDE;
+ X11->desktopVersion = qgetenv("KDE_SESSION_VERSION").toInt();
+ } else if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty() // Deprecated for some reason.
+ || qgetenv("DESKTOP_SESSION") == "gnome") { // De-facto-standardized by GNOME.
+ X11->desktopEnvironment = DE_GNOME;
+ } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_DT_SAVE_MODE),
+ 0, 2, False, XA_STRING, &type, &format, &length,
+ &after, &data) == Success
+ && !strcmp(reinterpret_cast<char *>(data), "xfce4")) {
+ // Pretend that xfce4 is gnome, as it uses the same libraries.
+ // The detection above is stolen from xdg-open.
+ X11->desktopEnvironment = DE_GNOME;
+ } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING),
+ 0, 1, False, AnyPropertyType, &type, &format, &length,
+ &after, &data) == Success && length) {
+ // DTWM is running, meaning most likely CDE is running...
+ X11->desktopEnvironment = DE_CDE;
+ } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_SGI_DESKS_MANAGER),
+ 0, 1, False, XA_WINDOW, &type, &format, &length, &after, &data) == Success
+ && length) {
+ X11->desktopEnvironment = DE_4DWM;
}
-
- if (X11->desktopEnvironment == DE_KDE)
- X11->desktopVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();
+ if (data)
+ XFree((char *)data);
#if !defined(QT_NO_STYLE_GTK)
if (X11->desktopEnvironment == DE_GNOME) {
diff --git a/src/gui/kernel/qcocoaapplication_mac.mm b/src/gui/kernel/qcocoaapplication_mac.mm
index 5629940..4962863 100644
--- a/src/gui/kernel/qcocoaapplication_mac.mm
+++ b/src/gui/kernel/qcocoaapplication_mac.mm
@@ -79,6 +79,8 @@
#include <private/qcocoaapplicationdelegate_mac_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
+QT_USE_NAMESPACE
+
@implementation NSApplication (QT_MANGLE_NAMESPACE(QApplicationIntegration))
- (void)QT_MANGLE_NAMESPACE(qt_setDockMenu):(NSMenu *)newMenu
@@ -107,7 +109,6 @@
| NSFontPanelStrikethroughEffectModeMask;
}
-
- (void)qt_sendPostedMessage:(NSEvent *)event
{
// WARNING: data1 and data2 is truncated to from 64-bit to 32-bit on OS 10.5!
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index d5e7534..455176e 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -83,6 +83,7 @@ extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); // qapplication.cpp
extern OSViewRef qt_mac_nativeview_for(const QWidget *w); // qwidget_mac.mm
extern QPointer<QWidget> qt_mouseover; //qapplication_mac.mm
extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
+extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum);
struct dndenum_mapper
{
@@ -692,7 +693,6 @@ extern "C" {
qt_button_down = 0;
}
-extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum);
- (void)otherMouseDown:(NSEvent *)theEvent
{
if (!qt_button_down)
diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm
index 99b77d0..afea3ec 100644
--- a/src/gui/kernel/qeventdispatcher_mac.mm
+++ b/src/gui/kernel/qeventdispatcher_mac.mm
@@ -573,6 +573,18 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
QMacCocoaAutoReleasePool pool;
NSEvent* event = 0;
+ // First, send all previously excluded input events, if any:
+ if (!(flags & QEventLoop::ExcludeUserInputEvents)) {
+ while (!d->queuedUserInputEvents.isEmpty()) {
+ event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst());
+ if (!filterEvent(event)) {
+ qt_mac_send_event(flags, event, 0);
+ retVal = true;
+ }
+ [event release];
+ }
+ }
+
// If Qt is used as a plugin, or as an extension in a native cocoa
// application, we should not run or stop NSApplication; This will be
// done from the application itself. And if processEvents is called
@@ -606,49 +618,33 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
// We cannot block the thread (and run in a tight loop).
// Instead we will process all current pending events and return.
d->ensureNSAppInitialized();
- do {
- bool releaseEvent = false;
-
- if (!(flags & QEventLoop::ExcludeUserInputEvents)
- && !d->queuedUserInputEvents.isEmpty()) {
- // Process a pending user input event
- releaseEvent = true;
- event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst());
- } else {
- if (NSModalSession session = d->currentModalSession()) {
- if (flags & QEventLoop::WaitForMoreEvents)
- qt_mac_waitForMoreModalSessionEvents();
- NSInteger status = [NSApp runModalSession:session];
- if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
- // INVARIANT: Someone called [NSApp stopModal:] from outside the event
- // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
- // 'session' as well. As a result, we need to restart all internal sessions:
- d->temporarilyStopAllModalSessions();
- }
- retVal = true;
- break;
- } else {
- event = [NSApp nextEventMatchingMask:NSAnyEventMask
- untilDate:nil
- inMode:NSDefaultRunLoopMode
- dequeue: YES];
-
- if (event != nil) {
- if (flags & QEventLoop::ExcludeUserInputEvents) {
- if (IsMouseOrKeyEvent(event)) {
- [event retain];
- d->queuedUserInputEvents.append(event);
- continue;
- }
- }
- }
- }
+ if (NSModalSession session = d->currentModalSession()) {
+ if (flags & QEventLoop::WaitForMoreEvents)
+ qt_mac_waitForMoreModalSessionEvents();
+ NSInteger status = [NSApp runModalSession:session];
+ if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
+ // INVARIANT: Someone called [NSApp stopModal:] from outside the event
+ // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
+ // 'session' as well. As a result, we need to restart all internal sessions:
+ d->temporarilyStopAllModalSessions();
}
+ retVal = true;
+ } else do {
+ event = [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:nil
+ inMode:NSDefaultRunLoopMode
+ dequeue: YES];
+
if (event) {
+ if (flags & QEventLoop::ExcludeUserInputEvents) {
+ if (IsMouseOrKeyEvent(event)) {
+ [event retain];
+ d->queuedUserInputEvents.append(event);
+ continue;
+ }
+ }
if (!filterEvent(event) && qt_mac_send_event(flags, event, 0))
retVal = true;
- if (releaseEvent)
- [event release];
}
} while (!d->interrupt && event != nil);
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 901bf0e..e9fdbda 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -138,7 +138,6 @@ void QMacWindowFader::performFade()
}
extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // qapplication.cpp;
-extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
extern QWidget * mac_mouse_grabber;
extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
@@ -971,7 +970,7 @@ bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */ev
#ifndef QT_NAMESPACE
Q_ASSERT(clickCount > 0);
#endif
- if (clickCount % 2 == 0)
+ if (clickCount % 2 == 0 && buttons == button)
eventType = QEvent::MouseButtonDblClick;
if (button == Qt::LeftButton && (keyMods & Qt::MetaModifier)) {
button = Qt::RightButton;
@@ -983,6 +982,7 @@ bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */ev
button = Qt::RightButton;
[theView qt_setLeftButtonIsRightButton: false];
}
+ qt_button_down = 0;
break;
}
[QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->localPoint = localPoint;
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index b2ce754..167557b 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -564,11 +564,8 @@ struct QX11Data
_MOTIF_WM_HINTS,
DTWM_IS_RUNNING,
- KDE_FULL_SESSION,
- KWIN_RUNNING,
- KWM_RUNNING,
- GNOME_BACKGROUND_PROPERTIES,
ENLIGHTENMENT_DESKTOP,
+ _DT_SAVE_MODE,
_SGI_DESKS_MANAGER,
// EWMH (aka NETWM)
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 9e642b9..da9e9eb 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2853,13 +2853,14 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
//recreate and setup flags
QObjectPrivate::setParent_helper(parent);
- QPoint pt = q->pos();
bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
if (wasCreated && !qt_isGenuineQWidget(q))
return;
- if ((data.window_flags & Qt::Sheet) && topData && topData->opacity == 242)
+ if (!q->testAttribute(Qt::WA_WState_WindowOpacitySet)) {
q->setWindowOpacity(1.0f);
+ q->setAttribute(Qt::WA_WState_WindowOpacitySet, false);
+ }
setWinId(0); //do after the above because they may want the id
diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h
index 1e59944..00d42e0 100644
--- a/src/gui/text/qstatictext.h
+++ b/src/gui/text/qstatictext.h
@@ -97,10 +97,10 @@ private:
friend class QStaticTextPrivate;
};
-Q_DECLARE_METATYPE(QStaticText)
-
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QStaticText)
+
QT_END_HEADER
#endif // QSTATICTEXT_H
diff --git a/src/gui/util/qsystemtrayicon_mac.mm b/src/gui/util/qsystemtrayicon_mac.mm
index 5cadbbd..348657e 100644
--- a/src/gui/util/qsystemtrayicon_mac.mm
+++ b/src/gui/util/qsystemtrayicon_mac.mm
@@ -93,6 +93,7 @@ extern bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret); //q
extern void qtsystray_sendActivated(QSystemTrayIcon *i, int r); //qsystemtrayicon.cpp
extern NSString *keySequenceToKeyEqivalent(const QKeySequence &accel); // qmenu_mac.mm
extern NSUInteger keySequenceModifierMask(const QKeySequence &accel); // qmenu_mac.mm
+extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum);
QT_END_NAMESPACE
QT_USE_NAMESPACE
@@ -382,7 +383,6 @@ QT_END_NAMESPACE
[self menuTrackingDone:nil];
}
-extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum);
- (void)otherMouseDown:(NSEvent *)mouseEvent
{
[self mousePressed:mouseEvent button:cocoaButton2QtButton([mouseEvent buttonNumber])];
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index 7c72859..9a0d66f 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
class QScrollBar;
class QAbstractScrollAreaScrollBarContainer;
-class Q_AUTOTEST_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate
+class Q_GUI_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate
{
Q_DECLARE_PUBLIC(QAbstractScrollArea)
diff --git a/src/multimedia/base/qmediaserviceprovider.cpp b/src/multimedia/base/qmediaserviceprovider.cpp
index 8d1e0fa..76377d9 100644
--- a/src/multimedia/base/qmediaserviceprovider.cpp
+++ b/src/multimedia/base/qmediaserviceprovider.cpp
@@ -48,7 +48,7 @@
#include "qmediapluginloader_p.h"
#include <QtMultimedia/qmediaplayer.h>
-
+QT_BEGIN_NAMESPACE
class QMediaServiceProviderHintPrivate : public QSharedData
{
@@ -594,6 +594,8 @@ QMediaServiceProvider *QMediaServiceProvider::defaultServiceProvider()
#endif
}
+QT_END_NAMESPACE
+
/*!
\class QMediaServiceProviderPlugin
\preliminary
@@ -697,5 +699,7 @@ QMediaServiceProvider *QMediaServiceProvider::defaultServiceProvider()
Returns a set of features supported by a plug-in \a service.
*/
+QT_END_NAMESPACE
+
#include "moc_qmediaserviceprovider.cpp"
#include "moc_qmediaserviceproviderplugin.cpp"
diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp
index 5f50fdb..ca34993 100644
--- a/src/multimedia/playback/qmediaplayer.cpp
+++ b/src/multimedia/playback/qmediaplayer.cpp
@@ -947,9 +947,8 @@ QStringList QMediaPlayer::supportedMimeTypes(Flags flags)
Such playback service can be used for beeps, ringtones, etc.
*/
-#include "moc_qmediaplayer.cpp"
-
QT_END_NAMESPACE
-QT_END_NAMESPACE
+QT_END_HEADER
+#include "moc_qmediaplayer.cpp"
diff --git a/src/multimedia/qml/qmlaudio.cpp b/src/multimedia/qml/qmlaudio.cpp
index b54d644..89f045e 100644
--- a/src/multimedia/qml/qmlaudio.cpp
+++ b/src/multimedia/qml/qmlaudio.cpp
@@ -315,7 +315,7 @@ QmlAudio::Error QmlAudio::error() const
/*!
\qmlsignal Audio::onError(error, errorString)
- This property is called when an \l {Error}{error} has occurred. The errorString parameter
+ This handler is called when an \l {Error}{error} has occurred. The errorString parameter
may contain more detailed information about the error.
*/
diff --git a/src/multimedia/qml/qmlgraphicsvideo.cpp b/src/multimedia/qml/qmlgraphicsvideo.cpp
index 9e30774..7289f4d 100644
--- a/src/multimedia/qml/qmlgraphicsvideo.cpp
+++ b/src/multimedia/qml/qmlgraphicsvideo.cpp
@@ -316,7 +316,7 @@ QmlGraphicsVideo::Error QmlGraphicsVideo::error() const
/*!
\qmlsignal Video::onError(error, errorString)
- This property is called when an \l {Error}{error} has occurred. The errorString parameter
+ This handler is called when an \l {Error}{error} has occurred. The errorString parameter
may contain more detailed information about the error.
*/
diff --git a/src/multimedia/qml/qsoundeffect.cpp b/src/multimedia/qml/qsoundeffect.cpp
index f0c9659..919aa75 100644
--- a/src/multimedia/qml/qsoundeffect.cpp
+++ b/src/multimedia/qml/qsoundeffect.cpp
@@ -52,6 +52,7 @@
#include "qsoundeffect_qsound_p.h"
#endif
+QT_BEGIN_NAMESPACE
/*!
\qmlclass SoundEffect QSoundEffect
@@ -139,7 +140,7 @@
QSoundEffect::QSoundEffect(QObject *parent) :
QObject(parent),
m_loopCount(1),
- m_volume(100),
+ m_vol(100),
m_muted(false),
m_runningCount(0)
{
@@ -165,7 +166,7 @@ void QSoundEffect::setSource(const QUrl &url)
if (d != 0 && d->media().canonicalUrl() == url)
return;
- d->setVolume(m_volume);
+ d->setVolume(m_vol);
d->setMuted(m_muted);
d->setMedia(url);
@@ -191,15 +192,15 @@ void QSoundEffect::setLoopCount(int loopCount)
int QSoundEffect::volume() const
{
- return d != 0 ? d->volume() : m_volume;
+ return d != 0 ? d->volume() : m_vol;
}
void QSoundEffect::setVolume(int volume)
{
- if (m_volume == volume)
+ if (m_vol == volume)
return;
- m_volume = volume;
+ m_vol = volume;
if (d != 0)
d->setVolume(volume);
else
@@ -250,3 +251,4 @@ void QSoundEffect::repeat()
}
}
+QT_END_NAMESPACE
diff --git a/src/multimedia/qml/qsoundeffect_p.h b/src/multimedia/qml/qsoundeffect_p.h
index ab6f9e5..4b440ec 100644
--- a/src/multimedia/qml/qsoundeffect_p.h
+++ b/src/multimedia/qml/qsoundeffect_p.h
@@ -109,7 +109,7 @@ private:
Q_DISABLE_COPY(QSoundEffect)
int m_loopCount;
- int m_volume;
+ int m_vol;
bool m_muted;
int m_runningCount;
diff --git a/src/multimedia/qml/qsoundeffect_pulse_p.cpp b/src/multimedia/qml/qsoundeffect_pulse_p.cpp
index 7057022..ec851aa 100644
--- a/src/multimedia/qml/qsoundeffect_pulse_p.cpp
+++ b/src/multimedia/qml/qsoundeffect_pulse_p.cpp
@@ -67,6 +67,8 @@
#include <pulse/ext-stream-restore.h>
#endif
+#include <unistd.h>
+
// Less than ideal
#define PA_SCACHE_ENTRY_SIZE_MAX (1024*1024*16)
@@ -128,13 +130,13 @@ public:
int volume()
{
- return m_volume;
+ return m_vol;
}
private:
void prepare()
{
- m_volume = 100;
+ m_vol = 100;
m_mainLoop = pa_threaded_mainloop_new();
if (m_mainLoop == 0) {
@@ -215,13 +217,13 @@ private:
const unsigned str_length = 256;
char str[str_length];
pa_cvolume_snprint(str, str_length, &info->volume);
- self->m_volume = QString(str).replace(" ","").replace("%","").mid(2).toInt();
+ self->m_vol = QString(str).replace(" ","").replace("%","").mid(2).toInt();
}
}
}
#endif
- int m_volume;
+ int m_vol;
bool m_prepared;
pa_context *m_context;
pa_threaded_mainloop *m_mainLoop;
@@ -236,7 +238,7 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
QObject(parent),
m_muted(false),
m_playQueued(false),
- m_volume(100),
+ m_vol(100),
m_duration(0),
m_dataUploaded(0),
m_state(QMediaPlayer::StoppedState),
@@ -260,7 +262,7 @@ qint64 QSoundEffectPrivate::duration() const
int QSoundEffectPrivate::volume() const
{
- return m_volume;
+ return m_vol;
}
bool QSoundEffectPrivate::isMuted() const
@@ -298,7 +300,7 @@ void QSoundEffectPrivate::play()
daemon()->lock();
#if(Q_WS_MAEMO_5)
- m_vol = PA_VOLUME_NORM/100*((daemon()->volume()+m_volume)/2);
+ m_vol = PA_VOLUME_NORM/100*((daemon()->volume()+m_vol)/2);
#endif
pa_operation_unref(
pa_context_play_sample(daemon()->context(),
@@ -322,7 +324,7 @@ void QSoundEffectPrivate::stop()
void QSoundEffectPrivate::setVolume(int volume)
{
- m_volume = volume;
+ m_vol = volume;
}
void QSoundEffectPrivate::setMuted(bool muted)
diff --git a/src/multimedia/qml/qsoundeffect_pulse_p.h b/src/multimedia/qml/qsoundeffect_pulse_p.h
index 58a05d2..247f8a3 100644
--- a/src/multimedia/qml/qsoundeffect_pulse_p.h
+++ b/src/multimedia/qml/qsoundeffect_pulse_p.h
@@ -117,7 +117,7 @@ private:
bool m_muted;
bool m_playQueued;
- int m_volume;
+ int m_vol;
int m_duration;
int m_dataUploaded;
QTime m_playbackTime;
diff --git a/src/multimedia/qml/qsoundeffect_qmedia_p.cpp b/src/multimedia/qml/qsoundeffect_qmedia_p.cpp
index e5ac0d3..886380a 100644
--- a/src/multimedia/qml/qsoundeffect_qmedia_p.cpp
+++ b/src/multimedia/qml/qsoundeffect_qmedia_p.cpp
@@ -62,7 +62,7 @@
QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
QObject(parent),
m_muted(false),
- m_volume(100),
+ m_vol(100),
m_player(0)
{
}
@@ -83,7 +83,7 @@ int QSoundEffectPrivate::volume() const
{
if (m_player) return m_player->volume();
- return m_volume;
+ return m_vol;
}
bool QSoundEffectPrivate::isMuted() const
@@ -128,7 +128,7 @@ void QSoundEffectPrivate::stop()
void QSoundEffectPrivate::setVolume(int volume)
{
- m_volume = volume;
+ m_vol = volume;
if (m_player)
m_player->setVolume(volume);
@@ -149,7 +149,7 @@ void QSoundEffectPrivate::setMedia(const QMediaContent &media)
if (m_player == 0) {
m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency);
- m_player->setVolume(m_volume);
+ m_player->setVolume(m_vol);
m_player->setMuted(m_muted);
connect(m_player, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int)));
diff --git a/src/multimedia/qml/qsoundeffect_qmedia_p.h b/src/multimedia/qml/qsoundeffect_qmedia_p.h
index e17d720..8267f79 100644
--- a/src/multimedia/qml/qsoundeffect_qmedia_p.h
+++ b/src/multimedia/qml/qsoundeffect_qmedia_p.h
@@ -98,7 +98,7 @@ Q_SIGNALS:
private:
bool m_muted;
- int m_volume;
+ int m_vol;
QMediaPlayer *m_player;
};
diff --git a/src/multimedia/qml/qsoundeffect_qsound_p.cpp b/src/multimedia/qml/qsoundeffect_qsound_p.cpp
index 33f5bd4..0292d26 100644
--- a/src/multimedia/qml/qsoundeffect_qsound_p.cpp
+++ b/src/multimedia/qml/qsoundeffect_qsound_p.cpp
@@ -65,6 +65,7 @@
#include "qsoundeffect_qsound_p.h"
+QT_BEGIN_NAMESPACE
QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
QObject(parent),
@@ -221,3 +222,4 @@ void QSoundEffectPrivate::unloadSample()
m_sound = 0;
}
+QT_END_NAMESPACE
diff --git a/src/multimedia/qml/wavedecoder_p.cpp b/src/multimedia/qml/wavedecoder_p.cpp
index 5fc5a96..b7d6101 100644
--- a/src/multimedia/qml/wavedecoder_p.cpp
+++ b/src/multimedia/qml/wavedecoder_p.cpp
@@ -44,6 +44,8 @@
#include <QtCore/qtimer.h>
#include <QtCore/qendian.h>
+QT_BEGIN_NAMESPACE
+
WaveDecoder::WaveDecoder(QIODevice *s, QObject *parent):
QIODevice(parent),
haveFormat(false),
@@ -134,3 +136,5 @@ void WaveDecoder::handleData()
emit formatKnown();
}
}
+
+QT_END_NAMESPACE
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index a890b3b..a169ca0 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -185,6 +185,9 @@ void QNativeSocketEnginePrivate::setError(QAbstractSocket::SocketError error, Er
// socket to recreate its engine after an error. Note: There's
// one exception: SocketError(11) bypasses this as it's purely
// a temporary internal error condition.
+ // Another exception is the way the waitFor*() functions set
+ // an error when a timeout occurs. After the call to setError()
+ // they reset the hasSetSocketError to false
return;
}
if (error != QAbstractSocket::SocketError(11))
@@ -859,6 +862,7 @@ bool QNativeSocketEngine::waitForRead(int msecs, bool *timedOut)
*timedOut = true;
d->setError(QAbstractSocket::SocketTimeoutError,
QNativeSocketEnginePrivate::TimeOutErrorString);
+ d->hasSetSocketError = false; // A timeout error is temporary in waitFor functions
return false;
} else if (state() == QAbstractSocket::ConnectingState) {
connectToHost(d->peerAddress, d->peerPort);
@@ -927,6 +931,7 @@ bool QNativeSocketEngine::waitForWrite(int msecs, bool *timedOut)
*timedOut = true;
d->setError(QAbstractSocket::SocketTimeoutError,
QNativeSocketEnginePrivate::TimeOutErrorString);
+ d->hasSetSocketError = false; // A timeout error is temporary in waitFor functions
return false;
} else if (state() == QAbstractSocket::ConnectingState) {
connectToHost(d->peerAddress, d->peerPort);
@@ -978,6 +983,7 @@ bool QNativeSocketEngine::waitForReadOrWrite(bool *readyToRead, bool *readyToWri
*timedOut = true;
d->setError(QAbstractSocket::SocketTimeoutError,
QNativeSocketEnginePrivate::TimeOutErrorString);
+ d->hasSetSocketError = false; // A timeout error is temporary in waitFor functions
return false;
} else if (state() == QAbstractSocket::ConnectingState) {
connectToHost(d->peerAddress, d->peerPort);
diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm
index 5507633..d516a99 100644
--- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm
+++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm
@@ -55,9 +55,6 @@
#include <QtCore/qurl.h>
#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
@interface QTMovieObserver : NSObject
{
@private
@@ -149,6 +146,8 @@ QT_BEGIN_NAMESPACE
@end
+QT_BEGIN_NAMESPACE
+
static CFStringRef qString2CFStringRef(const QString &string)
{
return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(string.unicode()),
diff --git a/src/plugins/mediaservices/qt7/qcvdisplaylink.mm b/src/plugins/mediaservices/qt7/qcvdisplaylink.mm
index 98ae71d..00b4dc5 100644
--- a/src/plugins/mediaservices/qt7/qcvdisplaylink.mm
+++ b/src/plugins/mediaservices/qt7/qcvdisplaylink.mm
@@ -44,8 +44,7 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
-
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
static CVReturn CVDisplayLinkCallback(CVDisplayLinkRef displayLink,
const CVTimeStamp *inNow,
diff --git a/src/plugins/mediaservices/qt7/qt7movievideowidget.h b/src/plugins/mediaservices/qt7/qt7movievideowidget.h
index 3acd373..558c3d7 100644
--- a/src/plugins/mediaservices/qt7/qt7movievideowidget.h
+++ b/src/plugins/mediaservices/qt7/qt7movievideowidget.h
@@ -57,10 +57,10 @@
QT_BEGIN_HEADER
-class GLVideoWidget;
QT_BEGIN_NAMESPACE
+class GLVideoWidget;
class QCvDisplayLink;
class QT7PlayerSession;
class QT7PlayerService;
diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm
index b549487..b90470c 100644
--- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm
+++ b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm
@@ -49,8 +49,6 @@
#include <QtCore/qdebug.h>
-QT_BEGIN_NAMESPACE
-
#define VIDEO_TRANSPARENT(m) -(void)m:(NSEvent *)e{[[self superview] m:e];}
@interface TransparentQTMovieView : QTMovieView
@@ -308,5 +306,3 @@ void QT7MovieViewOutput::setSaturation(int saturation)
{
m_saturation = saturation;
}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm
index 342feb8..7271f5b 100644
--- a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm
+++ b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm
@@ -99,6 +99,7 @@ private:
MapMode m_mode;
};
+QT_END_NAMESPACE
#define VIDEO_TRANSPARENT(m) -(void)m:(NSEvent *)e{[[self superview] m:e];}
@@ -223,6 +224,7 @@ VIDEO_TRANSPARENT(scrollWheel)
@end
+QT_BEGIN_NAMESPACE
QT7MovieViewRenderer::QT7MovieViewRenderer(QObject *parent)
:QT7VideoRendererControl(parent),
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 237b6fd..98a24d0 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -24,7 +24,6 @@
#include "config.h"
#include "qscriptengine.h"
#include "qscriptsyntaxchecker_p.h"
-#include "qnumeric.h"
#include "qscriptengine_p.h"
#include "qscriptengineagent_p.h"
@@ -41,12 +40,11 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qmetaobject.h>
+#include <math.h>
+
#include "Error.h"
-#include "JSArray.h"
#include "JSLock.h"
#include "Interpreter.h"
-#include "DateConstructor.h"
-#include "RegExpConstructor.h"
#include "PrototypeFunction.h"
#include "InitializeThreading.h"
@@ -56,11 +54,10 @@
#include "TimeoutChecker.h"
#include "JSFunction.h"
#include "Parser.h"
+#include "PropertyNameArray.h"
#include "Operations.h"
-#include "utils/qscriptdate_p.h"
#include "bridge/qscriptfunction_p.h"
-#include "bridge/qscriptobject_p.h"
#include "bridge/qscriptclassobject_p.h"
#include "bridge/qscriptvariant_p.h"
#include "bridge/qscriptqobject_p.h"
@@ -328,6 +325,89 @@ public:
namespace QScript
{
+static const qsreal D32 = 4294967296.0;
+
+qint32 ToInt32(qsreal n)
+{
+ if (qIsNaN(n) || qIsInf(n) || (n == 0))
+ return 0;
+
+ qsreal sign = (n < 0) ? -1.0 : 1.0;
+ qsreal 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);
+}
+
+quint32 ToUInt32(qsreal n)
+{
+ if (qIsNaN(n) || qIsInf(n) || (n == 0))
+ return 0;
+
+ qsreal sign = (n < 0) ? -1.0 : 1.0;
+ qsreal abs_n = fabs(n);
+
+ n = ::fmod(sign * ::floor(abs_n), D32);
+
+ if (n < 0)
+ n += D32;
+
+ return quint32 (n);
+}
+
+quint16 ToUInt16(qsreal n)
+{
+ static const qsreal D16 = 65536.0;
+
+ if (qIsNaN(n) || qIsInf(n) || (n == 0))
+ return 0;
+
+ qsreal sign = (n < 0) ? -1.0 : 1.0;
+ qsreal abs_n = fabs(n);
+
+ n = ::fmod(sign * ::floor(abs_n), D16);
+
+ if (n < 0)
+ n += D16;
+
+ return quint16 (n);
+}
+
+qsreal ToInteger(qsreal n)
+{
+ if (qIsNaN(n))
+ return 0;
+
+ if (n == 0 || qIsInf(n))
+ return n;
+
+ int sign = n < 0 ? -1 : 1;
+ return sign * ::floor(::fabs(n));
+}
+
+#ifdef Q_CC_MSVC
+// MSVC2008 crashes if these are inlined.
+
+QString ToString(qsreal value)
+{
+ return JSC::UString::from(value);
+}
+
+qsreal ToNumber(const QString &value)
+{
+ return ((JSC::UString)value).toDouble();
+}
+
+#endif
+
void GlobalClientData::mark(JSC::MarkStack& markStack)
{
engine->mark(markStack);
@@ -482,11 +562,9 @@ JSC::JSValue JSC_HOST_CALL functionDisconnect(JSC::ExecState *exec, JSC::JSObjec
if (isFunction(arg1))
slot = arg1;
else {
- // ### don't go via QScriptValue
QScript::SaveFrameHelper saveFrame(engine, exec);
- QScriptValue tmp = engine->scriptValueFromJSCValue(arg0);
- QString propertyName(arg1.toString(exec));
- slot = engine->scriptValueToJSCValue(tmp.property(propertyName, QScriptValue::ResolvePrototype));
+ QString propertyName(QScriptEnginePrivate::toString(exec, arg1));
+ slot = QScriptEnginePrivate::property(exec, arg0, propertyName, QScriptValue::ResolvePrototype);
}
}
@@ -566,11 +644,9 @@ JSC::JSValue JSC_HOST_CALL functionConnect(JSC::ExecState *exec, JSC::JSObject *
if (isFunction(arg1))
slot = arg1;
else {
- // ### don't go via QScriptValue
QScript::SaveFrameHelper saveFrame(engine, exec);
- QScriptValue tmp = engine->scriptValueFromJSCValue(arg0);
- QString propertyName = arg1.toString(exec);
- slot = engine->scriptValueToJSCValue(tmp.property(propertyName, QScriptValue::ResolvePrototype));
+ QString propertyName = QScriptEnginePrivate::toString(exec, arg1);
+ slot = QScriptEnginePrivate::property(exec, arg0, propertyName, QScriptValue::ResolvePrototype);
}
}
@@ -844,22 +920,15 @@ QScriptEnginePrivate::~QScriptEnginePrivate()
}
}
-QScriptValue QScriptEnginePrivate::scriptValueFromVariant(const QVariant &v)
-{
- QScriptValue result = create(v.userType(), v.data());
- Q_ASSERT(result.isValid());
- return result;
-}
-
-QVariant QScriptEnginePrivate::scriptValueToVariant(const QScriptValue &value, int targetType)
+QVariant QScriptEnginePrivate::jscValueToVariant(JSC::ExecState *exec, JSC::JSValue value, int targetType)
{
QVariant v(targetType, (void *)0);
- if (QScriptEnginePrivate::convert(value, targetType, v.data(), this))
+ if (convertValue(exec, value, targetType, v.data()))
return v;
if (uint(targetType) == QVariant::LastType)
- return value.toVariant();
- if (value.isVariant()) {
- v = value.toVariant();
+ return toVariant(exec, value);
+ if (isVariant(value)) {
+ v = variantValue(value);
if (v.canConvert(QVariant::Type(targetType))) {
v.convert(QVariant::Type(targetType));
return v;
@@ -870,88 +939,61 @@ QVariant QScriptEnginePrivate::scriptValueToVariant(const QScriptValue &value, i
return QVariant(targetType, *reinterpret_cast<void* *>(v.data()));
}
}
-
return QVariant();
}
-JSC::JSValue QScriptEnginePrivate::jscValueFromVariant(const QVariant &v)
+JSC::JSValue QScriptEnginePrivate::arrayFromStringList(JSC::ExecState *exec, const QStringList &lst)
{
- // ### it's inefficient to convert to QScriptValue and then to JSValue
- QScriptValue vv = scriptValueFromVariant(v);
- QScriptValuePrivate *p = QScriptValuePrivate::get(vv);
- switch (p->type) {
- case QScriptValuePrivate::JavaScriptCore:
- return p->jscValue;
- case QScriptValuePrivate::Number:
- return JSC::jsNumber(currentFrame, p->numberValue);
- case QScriptValuePrivate::String: {
- JSC::UString str = p->stringValue;
- return JSC::jsString(currentFrame, str);
- }
- }
- return JSC::JSValue();
-}
-
-QVariant QScriptEnginePrivate::jscValueToVariant(JSC::JSValue value, int targetType)
-{
- // ### it's inefficient to convert to QScriptValue and then to QVariant
- return scriptValueToVariant(scriptValueFromJSCValue(value), targetType);
-}
-
-QScriptValue QScriptEnginePrivate::arrayFromStringList(const QStringList &lst)
-{
- Q_Q(QScriptEngine);
- QScriptValue arr = q->newArray(lst.size());
+ JSC::JSValue arr = newArray(exec, lst.size());
for (int i = 0; i < lst.size(); ++i)
- arr.setProperty(i, QScriptValue(q, lst.at(i)));
+ setProperty(exec, arr, i, JSC::jsString(exec, lst.at(i)));
return arr;
}
-QStringList QScriptEnginePrivate::stringListFromArray(const QScriptValue &arr)
+QStringList QScriptEnginePrivate::stringListFromArray(JSC::ExecState *exec, JSC::JSValue arr)
{
QStringList lst;
- uint len = arr.property(QLatin1String("length")).toUInt32();
+ uint len = toUInt32(exec, property(exec, arr, exec->propertyNames().length));
for (uint i = 0; i < len; ++i)
- lst.append(arr.property(i).toString());
+ lst.append(toString(exec, property(exec, arr, i)));
return lst;
}
-QScriptValue QScriptEnginePrivate::arrayFromVariantList(const QVariantList &lst)
+JSC::JSValue QScriptEnginePrivate::arrayFromVariantList(JSC::ExecState *exec, const QVariantList &lst)
{
- Q_Q(QScriptEngine);
- QScriptValue arr = q->newArray(lst.size());
+ JSC::JSValue arr = newArray(exec, lst.size());
for (int i = 0; i < lst.size(); ++i)
- arr.setProperty(i, scriptValueFromVariant(lst.at(i)));
+ setProperty(exec, arr, i, jscValueFromVariant(exec, lst.at(i)));
return arr;
}
-QVariantList QScriptEnginePrivate::variantListFromArray(const QScriptValue &arr)
+QVariantList QScriptEnginePrivate::variantListFromArray(JSC::ExecState *exec, JSC::JSValue arr)
{
QVariantList lst;
- uint len = arr.property(QLatin1String("length")).toUInt32();
+ uint len = toUInt32(exec, property(exec, arr, exec->propertyNames().length));
for (uint i = 0; i < len; ++i)
- lst.append(arr.property(i).toVariant());
+ lst.append(toVariant(exec, property(exec, arr, i)));
return lst;
}
-QScriptValue QScriptEnginePrivate::objectFromVariantMap(const QVariantMap &vmap)
+JSC::JSValue QScriptEnginePrivate::objectFromVariantMap(JSC::ExecState *exec, const QVariantMap &vmap)
{
- Q_Q(QScriptEngine);
- QScriptValue obj = q->newObject();
+ JSC::JSValue obj = JSC::constructEmptyObject(exec);
QVariantMap::const_iterator it;
for (it = vmap.constBegin(); it != vmap.constEnd(); ++it)
- obj.setProperty(it.key(), scriptValueFromVariant(it.value()));
+ setProperty(exec, obj, it.key(), jscValueFromVariant(exec, it.value()));
return obj;
}
-QVariantMap QScriptEnginePrivate::variantMapFromObject(const QScriptValue &obj)
+QVariantMap QScriptEnginePrivate::variantMapFromObject(JSC::ExecState *exec, JSC::JSValue obj)
{
+ JSC::PropertyNameArray propertyNames(exec);
+ propertyNames.setShouldCache(false);
+ JSC::asObject(obj)->getOwnPropertyNames(exec, propertyNames, /*includeNonEnumerable=*/true);
QVariantMap vmap;
- QScriptValueIterator it(obj);
- while (it.hasNext()) {
- it.next();
- vmap.insert(it.name(), it.value().toVariant());
- }
+ JSC::PropertyNameArray::const_iterator it = propertyNames.begin();
+ for( ; it != propertyNames.end(); ++it)
+ vmap.insert(it->ustring(), toVariant(exec, property(exec, obj, *it)));
return vmap;
}
@@ -1280,13 +1322,13 @@ JSC::JSValue QScriptEnginePrivate::newQMetaObject(
return result;
}
-bool QScriptEnginePrivate::convertToNativeQObject(const QScriptValue &value,
+bool QScriptEnginePrivate::convertToNativeQObject(JSC::ExecState *exec, JSC::JSValue value,
const QByteArray &targetType,
void **result)
{
if (!targetType.endsWith('*'))
return false;
- if (QObject *qobject = value.toQObject()) {
+ if (QObject *qobject = toQObject(exec, value)) {
int start = targetType.startsWith("const ") ? 6 : 0;
QByteArray className = targetType.mid(start, targetType.size()-start-1);
if (void *instance = qobject->qt_metacast(className)) {
@@ -1427,6 +1469,328 @@ void QScriptEnginePrivate::detachAllRegisteredScriptStrings()
registeredScriptStrings = 0;
}
+#ifndef QT_NO_REGEXP
+
+extern QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
+
+JSC::JSValue QScriptEnginePrivate::newRegExp(JSC::ExecState *exec, const QRegExp &regexp)
+{
+ JSC::JSValue buf[2];
+ JSC::ArgList args(buf, sizeof(buf));
+
+ //convert the pattern to a ECMAScript pattern
+ QString pattern = qt_regexp_toCanonical(regexp.pattern(), regexp.patternSyntax());
+ if (regexp.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;
+ }
+
+ JSC::UString jscPattern = pattern;
+ QString flags;
+ if (regexp.caseSensitivity() == Qt::CaseInsensitive)
+ flags.append(QLatin1Char('i'));
+ JSC::UString jscFlags = flags;
+ buf[0] = JSC::jsString(exec, jscPattern);
+ buf[1] = JSC::jsString(exec, jscFlags);
+ return JSC::constructRegExp(exec, args);
+}
+
+#endif
+
+JSC::JSValue QScriptEnginePrivate::newRegExp(JSC::ExecState *exec, const QString &pattern, const QString &flags)
+{
+ JSC::JSValue buf[2];
+ JSC::ArgList args(buf, sizeof(buf));
+ JSC::UString jscPattern = pattern;
+ QString strippedFlags;
+ if (flags.contains(QLatin1Char('i')))
+ strippedFlags += QLatin1Char('i');
+ if (flags.contains(QLatin1Char('m')))
+ strippedFlags += QLatin1Char('m');
+ if (flags.contains(QLatin1Char('g')))
+ strippedFlags += QLatin1Char('g');
+ JSC::UString jscFlags = strippedFlags;
+ buf[0] = JSC::jsString(exec, jscPattern);
+ buf[1] = JSC::jsString(exec, jscFlags);
+ return JSC::constructRegExp(exec, args);
+}
+
+JSC::JSValue QScriptEnginePrivate::newVariant(const QVariant &value)
+{
+ QScriptObject *obj = new (currentFrame) QScriptObject(variantWrapperObjectStructure);
+ obj->setDelegate(new QScript::QVariantDelegate(value));
+ JSC::JSValue proto = defaultPrototype(value.userType());
+ if (proto)
+ obj->setPrototype(proto);
+ return obj;
+}
+
+JSC::JSValue QScriptEnginePrivate::newVariant(JSC::JSValue objectValue,
+ const QVariant &value)
+{
+ if (!isObject(objectValue))
+ return newVariant(value);
+ JSC::JSObject *jscObject = JSC::asObject(objectValue);
+ if (!jscObject->inherits(&QScriptObject::info)) {
+ qWarning("QScriptEngine::newVariant(): changing class of non-QScriptObject not supported");
+ return JSC::JSValue();
+ }
+ QScriptObject *jscScriptObject = static_cast<QScriptObject*>(jscObject);
+ if (!isVariant(objectValue)) {
+ jscScriptObject->setDelegate(new QScript::QVariantDelegate(value));
+ } else {
+ setVariantValue(objectValue, value);
+ }
+ return objectValue;
+}
+
+#ifndef QT_NO_REGEXP
+
+QRegExp QScriptEnginePrivate::toRegExp(JSC::ExecState *exec, JSC::JSValue value)
+{
+ if (!isRegExp(value))
+ return QRegExp();
+ QString pattern = toString(exec, property(exec, value, QLatin1String("source"), QScriptValue::ResolvePrototype));
+ Qt::CaseSensitivity kase = Qt::CaseSensitive;
+ if (toBool(exec, property(exec, value, QLatin1String("ignoreCase"), QScriptValue::ResolvePrototype)))
+ kase = Qt::CaseInsensitive;
+ return QRegExp(pattern, kase, QRegExp::RegExp2);
+}
+
+#endif
+
+QVariant QScriptEnginePrivate::toVariant(JSC::ExecState *exec, JSC::JSValue value)
+{
+ if (isObject(value)) {
+ if (isVariant(value))
+ return variantValue(value);
+#ifndef QT_NO_QOBJECT
+ else if (isQObject(value))
+ return qVariantFromValue(toQObject(exec, value));
+#endif
+ else if (isDate(value))
+ return QVariant(toDateTime(exec, value));
+#ifndef QT_NO_REGEXP
+ else if (isRegExp(value))
+ return QVariant(toRegExp(exec, value));
+#endif
+ else if (isArray(value))
+ return variantListFromArray(exec, value);
+ else if (QScriptDeclarativeClass *dc = declarativeClass(value))
+ return dc->toVariant(declarativeObject(value));
+ // try to convert to primitive
+ JSC::JSValue savedException;
+ saveException(exec, &savedException);
+ JSC::JSValue prim = value.toPrimitive(exec);
+ restoreException(exec, savedException);
+ if (!prim.isObject())
+ return toVariant(exec, prim);
+ } else if (value.isNumber()) {
+ return QVariant(toNumber(exec, value));
+ } else if (value.isString()) {
+ return QVariant(toString(exec, value));
+ } else if (value.isBoolean()) {
+ return QVariant(toBool(exec, value));
+ }
+ return QVariant();
+}
+
+JSC::JSValue QScriptEnginePrivate::propertyHelper(JSC::ExecState *exec, JSC::JSValue value, const JSC::Identifier &id, int resolveMode)
+{
+ JSC::JSValue result;
+ if (!(resolveMode & QScriptValue::ResolvePrototype)) {
+ // Look in the object's own properties
+ JSC::JSObject *object = JSC::asObject(value);
+ JSC::PropertySlot slot(object);
+ if (object->getOwnPropertySlot(exec, id, slot))
+ result = slot.getValue(exec, id);
+ }
+ if (!result && (resolveMode & QScriptValue::ResolveScope)) {
+ // ### check if it's a function object and look in the scope chain
+ JSC::JSValue scope = property(exec, value, QString::fromLatin1("__qt_scope__"), QScriptValue::ResolveLocal);
+ if (isObject(scope))
+ result = property(exec, scope, id, resolveMode);
+ }
+ return result;
+}
+
+JSC::JSValue QScriptEnginePrivate::propertyHelper(JSC::ExecState *exec, JSC::JSValue value, quint32 index, int resolveMode)
+{
+ JSC::JSValue result;
+ if (!(resolveMode & QScriptValue::ResolvePrototype)) {
+ // Look in the object's own properties
+ JSC::JSObject *object = JSC::asObject(value);
+ JSC::PropertySlot slot(object);
+ if (object->getOwnPropertySlot(exec, index, slot))
+ result = slot.getValue(exec, index);
+ }
+ return result;
+}
+
+void QScriptEnginePrivate::setProperty(JSC::ExecState *exec, JSC::JSValue objectValue, const JSC::Identifier &id,
+ JSC::JSValue value, const QScriptValue::PropertyFlags &flags)
+{
+ JSC::JSObject *thisObject = JSC::asObject(objectValue);
+ JSC::JSValue setter = thisObject->lookupSetter(exec, id);
+ JSC::JSValue getter = thisObject->lookupGetter(exec, id);
+ if ((flags & QScriptValue::PropertyGetter) || (flags & QScriptValue::PropertySetter)) {
+ if (!value) {
+ // deleting getter/setter
+ if ((flags & QScriptValue::PropertyGetter) && (flags & QScriptValue::PropertySetter)) {
+ // deleting both: just delete the property
+ thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false);
+ } else if (flags & QScriptValue::PropertyGetter) {
+ // preserve setter, if there is one
+ thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false);
+ if (setter && setter.isObject())
+ thisObject->defineSetter(exec, id, JSC::asObject(setter));
+ } else { // flags & QScriptValue::PropertySetter
+ // preserve getter, if there is one
+ thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false);
+ if (getter && getter.isObject())
+ thisObject->defineGetter(exec, id, JSC::asObject(getter));
+ }
+ } else {
+ if (value.isObject()) { // ### should check if it has callData()
+ // defining getter/setter
+ if (id == exec->propertyNames().underscoreProto) {
+ qWarning("QScriptValue::setProperty() failed: "
+ "cannot set getter or setter of native property `__proto__'");
+ } else {
+ if (flags & QScriptValue::PropertyGetter)
+ thisObject->defineGetter(exec, id, JSC::asObject(value));
+ if (flags & QScriptValue::PropertySetter)
+ thisObject->defineSetter(exec, id, JSC::asObject(value));
+ }
+ } else {
+ qWarning("QScriptValue::setProperty(): getter/setter must be a function");
+ }
+ }
+ } else {
+ // setting the value
+ if (getter && getter.isObject() && !(setter && setter.isObject())) {
+ qWarning("QScriptValue::setProperty() failed: "
+ "property '%s' has a getter but no setter",
+ qPrintable(QString(id.ustring())));
+ return;
+ }
+ if (!value) {
+ // ### check if it's a getter/setter property
+ thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false);
+ } else if (flags != QScriptValue::KeepExistingFlags) {
+ if (thisObject->hasOwnProperty(exec, id))
+ thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false); // ### hmmm - can't we just update the attributes?
+ unsigned attribs = 0;
+ if (flags & QScriptValue::ReadOnly)
+ attribs |= JSC::ReadOnly;
+ if (flags & QScriptValue::SkipInEnumeration)
+ attribs |= JSC::DontEnum;
+ if (flags & QScriptValue::Undeletable)
+ attribs |= JSC::DontDelete;
+ attribs |= flags & QScriptValue::UserRange;
+ thisObject->putWithAttributes(exec, id, value, attribs);
+ } else {
+ JSC::PutPropertySlot slot;
+ thisObject->put(exec, id, value, slot);
+ }
+ }
+}
+
+void QScriptEnginePrivate::setProperty(JSC::ExecState *exec, JSC::JSValue objectValue, quint32 index,
+ JSC::JSValue value, const QScriptValue::PropertyFlags &flags)
+{
+ if (!value) {
+ JSC::asObject(objectValue)->deleteProperty(exec, index, /*checkDontDelete=*/false);
+ } else {
+ if ((flags & QScriptValue::PropertyGetter) || (flags & QScriptValue::PropertySetter)) {
+ // fall back to string-based setProperty(), since there is no
+ // JSC::JSObject::defineGetter(unsigned)
+ setProperty(exec, objectValue, JSC::Identifier::from(exec, index), value, flags);
+ } else {
+ if (flags != QScriptValue::KeepExistingFlags) {
+ // if (JSC::asObject(d->jscValue)->hasOwnProperty(exec, arrayIndex))
+ // JSC::asObject(d->jscValue)->deleteProperty(exec, arrayIndex);
+ unsigned attribs = 0;
+ if (flags & QScriptValue::ReadOnly)
+ attribs |= JSC::ReadOnly;
+ if (flags & QScriptValue::SkipInEnumeration)
+ attribs |= JSC::DontEnum;
+ if (flags & QScriptValue::Undeletable)
+ attribs |= JSC::DontDelete;
+ attribs |= flags & QScriptValue::UserRange;
+ JSC::asObject(objectValue)->putWithAttributes(exec, index, value, attribs);
+ } else {
+ JSC::asObject(objectValue)->put(exec, index, value);
+ }
+ }
+ }
+}
+
+QScriptValue::PropertyFlags QScriptEnginePrivate::propertyFlags(JSC::ExecState *exec, JSC::JSValue value, const JSC::Identifier &id,
+ const QScriptValue::ResolveFlags &mode)
+{
+ JSC::JSObject *object = JSC::asObject(value);
+ unsigned attribs = 0;
+ JSC::PropertyDescriptor descriptor;
+ if (object->getOwnPropertyDescriptor(exec, id, descriptor))
+ attribs = descriptor.attributes();
+ else if (!object->getPropertyAttributes(exec, id, attribs)) {
+ if ((mode & QScriptValue::ResolvePrototype) && object->prototype() && object->prototype().isObject()) {
+ JSC::JSValue proto = object->prototype();
+ return propertyFlags(exec, proto, id, mode);
+ }
+ return 0;
+ }
+ QScriptValue::PropertyFlags result = 0;
+ if (attribs & JSC::ReadOnly)
+ result |= QScriptValue::ReadOnly;
+ if (attribs & JSC::DontEnum)
+ result |= QScriptValue::SkipInEnumeration;
+ if (attribs & JSC::DontDelete)
+ result |= QScriptValue::Undeletable;
+ //We cannot rely on attribs JSC::Setter/Getter because they are not necesserly set by JSC (bug?)
+ if (attribs & JSC::Getter || !object->lookupGetter(exec, id).isUndefinedOrNull())
+ result |= QScriptValue::PropertyGetter;
+ if (attribs & JSC::Setter || !object->lookupSetter(exec, id).isUndefinedOrNull())
+ result |= QScriptValue::PropertySetter;
+#ifndef QT_NO_QOBJECT
+ if (attribs & QScript::QObjectMemberAttribute)
+ result |= QScriptValue::QObjectMember;
+#endif
+ result |= QScriptValue::PropertyFlag(attribs & QScriptValue::UserRange);
+ return result;
+}
+
#ifdef QT_NO_QOBJECT
QScriptEngine::QScriptEngine()
@@ -1599,56 +1963,7 @@ extern QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
QScriptValue QScriptEngine::newRegExp(const QRegExp &regexp)
{
Q_D(QScriptEngine);
- JSC::ExecState* exec = d->currentFrame;
- JSC::JSValue buf[2];
- JSC::ArgList args(buf, sizeof(buf));
-
- //convert the pattern to a ECMAScript pattern
- QString pattern = qt_regexp_toCanonical(regexp.pattern(), regexp.patternSyntax());
- if (regexp.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;
- }
-
- JSC::UString jscPattern = pattern;
- QString flags;
- if (regexp.caseSensitivity() == Qt::CaseInsensitive)
- flags.append(QLatin1Char('i'));
- JSC::UString jscFlags = flags;
- buf[0] = JSC::jsString(exec, jscPattern);
- buf[1] = JSC::jsString(exec, jscFlags);
- JSC::JSObject* result = JSC::constructRegExp(exec, args);
- return d->scriptValueFromJSCValue(result);
+ return d->scriptValueFromJSCValue(d->newRegExp(d->currentFrame, regexp));
}
#endif // QT_NO_REGEXP
@@ -1666,14 +1981,7 @@ QScriptValue QScriptEngine::newRegExp(const QRegExp &regexp)
QScriptValue QScriptEngine::newVariant(const QVariant &value)
{
Q_D(QScriptEngine);
- JSC::ExecState* exec = d->currentFrame;
- QScriptObject *obj = new (exec) QScriptObject(d->variantWrapperObjectStructure);
- obj->setDelegate(new QScript::QVariantDelegate(value));
- QScriptValue result = d->scriptValueFromJSCValue(obj);
- QScriptValue proto = defaultPrototype(value.userType());
- if (proto.isValid())
- result.setPrototype(proto);
- return result;
+ return d->scriptValueFromJSCValue(d->newVariant(value));
}
/*!
@@ -1703,20 +2011,9 @@ QScriptValue QScriptEngine::newVariant(const QVariant &value)
QScriptValue QScriptEngine::newVariant(const QScriptValue &object,
const QVariant &value)
{
- if (!object.isObject())
- return newVariant(value);
- JSC::JSObject *jscObject = JSC::asObject(QScriptValuePrivate::get(object)->jscValue);
- if (!jscObject->inherits(&QScriptObject::info)) {
- qWarning("QScriptEngine::newVariant(): changing class of non-QScriptObject not supported");
- return QScriptValue();
- }
- QScriptObject *jscScriptObject = static_cast<QScriptObject*>(jscObject);
- if (!object.isVariant()) {
- jscScriptObject->setDelegate(new QScript::QVariantDelegate(value));
- } else {
- QScriptValuePrivate::get(object)->setVariantValue(value);
- }
- return object;
+ Q_D(QScriptEngine);
+ JSC::JSValue jsObject = d->scriptValueToJSCValue(object);
+ return d->scriptValueFromJSCValue(d->newVariant(jsObject, value));
}
#ifndef QT_NO_QOBJECT
@@ -1812,9 +2109,7 @@ QScriptValue QScriptEngine::newQObject(const QScriptValue &scriptObject,
QScriptValue QScriptEngine::newObject()
{
Q_D(QScriptEngine);
- JSC::ExecState* exec = d->currentFrame;
- JSC::JSObject *result = new (exec)QScriptObject(d->scriptObjectStructure);
- return d->scriptValueFromJSCValue(result);
+ return d->scriptValueFromJSCValue(d->newObject());
}
/*!
@@ -1937,9 +2232,7 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionWithArgSignature
QScriptValue QScriptEngine::newArray(uint length)
{
Q_D(QScriptEngine);
- JSC::ExecState* exec = d->currentFrame;
- JSC::JSArray* result = JSC::constructEmptyArray(exec, length);
- return d->scriptValueFromJSCValue(result);
+ return d->scriptValueFromJSCValue(d->newArray(d->currentFrame, length));
}
/*!
@@ -1952,22 +2245,7 @@ QScriptValue QScriptEngine::newArray(uint length)
QScriptValue QScriptEngine::newRegExp(const QString &pattern, const QString &flags)
{
Q_D(QScriptEngine);
- JSC::ExecState* exec = d->currentFrame;
- JSC::JSValue buf[2];
- JSC::ArgList args(buf, sizeof(buf));
- JSC::UString jscPattern = pattern;
- QString strippedFlags;
- if (flags.contains(QLatin1Char('i')))
- strippedFlags += QLatin1Char('i');
- if (flags.contains(QLatin1Char('m')))
- strippedFlags += QLatin1Char('m');
- if (flags.contains(QLatin1Char('g')))
- strippedFlags += QLatin1Char('g');
- JSC::UString jscFlags = strippedFlags;
- buf[0] = JSC::jsString(exec, jscPattern);
- buf[1] = JSC::jsString(exec, jscFlags);
- JSC::JSObject* result = JSC::constructRegExp(exec, args);
- return d->scriptValueFromJSCValue(result);
+ return d->scriptValueFromJSCValue(d->newRegExp(d->currentFrame, pattern, flags));
}
/*!
@@ -1978,11 +2256,7 @@ QScriptValue QScriptEngine::newRegExp(const QString &pattern, const QString &fla
QScriptValue QScriptEngine::newDate(qsreal value)
{
Q_D(QScriptEngine);
- JSC::ExecState* exec = d->currentFrame;
- JSC::JSValue val = JSC::jsNumber(exec, value);
- JSC::ArgList args(&val, 1);
- JSC::JSObject *result = JSC::constructDate(exec, args);
- return d->scriptValueFromJSCValue(result);
+ return d->scriptValueFromJSCValue(d->newDate(d->currentFrame, value));
}
/*!
@@ -1992,7 +2266,8 @@ QScriptValue QScriptEngine::newDate(qsreal value)
*/
QScriptValue QScriptEngine::newDate(const QDateTime &value)
{
- return newDate(QScript::FromDateTime(value));
+ Q_D(QScriptEngine);
+ return d->scriptValueFromJSCValue(d->newDate(d->currentFrame, value));
}
#ifndef QT_NO_QOBJECT
@@ -2551,128 +2826,126 @@ void QScriptEngine::setDefaultPrototype(int metaTypeId, const QScriptValue &prot
QScriptValue QScriptEngine::create(int type, const void *ptr)
{
Q_D(QScriptEngine);
- return d->create(type, ptr);
+ return d->scriptValueFromJSCValue(d->create(d->currentFrame, type, ptr));
}
-QScriptValue QScriptEnginePrivate::create(int type, const void *ptr)
+JSC::JSValue QScriptEnginePrivate::create(JSC::ExecState *exec, int type, const void *ptr)
{
- Q_Q(QScriptEngine);
Q_ASSERT(ptr != 0);
- QScriptValue result;
- QScriptTypeInfo *info = m_typeInfos.value(type);
+ JSC::JSValue result;
+ QScriptEnginePrivate *eng = exec ? QScript::scriptEngineFromExec(exec) : 0;
+ QScriptTypeInfo *info = eng ? eng->m_typeInfos.value(type) : 0;
if (info && info->marshal) {
- result = info->marshal(q, ptr);
+ result = eng->scriptValueToJSCValue(info->marshal(eng->q_func(), ptr));
} else {
// check if it's one of the types we know
switch (QMetaType::Type(type)) {
case QMetaType::Void:
- return QScriptValue(q, QScriptValue::UndefinedValue);
+ return JSC::jsUndefined();
case QMetaType::Bool:
- return QScriptValue(q, *reinterpret_cast<const bool*>(ptr));
+ return JSC::jsBoolean(*reinterpret_cast<const bool*>(ptr));
case QMetaType::Int:
- return QScriptValue(q, *reinterpret_cast<const int*>(ptr));
+ return JSC::jsNumber(exec, *reinterpret_cast<const int*>(ptr));
case QMetaType::UInt:
- return QScriptValue(q, *reinterpret_cast<const uint*>(ptr));
+ return JSC::jsNumber(exec, *reinterpret_cast<const uint*>(ptr));
case QMetaType::LongLong:
- return QScriptValue(q, qsreal(*reinterpret_cast<const qlonglong*>(ptr)));
+ return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const qlonglong*>(ptr)));
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 QScriptValue(q, qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr)));
+ return JSC::jsNumber(exec, qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr)));
#elif defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET)
- return QScriptValue(q, qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr)));
+ return JSC::jsNumber(exec, qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr)));
#else
- return QScriptValue(q, qsreal(*reinterpret_cast<const qulonglong*>(ptr)));
+ return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const qulonglong*>(ptr)));
#endif
case QMetaType::Double:
- return QScriptValue(q, qsreal(*reinterpret_cast<const double*>(ptr)));
+ return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const double*>(ptr)));
case QMetaType::QString:
- return QScriptValue(q, *reinterpret_cast<const QString*>(ptr));
+ return JSC::jsString(exec, *reinterpret_cast<const QString*>(ptr));
case QMetaType::Float:
- return QScriptValue(q, *reinterpret_cast<const float*>(ptr));
+ return JSC::jsNumber(exec, *reinterpret_cast<const float*>(ptr));
case QMetaType::Short:
- return QScriptValue(q, *reinterpret_cast<const short*>(ptr));
+ return JSC::jsNumber(exec, *reinterpret_cast<const short*>(ptr));
case QMetaType::UShort:
- return QScriptValue(q, *reinterpret_cast<const unsigned short*>(ptr));
+ return JSC::jsNumber(exec, *reinterpret_cast<const unsigned short*>(ptr));
case QMetaType::Char:
- return QScriptValue(q, *reinterpret_cast<const char*>(ptr));
+ return JSC::jsNumber(exec, *reinterpret_cast<const char*>(ptr));
case QMetaType::UChar:
- return QScriptValue(q, *reinterpret_cast<const unsigned char*>(ptr));
+ return JSC::jsNumber(exec, *reinterpret_cast<const unsigned char*>(ptr));
case QMetaType::QChar:
- return QScriptValue(q, (*reinterpret_cast<const QChar*>(ptr)).unicode());
+ return JSC::jsNumber(exec, (*reinterpret_cast<const QChar*>(ptr)).unicode());
case QMetaType::QStringList:
- result = arrayFromStringList(*reinterpret_cast<const QStringList *>(ptr));
+ result = arrayFromStringList(exec, *reinterpret_cast<const QStringList *>(ptr));
break;
case QMetaType::QVariantList:
- result = arrayFromVariantList(*reinterpret_cast<const QVariantList *>(ptr));
+ result = arrayFromVariantList(exec, *reinterpret_cast<const QVariantList *>(ptr));
break;
case QMetaType::QVariantMap:
- result = objectFromVariantMap(*reinterpret_cast<const QVariantMap *>(ptr));
+ result = objectFromVariantMap(exec, *reinterpret_cast<const QVariantMap *>(ptr));
break;
case QMetaType::QDateTime:
- result = q->newDate(*reinterpret_cast<const QDateTime *>(ptr));
+ result = newDate(exec, *reinterpret_cast<const QDateTime *>(ptr));
break;
case QMetaType::QDate:
- result = q->newDate(QDateTime(*reinterpret_cast<const QDate *>(ptr)));
+ result = newDate(exec, QDateTime(*reinterpret_cast<const QDate *>(ptr)));
break;
#ifndef QT_NO_REGEXP
case QMetaType::QRegExp:
- result = q->newRegExp(*reinterpret_cast<const QRegExp *>(ptr));
+ result = newRegExp(exec, *reinterpret_cast<const QRegExp *>(ptr));
break;
#endif
#ifndef QT_NO_QOBJECT
case QMetaType::QObjectStar:
case QMetaType::QWidgetStar:
- result = q->newQObject(*reinterpret_cast<QObject* const *>(ptr));
+ result = eng->newQObject(*reinterpret_cast<QObject* const *>(ptr));
break;
#endif
default:
if (type == qMetaTypeId<QScriptValue>()) {
- result = *reinterpret_cast<const QScriptValue*>(ptr);
- if (!result.isValid())
- return QScriptValue(q, QScriptValue::UndefinedValue);
+ result = eng->scriptValueToJSCValue(*reinterpret_cast<const QScriptValue*>(ptr));
+ if (!result)
+ return JSC::jsUndefined();
}
#ifndef QT_NO_QOBJECT
// lazy registration of some common list types
else if (type == qMetaTypeId<QObjectList>()) {
- qScriptRegisterSequenceMetaType<QObjectList>(q);
- return create(type, ptr);
+ qScriptRegisterSequenceMetaType<QObjectList>(eng->q_func());
+ return create(exec, type, ptr);
}
#endif
else if (type == qMetaTypeId<QList<int> >()) {
- qScriptRegisterSequenceMetaType<QList<int> >(q);
- return create(type, ptr);
+ qScriptRegisterSequenceMetaType<QList<int> >(eng->q_func());
+ return create(exec, type, ptr);
}
else {
QByteArray typeName = QMetaType::typeName(type);
if (typeName == "QVariant")
- result = scriptValueFromVariant(*reinterpret_cast<const QVariant*>(ptr));
+ result = jscValueFromVariant(exec, *reinterpret_cast<const QVariant*>(ptr));
if (typeName.endsWith('*') && !*reinterpret_cast<void* const *>(ptr))
- return QScriptValue(q, QScriptValue::NullValue);
+ return JSC::jsNull();
else
- result = q->newVariant(QVariant(type, ptr));
+ result = eng->newVariant(QVariant(type, ptr));
}
}
}
- if (result.isObject() && info && info->prototype
- && JSC::JSValue::strictEqual(scriptValueToJSCValue(result.prototype()), originalGlobalObject()->objectPrototype())) {
- result.setPrototype(scriptValueFromJSCValue(info->prototype));
+ if (result && result.isObject() && info && info->prototype
+ && JSC::JSValue::strictEqual(JSC::asObject(result)->prototype(), eng->originalGlobalObject()->objectPrototype())) {
+ JSC::asObject(result)->setPrototype(info->prototype);
}
return result;
}
-bool QScriptEnginePrivate::convert(const QScriptValue &value,
- int type, void *ptr,
- QScriptEnginePrivate *eng)
+bool QScriptEnginePrivate::convertValue(JSC::ExecState *exec, JSC::JSValue value,
+ int type, void *ptr)
{
- if (!eng)
- eng = QScriptValuePrivate::getEngine(value);
+ QScriptEnginePrivate *eng = exec ? QScript::scriptEngineFromExec(exec) : 0;
if (eng) {
QScriptTypeInfo *info = eng->m_typeInfos.value(type);
if (info && info->demarshal) {
- info->demarshal(value, ptr);
+ info->demarshal(eng->scriptValueFromJSCValue(value), ptr);
return true;
}
}
@@ -2680,78 +2953,78 @@ bool QScriptEnginePrivate::convert(const QScriptValue &value,
// check if it's one of the types we know
switch (QMetaType::Type(type)) {
case QMetaType::Bool:
- *reinterpret_cast<bool*>(ptr) = value.toBoolean();
+ *reinterpret_cast<bool*>(ptr) = toBool(exec, value);
return true;
case QMetaType::Int:
- *reinterpret_cast<int*>(ptr) = value.toInt32();
+ *reinterpret_cast<int*>(ptr) = toInt32(exec, value);
return true;
case QMetaType::UInt:
- *reinterpret_cast<uint*>(ptr) = value.toUInt32();
+ *reinterpret_cast<uint*>(ptr) = toUInt32(exec, value);
return true;
case QMetaType::LongLong:
- *reinterpret_cast<qlonglong*>(ptr) = qlonglong(value.toInteger());
+ *reinterpret_cast<qlonglong*>(ptr) = qlonglong(toInteger(exec, value));
return true;
case QMetaType::ULongLong:
- *reinterpret_cast<qulonglong*>(ptr) = qulonglong(value.toInteger());
+ *reinterpret_cast<qulonglong*>(ptr) = qulonglong(toInteger(exec, value));
return true;
case QMetaType::Double:
- *reinterpret_cast<double*>(ptr) = value.toNumber();
+ *reinterpret_cast<double*>(ptr) = toNumber(exec, value);
return true;
case QMetaType::QString:
if (value.isUndefined() || value.isNull())
*reinterpret_cast<QString*>(ptr) = QString();
else
- *reinterpret_cast<QString*>(ptr) = value.toString();
+ *reinterpret_cast<QString*>(ptr) = toString(exec, value);
return true;
case QMetaType::Float:
- *reinterpret_cast<float*>(ptr) = value.toNumber();
+ *reinterpret_cast<float*>(ptr) = toNumber(exec, value);
return true;
case QMetaType::Short:
- *reinterpret_cast<short*>(ptr) = short(value.toInt32());
+ *reinterpret_cast<short*>(ptr) = short(toInt32(exec, value));
return true;
case QMetaType::UShort:
- *reinterpret_cast<unsigned short*>(ptr) = value.toUInt16();
+ *reinterpret_cast<unsigned short*>(ptr) = QScript::ToUInt16(toNumber(exec, value));
return true;
case QMetaType::Char:
- *reinterpret_cast<char*>(ptr) = char(value.toInt32());
+ *reinterpret_cast<char*>(ptr) = char(toInt32(exec, value));
return true;
case QMetaType::UChar:
- *reinterpret_cast<unsigned char*>(ptr) = (unsigned char)(value.toInt32());
+ *reinterpret_cast<unsigned char*>(ptr) = (unsigned char)(toInt32(exec, value));
return true;
case QMetaType::QChar:
if (value.isString()) {
- QString str = value.toString();
+ QString str = toString(exec, value);
*reinterpret_cast<QChar*>(ptr) = str.isEmpty() ? QChar() : str.at(0);
} else {
- *reinterpret_cast<QChar*>(ptr) = QChar(value.toUInt16());
+ *reinterpret_cast<QChar*>(ptr) = QChar(QScript::ToUInt16(toNumber(exec, value)));
}
return true;
case QMetaType::QDateTime:
- if (value.isDate()) {
- *reinterpret_cast<QDateTime *>(ptr) = value.toDateTime();
+ if (isDate(value)) {
+ *reinterpret_cast<QDateTime *>(ptr) = toDateTime(exec, value);
return true;
} break;
case QMetaType::QDate:
- if (value.isDate()) {
- *reinterpret_cast<QDate *>(ptr) = value.toDateTime().date();
+ if (isDate(value)) {
+ *reinterpret_cast<QDate *>(ptr) = toDateTime(exec, value).date();
return true;
} break;
#ifndef QT_NO_REGEXP
case QMetaType::QRegExp:
- if (value.isRegExp()) {
- *reinterpret_cast<QRegExp *>(ptr) = value.toRegExp();
+ if (isRegExp(value)) {
+ *reinterpret_cast<QRegExp *>(ptr) = toRegExp(exec, value);
return true;
} break;
#endif
#ifndef QT_NO_QOBJECT
case QMetaType::QObjectStar:
- if (value.isQObject() || value.isNull()) {
- *reinterpret_cast<QObject* *>(ptr) = value.toQObject();
+ if (isQObject(value) || value.isNull()) {
+ *reinterpret_cast<QObject* *>(ptr) = toQObject(exec, value);
return true;
} break;
case QMetaType::QWidgetStar:
- if (value.isQObject() || value.isNull()) {
- QObject *qo = value.toQObject();
+ if (isQObject(value) || value.isNull()) {
+ QObject *qo = toQObject(exec, value);
if (!qo || qo->isWidgetType()) {
*reinterpret_cast<QWidget* *>(ptr) = reinterpret_cast<QWidget*>(qo);
return true;
@@ -2759,18 +3032,18 @@ bool QScriptEnginePrivate::convert(const QScriptValue &value,
} break;
#endif
case QMetaType::QStringList:
- if (value.isArray()) {
- *reinterpret_cast<QStringList *>(ptr) = stringListFromArray(value);
+ if (isArray(value)) {
+ *reinterpret_cast<QStringList *>(ptr) = stringListFromArray(exec, value);
return true;
} break;
case QMetaType::QVariantList:
- if (value.isArray()) {
- *reinterpret_cast<QVariantList *>(ptr) = variantListFromArray(value);
+ if (isArray(value)) {
+ *reinterpret_cast<QVariantList *>(ptr) = variantListFromArray(exec, value);
return true;
} break;
case QMetaType::QVariantMap:
- if (value.isObject()) {
- *reinterpret_cast<QVariantMap *>(ptr) = variantMapFromObject(value);
+ if (isObject(value)) {
+ *reinterpret_cast<QVariantMap *>(ptr) = variantMapFromObject(exec, value);
return true;
} break;
default:
@@ -2779,28 +3052,28 @@ bool QScriptEnginePrivate::convert(const QScriptValue &value,
QByteArray name = QMetaType::typeName(type);
#ifndef QT_NO_QOBJECT
- if (convertToNativeQObject(value, name, reinterpret_cast<void* *>(ptr)))
+ if (convertToNativeQObject(exec, value, name, reinterpret_cast<void* *>(ptr)))
return true;
#endif
- if (value.isVariant() && name.endsWith('*')) {
+ if (isVariant(value) && name.endsWith('*')) {
int valueType = QMetaType::type(name.left(name.size()-1));
- QVariant &var = QScriptValuePrivate::get(value)->variantValue();
+ QVariant &var = variantValue(value);
if (valueType == var.userType()) {
*reinterpret_cast<void* *>(ptr) = var.data();
return true;
} else {
// look in the prototype chain
- QScriptValue proto = value.prototype();
+ JSC::JSValue proto = JSC::asObject(value)->prototype();
while (proto.isObject()) {
bool canCast = false;
- if (proto.isVariant()) {
- canCast = (type == proto.toVariant().userType())
- || (valueType && (valueType == proto.toVariant().userType()));
+ if (isVariant(proto)) {
+ canCast = (type == variantValue(proto).userType())
+ || (valueType && (valueType == variantValue(proto).userType()));
}
#ifndef QT_NO_QOBJECT
- else if (proto.isQObject()) {
+ else if (isQObject(proto)) {
QByteArray className = name.left(name.size()-1);
- if (QObject *qobject = proto.toQObject())
+ if (QObject *qobject = toQObject(exec, proto))
canCast = qobject->qt_metacast(className) != 0;
}
#endif
@@ -2812,7 +3085,7 @@ bool QScriptEnginePrivate::convert(const QScriptValue &value,
*reinterpret_cast<void* *>(ptr) = var.data();
return true;
}
- proto = proto.prototype();
+ proto = JSC::asObject(proto)->prototype();
}
}
} else if (value.isNull() && name.endsWith('*')) {
@@ -2821,10 +3094,10 @@ bool QScriptEnginePrivate::convert(const QScriptValue &value,
} else if (type == qMetaTypeId<QScriptValue>()) {
if (!eng)
return false;
- *reinterpret_cast<QScriptValue*>(ptr) = value;
+ *reinterpret_cast<QScriptValue*>(ptr) = eng->scriptValueFromJSCValue(value);
return true;
} else if (name == "QVariant") {
- *reinterpret_cast<QVariant*>(ptr) = value.toVariant();
+ *reinterpret_cast<QVariant*>(ptr) = toVariant(exec, value);
return true;
}
@@ -2834,14 +3107,14 @@ bool QScriptEnginePrivate::convert(const QScriptValue &value,
if (!eng)
return false;
qScriptRegisterSequenceMetaType<QObjectList>(eng->q_func());
- return convert(value, type, ptr, eng);
+ return convertValue(exec, value, type, ptr);
}
#endif
else if (type == qMetaTypeId<QList<int> >()) {
if (!eng)
return false;
qScriptRegisterSequenceMetaType<QList<int> >(eng->q_func());
- return convert(value, type, ptr, eng);
+ return convertValue(exec, value, type, ptr);
}
#if 0
@@ -2853,6 +3126,102 @@ bool QScriptEnginePrivate::convert(const QScriptValue &value,
return false;
}
+bool QScriptEnginePrivate::convertNumber(qsreal value, int type, void *ptr)
+{
+ switch (QMetaType::Type(type)) {
+ case QMetaType::Bool:
+ *reinterpret_cast<bool*>(ptr) = QScript::ToBool(value);
+ return true;
+ case QMetaType::Int:
+ *reinterpret_cast<int*>(ptr) = QScript::ToInt32(value);
+ return true;
+ case QMetaType::UInt:
+ *reinterpret_cast<uint*>(ptr) = QScript::ToUInt32(value);
+ return true;
+ case QMetaType::LongLong:
+ *reinterpret_cast<qlonglong*>(ptr) = qlonglong(QScript::ToInteger(value));
+ return true;
+ case QMetaType::ULongLong:
+ *reinterpret_cast<qulonglong*>(ptr) = qulonglong(QScript::ToInteger(value));
+ return true;
+ case QMetaType::Double:
+ *reinterpret_cast<double*>(ptr) = value;
+ return true;
+ case QMetaType::QString:
+ *reinterpret_cast<QString*>(ptr) = QScript::ToString(value);
+ return true;
+ case QMetaType::Float:
+ *reinterpret_cast<float*>(ptr) = value;
+ return true;
+ case QMetaType::Short:
+ *reinterpret_cast<short*>(ptr) = short(QScript::ToInt32(value));
+ return true;
+ case QMetaType::UShort:
+ *reinterpret_cast<unsigned short*>(ptr) = QScript::ToUInt16(value);
+ return true;
+ case QMetaType::Char:
+ *reinterpret_cast<char*>(ptr) = char(QScript::ToInt32(value));
+ return true;
+ case QMetaType::UChar:
+ *reinterpret_cast<unsigned char*>(ptr) = (unsigned char)(QScript::ToInt32(value));
+ return true;
+ case QMetaType::QChar:
+ *reinterpret_cast<QChar*>(ptr) = QChar(QScript::ToUInt16(value));
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+bool QScriptEnginePrivate::convertString(const QString &value, int type, void *ptr)
+{
+ switch (QMetaType::Type(type)) {
+ case QMetaType::Bool:
+ *reinterpret_cast<bool*>(ptr) = QScript::ToBool(value);
+ return true;
+ case QMetaType::Int:
+ *reinterpret_cast<int*>(ptr) = QScript::ToInt32(value);
+ return true;
+ case QMetaType::UInt:
+ *reinterpret_cast<uint*>(ptr) = QScript::ToUInt32(value);
+ return true;
+ case QMetaType::LongLong:
+ *reinterpret_cast<qlonglong*>(ptr) = qlonglong(QScript::ToInteger(value));
+ return true;
+ case QMetaType::ULongLong:
+ *reinterpret_cast<qulonglong*>(ptr) = qulonglong(QScript::ToInteger(value));
+ return true;
+ case QMetaType::Double:
+ *reinterpret_cast<double*>(ptr) = QScript::ToNumber(value);
+ return true;
+ case QMetaType::QString:
+ *reinterpret_cast<QString*>(ptr) = value;
+ return true;
+ case QMetaType::Float:
+ *reinterpret_cast<float*>(ptr) = QScript::ToNumber(value);
+ return true;
+ case QMetaType::Short:
+ *reinterpret_cast<short*>(ptr) = short(QScript::ToInt32(value));
+ return true;
+ case QMetaType::UShort:
+ *reinterpret_cast<unsigned short*>(ptr) = QScript::ToUInt16(value);
+ return true;
+ case QMetaType::Char:
+ *reinterpret_cast<char*>(ptr) = char(QScript::ToInt32(value));
+ return true;
+ case QMetaType::UChar:
+ *reinterpret_cast<unsigned char*>(ptr) = (unsigned char)(QScript::ToInt32(value));
+ return true;
+ case QMetaType::QChar:
+ *reinterpret_cast<QChar*>(ptr) = QChar(QScript::ToUInt16(value));
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
bool QScriptEnginePrivate::hasDemarshalFunction(int type) const
{
QScriptTypeInfo *info = m_typeInfos.value(type);
@@ -2865,7 +3234,7 @@ bool QScriptEnginePrivate::hasDemarshalFunction(int type) const
bool QScriptEngine::convert(const QScriptValue &value, int type, void *ptr)
{
Q_D(QScriptEngine);
- return QScriptEnginePrivate::convert(value, type, ptr, d);
+ return QScriptEnginePrivate::convertValue(d->currentFrame, d->scriptValueToJSCValue(value), type, ptr);
}
/*!
@@ -2873,7 +3242,20 @@ bool QScriptEngine::convert(const QScriptValue &value, int type, void *ptr)
*/
bool QScriptEngine::convertV2(const QScriptValue &value, int type, void *ptr)
{
- return QScriptEnginePrivate::convert(value, type, ptr, /*engine=*/0);
+ QScriptValuePrivate *vp = QScriptValuePrivate::get(value);
+ if (vp) {
+ switch (vp->type) {
+ case QScriptValuePrivate::JavaScriptCore: {
+ JSC::ExecState *exec = vp->engine ? vp->engine->currentFrame : 0;
+ return QScriptEnginePrivate::convertValue(exec, vp->jscValue, type, ptr);
+ }
+ case QScriptValuePrivate::Number:
+ return QScriptEnginePrivate::convertNumber(vp->numberValue, type, ptr);
+ case QScriptValuePrivate::String:
+ return QScriptEnginePrivate::convertString(vp->stringValue, type, ptr);
+ }
+ }
+ return false;
}
/*!
@@ -3845,4 +4227,9 @@ Q_AUTOTEST_EXPORT bool qt_script_isJITEnabled()
}
#endif
+#ifdef Q_CC_MSVC
+// Try to prevent compiler from crashing.
+#pragma optimize("", off)
+#endif
+
QT_END_NAMESPACE
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index 6780b2c..f69e537 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -37,14 +37,30 @@
#include "private/qobject_p.h"
+#include <QtCore/qdatetime.h>
#include <QtCore/qhash.h>
+#include <QtCore/qnumeric.h>
+#include <QtCore/qregexp.h>
#include <QtCore/qset.h>
#include "qscriptvalue_p.h"
#include "qscriptstring_p.h"
-
+#include "bridge/qscriptclassobject_p.h"
+#include "bridge/qscriptdeclarativeclass_p.h"
+#include "bridge/qscriptdeclarativeobject_p.h"
+#include "bridge/qscriptobject_p.h"
+#include "bridge/qscriptqobject_p.h"
+#include "bridge/qscriptvariant_p.h"
+#include "utils/qscriptdate_p.h"
+
+#include "DateConstructor.h"
+#include "DateInstance.h"
#include "Debugger.h"
+#include "ErrorInstance.h"
+#include "JSArray.h"
#include "Lexer.h"
#include "RefPtr.h"
+#include "RegExpConstructor.h"
+#include "RegExpObject.h"
#include "SourceProvider.h"
#include "Structure.h"
#include "JSGlobalObject.h"
@@ -83,6 +99,26 @@ namespace QScript
#endif
class TimeoutCheckerProxy;
+ qint32 ToInt32(qsreal);
+ quint32 ToUInt32(qsreal);
+ quint16 ToUInt16(qsreal);
+ qsreal ToInteger(qsreal);
+
+ inline bool ToBool(qsreal);
+ inline bool ToBool(const QString &);
+ inline qint32 ToInt32(const QString &);
+ inline quint32 ToUInt32(const QString &);
+ inline quint16 ToUInt16(const QString &);
+ inline qsreal ToInteger(const QString &);
+#ifdef Q_CC_MSVC
+ // MSVC2008 crashes if these are inlined.
+ qsreal ToNumber(const QString &);
+ QString ToString(qsreal);
+#else
+ inline qsreal ToNumber(const QString &);
+ inline QString ToString(qsreal);
+#endif
+
//some conversion helper functions
inline QScriptEnginePrivate *scriptEngineFromExec(const JSC::ExecState *exec);
bool isFunction(JSC::JSValue value);
@@ -114,29 +150,72 @@ public:
static QScriptEnginePrivate *get(QScriptEngine *q) { return q ? q->d_func() : 0; }
static QScriptEngine *get(QScriptEnginePrivate *d) { return d ? d->q_func() : 0; }
- static bool convert(const QScriptValue &value,
- int type, void *ptr,
- QScriptEnginePrivate *eng);
- QScriptValue create(int type, const void *ptr);
+ static inline bool isArray(JSC::JSValue);
+ static inline bool isDate(JSC::JSValue);
+ static inline bool isError(JSC::JSValue);
+ static inline bool isObject(JSC::JSValue);
+ static inline bool isRegExp(JSC::JSValue);
+ static inline bool isVariant(JSC::JSValue);
+ static inline bool isQObject(JSC::JSValue);
+ static inline bool isQMetaObject(JSC::JSValue);
+
+ static inline bool toBool(JSC::ExecState *, JSC::JSValue);
+ static inline qsreal toInteger(JSC::ExecState *, JSC::JSValue);
+ static inline qsreal toNumber(JSC::ExecState *, JSC::JSValue);
+ static inline qint32 toInt32(JSC::ExecState *, JSC::JSValue);
+ static inline quint32 toUInt32(JSC::ExecState *, JSC::JSValue);
+ static inline quint16 toUInt16(JSC::ExecState *, JSC::JSValue);
+ static inline QString toString(JSC::ExecState *, JSC::JSValue);
+
+ static inline QDateTime toDateTime(JSC::ExecState *, JSC::JSValue);
+#ifndef QT_NO_REGEXP
+ static QRegExp toRegExp(JSC::ExecState*, JSC::JSValue);
+#endif
+ static QVariant toVariant(JSC::ExecState *, JSC::JSValue);
+ static inline QObject *toQObject(JSC::ExecState *, JSC::JSValue);
+ static inline const QMetaObject *toQMetaObject(JSC::ExecState *, JSC::JSValue);
+
+ static inline JSC::JSValue property(JSC::ExecState*, JSC::JSValue, const JSC::Identifier &id,
+ int resolveMode = QScriptValue::ResolvePrototype);
+ static JSC::JSValue propertyHelper(JSC::ExecState*, JSC::JSValue, const JSC::Identifier &id, int resolveMode);
+ static inline JSC::JSValue property(JSC::ExecState*, JSC::JSValue, quint32 index,
+ int resolveMode = QScriptValue::ResolvePrototype);
+ static JSC::JSValue propertyHelper(JSC::ExecState*, JSC::JSValue, quint32, int resolveMode);
+ static inline JSC::JSValue property(JSC::ExecState*, JSC::JSValue, const QString &, int resolveMode);
+ static inline void setProperty(JSC::ExecState*, JSC::JSValue object, const QString &name, JSC::JSValue,
+ const QScriptValue::PropertyFlags &flags = QScriptValue::KeepExistingFlags);
+ static void setProperty(JSC::ExecState*, JSC::JSValue object, const JSC::Identifier &id, JSC::JSValue,
+ const QScriptValue::PropertyFlags &flags = QScriptValue::KeepExistingFlags);
+ static void setProperty(JSC::ExecState*, JSC::JSValue object, quint32 index, JSC::JSValue,
+ const QScriptValue::PropertyFlags &flags = QScriptValue::KeepExistingFlags);
+ static QScriptValue::PropertyFlags propertyFlags(JSC::ExecState*, JSC::JSValue value,
+ const JSC::Identifier &id, const QScriptValue::ResolveFlags &mode);
+ static inline QScriptValue::PropertyFlags propertyFlags(JSC::ExecState*, JSC::JSValue value,
+ const QString &name, const QScriptValue::ResolveFlags &mode);
+
+ static bool convertValue(JSC::ExecState*, JSC::JSValue value,
+ int type, void *ptr);
+ static bool convertNumber(qsreal, int type, void *ptr);
+ static bool convertString(const QString &, int type, void *ptr);
+ static JSC::JSValue create(JSC::ExecState*, int type, const void *ptr);
bool hasDemarshalFunction(int type) const;
inline QScriptValue scriptValueFromJSCValue(JSC::JSValue value);
inline JSC::JSValue scriptValueToJSCValue(const QScriptValue &value);
- QScriptValue scriptValueFromVariant(const QVariant &value);
- QVariant scriptValueToVariant(const QScriptValue &value, int targetType);
-
- JSC::JSValue jscValueFromVariant(const QVariant &value);
- QVariant jscValueToVariant(JSC::JSValue value, int targetType);
+ static inline JSC::JSValue jscValueFromVariant(JSC::ExecState*, const QVariant &value);
+ static QVariant jscValueToVariant(JSC::ExecState*, JSC::JSValue value, int targetType);
+ static inline QVariant &variantValue(JSC::JSValue value);
+ static inline void setVariantValue(JSC::JSValue objectValue, const QVariant &value);
- QScriptValue arrayFromStringList(const QStringList &lst);
- static QStringList stringListFromArray(const QScriptValue &arr);
+ static JSC::JSValue arrayFromStringList(JSC::ExecState*, const QStringList &lst);
+ static QStringList stringListFromArray(JSC::ExecState*, JSC::JSValue arr);
- QScriptValue arrayFromVariantList(const QVariantList &lst);
- static QVariantList variantListFromArray(const QScriptValue &arr);
+ static JSC::JSValue arrayFromVariantList(JSC::ExecState*, const QVariantList &lst);
+ static QVariantList variantListFromArray(JSC::ExecState*, JSC::JSValue arr);
- QScriptValue objectFromVariantMap(const QVariantMap &vmap);
- static QVariantMap variantMapFromObject(const QScriptValue &obj);
+ static JSC::JSValue objectFromVariantMap(JSC::ExecState*, const QVariantMap &vmap);
+ static QVariantMap variantMapFromObject(JSC::ExecState*, JSC::JSValue obj);
JSC::JSValue defaultPrototype(int metaTypeId) const;
void setDefaultPrototype(int metaTypeId, JSC::JSValue prototype);
@@ -177,10 +256,43 @@ public:
void agentDeleted(QScriptEngineAgent *agent);
+ static inline void saveException(JSC::ExecState *, JSC::JSValue *);
+ static inline void restoreException(JSC::ExecState *, JSC::JSValue);
+
void setCurrentException(QScriptValue exception) { m_currentException = exception; }
QScriptValue currentException() const { return m_currentException; }
void clearCurrentException() { m_currentException.d_ptr.reset(); }
+ static QScriptSyntaxCheckResult checkSyntax(const QString &program);
+ static bool canEvaluate(const QString &program);
+
+ inline QScriptValuePrivate *allocateScriptValuePrivate(size_t);
+ inline void freeScriptValuePrivate(QScriptValuePrivate *p);
+
+ inline void registerScriptValue(QScriptValuePrivate *value);
+ inline void unregisterScriptValue(QScriptValuePrivate *value);
+ void detachAllRegisteredScriptValues();
+
+ inline void registerScriptString(QScriptStringPrivate *value);
+ inline void unregisterScriptString(QScriptStringPrivate *value);
+ void detachAllRegisteredScriptStrings();
+
+ static inline JSC::JSValue newArray(JSC::ExecState *, uint length);
+ static inline JSC::JSValue newDate(JSC::ExecState *, qsreal value);
+ static inline JSC::JSValue newDate(JSC::ExecState *, const QDateTime &);
+ inline JSC::JSValue newObject();
+
+#ifndef QT_NO_REGEXP
+ static JSC::JSValue newRegExp(JSC::ExecState *, const QRegExp &);
+#endif
+
+ static JSC::JSValue newRegExp(JSC::ExecState *, const QString &pattern, const QString &flags);
+ JSC::JSValue newVariant(const QVariant &);
+ JSC::JSValue newVariant(JSC::JSValue objectValue, const QVariant &);
+
+ static inline QScriptDeclarativeClass *declarativeClass(JSC::JSValue);
+ static inline QScriptDeclarativeClass::Object *declarativeObject(JSC::JSValue);
+
#ifndef QT_NO_QOBJECT
JSC::JSValue newQObject(QObject *object,
QScriptEngine::ValueOwnership ownership = QScriptEngine::QtOwnership,
@@ -188,9 +300,7 @@ public:
JSC::JSValue newQMetaObject(const QMetaObject *metaObject,
JSC::JSValue ctor);
- static QScriptSyntaxCheckResult checkSyntax(const QString &program);
- static bool canEvaluate(const QString &program);
- static bool convertToNativeQObject(const QScriptValue &value,
+ static bool convertToNativeQObject(JSC::ExecState*, JSC::JSValue,
const QByteArray &targetType,
void **result);
@@ -220,17 +330,6 @@ public:
bool scriptDisconnect(JSC::JSValue signal, JSC::JSValue receiver,
JSC::JSValue function);
- inline QScriptValuePrivate *allocateScriptValuePrivate(size_t);
- inline void freeScriptValuePrivate(QScriptValuePrivate *p);
-
- inline void registerScriptValue(QScriptValuePrivate *value);
- inline void unregisterScriptValue(QScriptValuePrivate *value);
- void detachAllRegisteredScriptValues();
-
- inline void registerScriptString(QScriptStringPrivate *value);
- inline void unregisterScriptString(QScriptStringPrivate *value);
- void detachAllRegisteredScriptStrings();
-
// private slots
void _q_objectDestroyed(QObject *);
#endif
@@ -370,6 +469,51 @@ inline QScriptEnginePrivate *scriptEngineFromExec(const JSC::ExecState *exec)
return static_cast<GlobalClientData*>(exec->globalData().clientData)->engine;
}
+#ifndef Q_CC_MSVC
+// MSVC2008 crashes if these are inlined.
+
+inline QString ToString(qsreal value)
+{
+ return JSC::UString::from(value);
+}
+
+inline qsreal ToNumber(const QString &value)
+{
+ return ((JSC::UString)value).toDouble();
+}
+
+#endif
+
+inline qint32 ToInt32(const QString &value)
+{
+ return ToInt32(ToNumber(value));
+}
+
+inline quint32 ToUInt32(const QString &value)
+{
+ return ToUInt32(ToNumber(value));
+}
+
+inline quint16 ToUInt16(const QString &value)
+{
+ return ToUInt16(ToNumber(value));
+}
+
+inline qsreal ToInteger(const QString &value)
+{
+ return ToInteger(ToNumber(value));
+}
+
+inline bool ToBool(qsreal value)
+{
+ return (value != 0) && !qIsNaN(value);
+}
+
+inline bool ToBool(const QString &value)
+{
+ return !value.isEmpty();
+}
+
} // namespace QScript
inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(size_t size)
@@ -409,6 +553,13 @@ inline void QScriptEnginePrivate::unregisterScriptValue(QScriptValuePrivate *val
value->next = 0;
}
+inline JSC::JSValue QScriptEnginePrivate::jscValueFromVariant(JSC::ExecState *exec, const QVariant &v)
+{
+ JSC::JSValue result = create(exec, v.userType(), v.data());
+ Q_ASSERT(result);
+ return result;
+}
+
inline QScriptValue QScriptEnginePrivate::scriptValueFromJSCValue(JSC::JSValue value)
{
if (!value)
@@ -470,32 +621,83 @@ inline void QScriptValuePrivate::initFrom(const QString &value)
engine->registerScriptValue(this);
}
-inline QScriptValue QScriptValuePrivate::property(const QString &name, int resolveMode) const
+inline JSC::JSValue QScriptEnginePrivate::property(JSC::ExecState *exec, JSC::JSValue value, const QString &name, int resolveMode)
{
- JSC::ExecState *exec = engine->currentFrame;
- return property(JSC::Identifier(exec, name), resolveMode);
+ return property(exec, value, JSC::Identifier(exec, name), resolveMode);
}
-inline QScriptValue QScriptValuePrivate::property(const JSC::Identifier &id, int resolveMode) const
+inline JSC::JSValue QScriptEnginePrivate::property(JSC::ExecState *exec, JSC::JSValue value, const JSC::Identifier &id, int resolveMode)
{
- Q_ASSERT(isObject());
- JSC::ExecState *exec = engine->currentFrame;
- JSC::JSObject *object = JSC::asObject(jscValue);
+ Q_ASSERT(isObject(value));
+ JSC::JSObject *object = JSC::asObject(value);
JSC::PropertySlot slot(object);
if ((resolveMode & QScriptValue::ResolvePrototype) && object->getPropertySlot(exec, id, slot))
- return engine->scriptValueFromJSCValue(slot.getValue(exec, id));
- return propertyHelper(id, resolveMode);
+ return slot.getValue(exec, id);
+ return propertyHelper(exec, value, id, resolveMode);
}
-inline QScriptValue QScriptValuePrivate::property(quint32 index, int resolveMode) const
+inline JSC::JSValue QScriptEnginePrivate::property(JSC::ExecState *exec, JSC::JSValue value, quint32 index, int resolveMode)
{
- Q_ASSERT(isObject());
- JSC::ExecState *exec = engine->currentFrame;
- JSC::JSObject *object = JSC::asObject(jscValue);
+ Q_ASSERT(isObject(value));
+ JSC::JSObject *object = JSC::asObject(value);
JSC::PropertySlot slot(object);
if ((resolveMode & QScriptValue::ResolvePrototype) && object->getPropertySlot(exec, index, slot))
- return engine->scriptValueFromJSCValue(slot.getValue(exec, index));
- return propertyHelper(index, resolveMode);
+ return slot.getValue(exec, index);
+ return propertyHelper(exec, value, index, resolveMode);
+}
+
+inline QScriptValue::PropertyFlags QScriptEnginePrivate::propertyFlags(JSC::ExecState *exec, JSC::JSValue value,
+ const QString &name,
+ const QScriptValue::ResolveFlags &mode)
+{
+ return propertyFlags(exec, value, JSC::Identifier(exec, name), mode);
+}
+
+inline void QScriptEnginePrivate::setProperty(JSC::ExecState *exec, JSC::JSValue objectValue, const QString &name,
+ JSC::JSValue value, const QScriptValue::PropertyFlags &flags)
+{
+ setProperty(exec, objectValue, JSC::Identifier(exec, name), value, flags);
+}
+
+inline JSC::JSValue QScriptValuePrivate::property(const JSC::Identifier &id, int resolveMode) const
+{
+ return QScriptEnginePrivate::property(engine->currentFrame, jscValue, id, resolveMode);
+}
+
+inline JSC::JSValue QScriptValuePrivate::property(quint32 index, int resolveMode) const
+{
+ return QScriptEnginePrivate::property(engine->currentFrame, jscValue, index, resolveMode);
+}
+
+inline JSC::JSValue QScriptValuePrivate::property(const QString &name, int resolveMode) const
+{
+ JSC::ExecState *exec = engine->currentFrame;
+ return QScriptEnginePrivate::property(exec, jscValue, JSC::Identifier(exec, name), resolveMode);
+}
+
+inline QScriptValue::PropertyFlags QScriptValuePrivate::propertyFlags(
+ const JSC::Identifier &id, const QScriptValue::ResolveFlags &mode) const
+{
+ return QScriptEnginePrivate::propertyFlags(engine->currentFrame, jscValue, id, mode);
+}
+
+inline void QScriptValuePrivate::setProperty(const JSC::Identifier &id, const JSC::JSValue &value,
+ const QScriptValue::PropertyFlags &flags)
+{
+ QScriptEnginePrivate::setProperty(engine->currentFrame, jscValue, id, value, flags);
+}
+
+inline void QScriptValuePrivate::setProperty(quint32 index, const JSC::JSValue &value,
+ const QScriptValue::PropertyFlags &flags)
+{
+ QScriptEnginePrivate::setProperty(engine->currentFrame, jscValue, index, value, flags);
+}
+
+inline void QScriptValuePrivate::setProperty(const QString &name, const JSC::JSValue &value,
+ const QScriptValue::PropertyFlags &flags)
+{
+ JSC::ExecState *exec = engine->currentFrame;
+ QScriptEnginePrivate::setProperty(exec, jscValue, JSC::Identifier(exec, name), value, flags);
}
inline void* QScriptValuePrivate::operator new(size_t size, QScriptEnginePrivate *engine)
@@ -514,7 +716,7 @@ inline void QScriptValuePrivate::operator delete(void *ptr)
qFree(d);
}
-inline void QScriptValuePrivate::saveException(JSC::ExecState *exec, JSC::JSValue *val)
+inline void QScriptEnginePrivate::saveException(JSC::ExecState *exec, JSC::JSValue *val)
{
if (exec) {
*val = exec->exception();
@@ -524,7 +726,7 @@ inline void QScriptValuePrivate::saveException(JSC::ExecState *exec, JSC::JSValu
}
}
-inline void QScriptValuePrivate::restoreException(JSC::ExecState *exec, JSC::JSValue val)
+inline void QScriptEnginePrivate::restoreException(JSC::ExecState *exec, JSC::JSValue val)
{
if (exec && val)
exec->setException(val);
@@ -578,6 +780,231 @@ inline JSC::ExecState *QScriptEnginePrivate::globalExec() const
return originalGlobalObject()->globalExec();
}
+inline JSC::JSValue QScriptEnginePrivate::newArray(JSC::ExecState *exec, uint length)
+{
+ return JSC::constructEmptyArray(exec, length);
+}
+
+inline JSC::JSValue QScriptEnginePrivate::newDate(JSC::ExecState *exec, qsreal value)
+{
+ JSC::JSValue val = JSC::jsNumber(exec, value);
+ JSC::ArgList args(&val, 1);
+ return JSC::constructDate(exec, args);
+}
+
+inline JSC::JSValue QScriptEnginePrivate::newDate(JSC::ExecState *exec, const QDateTime &value)
+{
+ return newDate(exec, QScript::FromDateTime(value));
+}
+
+inline JSC::JSValue QScriptEnginePrivate::newObject()
+{
+ return new (currentFrame)QScriptObject(scriptObjectStructure);
+}
+
+inline bool QScriptEnginePrivate::isObject(JSC::JSValue value)
+{
+ return value && value.isObject();
+}
+
+inline bool QScriptEnginePrivate::isArray(JSC::JSValue value)
+{
+ return isObject(value) && value.inherits(&JSC::JSArray::info);
+}
+
+inline bool QScriptEnginePrivate::isDate(JSC::JSValue value)
+{
+ return isObject(value) && value.inherits(&JSC::DateInstance::info);
+}
+
+inline bool QScriptEnginePrivate::isError(JSC::JSValue value)
+{
+ return isObject(value) && value.inherits(&JSC::ErrorInstance::info);
+}
+
+inline bool QScriptEnginePrivate::isRegExp(JSC::JSValue value)
+{
+ return isObject(value) && value.inherits(&JSC::RegExpObject::info);
+}
+
+inline bool QScriptEnginePrivate::isVariant(JSC::JSValue value)
+{
+ if (!isObject(value) || !value.inherits(&QScriptObject::info))
+ return false;
+ QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(value));
+ QScriptObjectDelegate *delegate = object->delegate();
+ return (delegate && (delegate->type() == QScriptObjectDelegate::Variant));
+}
+
+inline bool QScriptEnginePrivate::isQObject(JSC::JSValue value)
+{
+#ifndef QT_NO_QOBJECT
+ if (!isObject(value) || !value.inherits(&QScriptObject::info))
+ return false;
+ QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(value));
+ QScriptObjectDelegate *delegate = object->delegate();
+ return (delegate && (delegate->type() == QScriptObjectDelegate::QtObject ||
+ (delegate->type() == QScriptObjectDelegate::DeclarativeClassObject &&
+ static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass()->isQObject())));
+#else
+ return false;
+#endif
+}
+
+inline bool QScriptEnginePrivate::isQMetaObject(JSC::JSValue value)
+{
+#ifndef QT_NO_QOBJECT
+ return JSC::asObject(value)->inherits(&QScript::QMetaObjectWrapperObject::info);
+#else
+ return false;
+#endif
+}
+
+inline bool QScriptEnginePrivate::toBool(JSC::ExecState *exec, JSC::JSValue value)
+{
+ JSC::JSValue savedException;
+ saveException(exec, &savedException);
+ bool result = value.toBoolean(exec);
+ restoreException(exec, savedException);
+ return result;
+}
+
+inline qsreal QScriptEnginePrivate::toInteger(JSC::ExecState *exec, JSC::JSValue value)
+{
+ JSC::JSValue savedException;
+ saveException(exec, &savedException);
+ qsreal result = value.toInteger(exec);
+ restoreException(exec, savedException);
+ return result;
+}
+
+inline qsreal QScriptEnginePrivate::toNumber(JSC::ExecState *exec, JSC::JSValue value)
+{
+ JSC::JSValue savedException;
+ saveException(exec, &savedException);
+ qsreal result = value.toNumber(exec);
+ restoreException(exec, savedException);
+ return result;
+}
+
+inline qint32 QScriptEnginePrivate::toInt32(JSC::ExecState *exec, JSC::JSValue value)
+{
+ JSC::JSValue savedException;
+ saveException(exec, &savedException);
+ qint32 result = value.toInt32(exec);
+ restoreException(exec, savedException);
+ return result;
+}
+
+inline quint32 QScriptEnginePrivate::toUInt32(JSC::ExecState *exec, JSC::JSValue value)
+{
+ JSC::JSValue savedException;
+ saveException(exec, &savedException);
+ quint32 result = value.toUInt32(exec);
+ restoreException(exec, savedException);
+ return result;
+}
+
+inline quint16 QScriptEnginePrivate::toUInt16(JSC::ExecState *exec, JSC::JSValue value)
+{
+ // ### no equivalent function in JSC
+ return QScript::ToUInt16(toNumber(exec, value));
+}
+
+inline QString QScriptEnginePrivate::toString(JSC::ExecState *exec, JSC::JSValue value)
+{
+ JSC::JSValue savedException;
+ saveException(exec, &savedException);
+ JSC::UString str = value.toString(exec);
+ if (exec && exec->hadException() && !str.size()) {
+ JSC::JSValue savedException2;
+ saveException(exec, &savedException2);
+ str = savedException2.toString(exec);
+ restoreException(exec, savedException2);
+ }
+ if (savedException)
+ restoreException(exec, savedException);
+ return str;
+}
+
+inline QDateTime QScriptEnginePrivate::toDateTime(JSC::ExecState *, JSC::JSValue value)
+{
+ if (!isDate(value))
+ return QDateTime();
+ qsreal t = static_cast<JSC::DateInstance*>(JSC::asObject(value))->internalNumber();
+ return QScript::ToDateTime(t, Qt::LocalTime);
+}
+
+inline QObject *QScriptEnginePrivate::toQObject(JSC::ExecState *exec, JSC::JSValue value)
+{
+#ifndef QT_NO_QOBJECT
+ if (isObject(value) && value.inherits(&QScriptObject::info)) {
+ QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(value));
+ QScriptObjectDelegate *delegate = object->delegate();
+ if (!delegate)
+ return 0;
+ if (delegate->type() == QScriptObjectDelegate::QtObject)
+ return static_cast<QScript::QObjectDelegate*>(delegate)->value();
+ if (delegate->type() == QScriptObjectDelegate::DeclarativeClassObject)
+ return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass()->toQObject(declarativeObject(value));
+ if (delegate->type() == QScriptObjectDelegate::Variant) {
+ QVariant var = variantValue(value);
+ int type = var.userType();
+ if ((type == QMetaType::QObjectStar) || (type == QMetaType::QWidgetStar))
+ return *reinterpret_cast<QObject* const *>(var.constData());
+ }
+ }
+#endif
+ return 0;
+}
+
+inline const QMetaObject *QScriptEnginePrivate::toQMetaObject(JSC::ExecState*, JSC::JSValue value)
+{
+#ifndef QT_NO_QOBJECT
+ if (isQMetaObject(value))
+ return static_cast<QScript::QMetaObjectWrapperObject*>(JSC::asObject(value))->value();
+#endif
+ return 0;
+}
+
+inline QVariant &QScriptEnginePrivate::variantValue(JSC::JSValue value)
+{
+ Q_ASSERT(value.inherits(&QScriptObject::info));
+ QScriptObjectDelegate *delegate = static_cast<QScriptObject*>(JSC::asObject(value))->delegate();
+ Q_ASSERT(delegate && (delegate->type() == QScriptObjectDelegate::Variant));
+ return static_cast<QScript::QVariantDelegate*>(delegate)->value();
+}
+
+inline void QScriptEnginePrivate::setVariantValue(JSC::JSValue objectValue, const QVariant &value)
+{
+ Q_ASSERT(objectValue.inherits(&QScriptObject::info));
+ QScriptObjectDelegate *delegate = static_cast<QScriptObject*>(JSC::asObject(objectValue))->delegate();
+ Q_ASSERT(delegate && (delegate->type() == QScriptObjectDelegate::Variant));
+ static_cast<QScript::QVariantDelegate*>(delegate)->setValue(value);
+}
+
+inline QScriptDeclarativeClass *QScriptEnginePrivate::declarativeClass(JSC::JSValue v)
+{
+ if (!QScriptEnginePrivate::isObject(v) || !v.inherits(&QScriptObject::info))
+ return 0;
+ QScriptObject *scriptObject = static_cast<QScriptObject*>(JSC::asObject(v));
+ QScriptObjectDelegate *delegate = scriptObject->delegate();
+ if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
+ return 0;
+ return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass();
+}
+
+inline QScriptDeclarativeClass::Object *QScriptEnginePrivate::declarativeObject(JSC::JSValue v)
+{
+ if (!QScriptEnginePrivate::isObject(v) || !v.inherits(&QScriptObject::info))
+ return 0;
+ QScriptObject *scriptObject = static_cast<QScriptObject*>(JSC::asObject(v));
+ QScriptObjectDelegate *delegate = scriptObject->delegate();
+ if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
+ return 0;
+ return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->object();
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp
index 5bfe46a..7f1fdaa 100644
--- a/src/script/api/qscriptvalue.cpp
+++ b/src/script/api/qscriptvalue.cpp
@@ -29,33 +29,19 @@
#include "qscriptengine_p.h"
#include "qscriptstring_p.h"
-#include "JSArray.h"
#include "JSGlobalObject.h"
#include "JSImmediate.h"
#include "JSObject.h"
#include "JSValue.h"
#include "JSFunction.h"
-#include "DateInstance.h"
-#include "ErrorInstance.h"
-#include "RegExpObject.h"
#include "Identifier.h"
#include "Operations.h"
#include "Arguments.h"
-#include <QtCore/qdatetime.h>
-#include <QtCore/qregexp.h>
#include <QtCore/qvariant.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qnumeric.h>
-#include "utils/qscriptdate_p.h"
-#include "bridge/qscriptobject_p.h"
-#include "bridge/qscriptclassobject_p.h"
-#include "bridge/qscriptvariant_p.h"
-#include "bridge/qscriptqobject_p.h"
-#include "bridge/qscriptdeclarativeclass_p.h"
-#include "bridge/qscriptdeclarativeobject_p.h"
-
/*!
\since 4.3
\class QScriptValue
@@ -180,248 +166,8 @@
\omitvalue ResolveFull Check the object's own properties first, then search the prototype chain, and finally search the scope chain.
*/
-// ### move
-
-#include <QtCore/qnumeric.h>
-#include <math.h>
-
QT_BEGIN_NAMESPACE
-namespace QScript
-{
-
-static const qsreal D32 = 4294967296.0;
-
-qint32 ToInt32(qsreal n)
-{
- if (qIsNaN(n) || qIsInf(n) || (n == 0))
- return 0;
-
- qsreal sign = (n < 0) ? -1.0 : 1.0;
- qsreal 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);
-}
-
-quint32 ToUint32(qsreal n)
-{
- if (qIsNaN(n) || qIsInf(n) || (n == 0))
- return 0;
-
- qsreal sign = (n < 0) ? -1.0 : 1.0;
- qsreal abs_n = fabs(n);
-
- n = ::fmod(sign * ::floor(abs_n), D32);
-
- if (n < 0)
- n += D32;
-
- return quint32 (n);
-}
-
-quint16 ToUint16(qsreal n)
-{
- static const qsreal D16 = 65536.0;
-
- if (qIsNaN(n) || qIsInf(n) || (n == 0))
- return 0;
-
- qsreal sign = (n < 0) ? -1.0 : 1.0;
- qsreal abs_n = fabs(n);
-
- n = ::fmod(sign * ::floor(abs_n), D16);
-
- if (n < 0)
- n += D16;
-
- return quint16 (n);
-}
-
-qsreal ToInteger(qsreal n)
-{
- if (qIsNaN(n))
- return 0;
-
- if (n == 0 || qIsInf(n))
- return n;
-
- int sign = n < 0 ? -1 : 1;
- return sign * ::floor(::fabs(n));
-}
-
-} // namespace QScript
-
-QScriptValue QScriptValuePrivate::propertyHelper(const JSC::Identifier &id, int resolveMode) const
-{
- JSC::JSValue result;
- if (!(resolveMode & QScriptValue::ResolvePrototype)) {
- // Look in the object's own properties
- JSC::ExecState *exec = engine->currentFrame;
- JSC::JSObject *object = JSC::asObject(jscValue);
- JSC::PropertySlot slot(object);
- if (object->getOwnPropertySlot(exec, id, slot))
- result = slot.getValue(exec, id);
- }
- if (!result && (resolveMode & QScriptValue::ResolveScope)) {
- // ### check if it's a function object and look in the scope chain
- QScriptValue scope = property(QString::fromLatin1("__qt_scope__"), QScriptValue::ResolveLocal);
- if (scope.isObject())
- result = engine->scriptValueToJSCValue(QScriptValuePrivate::get(scope)->property(id, resolveMode));
- }
- return engine->scriptValueFromJSCValue(result);
-}
-
-QScriptValue QScriptValuePrivate::propertyHelper(quint32 index, int resolveMode) const
-{
- JSC::JSValue result;
- if (!(resolveMode & QScriptValue::ResolvePrototype)) {
- // Look in the object's own properties
- JSC::ExecState *exec = engine->currentFrame;
- JSC::JSObject *object = JSC::asObject(jscValue);
- JSC::PropertySlot slot(object);
- if (object->getOwnPropertySlot(exec, index, slot))
- result = slot.getValue(exec, index);
- }
- return engine->scriptValueFromJSCValue(result);
-}
-
-void QScriptValuePrivate::setProperty(const JSC::Identifier &id, const QScriptValue &value,
- const QScriptValue::PropertyFlags &flags)
-{
- QScriptEnginePrivate *valueEngine = QScriptValuePrivate::getEngine(value);
- if (valueEngine && (valueEngine != engine)) {
- qWarning("QScriptValue::setProperty(%s) failed: "
- "cannot set value created in a different engine",
- qPrintable(QString(id.ustring())));
- return;
- }
- JSC::ExecState *exec = engine->currentFrame;
- JSC::JSValue jsValue = engine->scriptValueToJSCValue(value);
- JSC::JSObject *thisObject = JSC::asObject(jscValue);
- JSC::JSValue setter = thisObject->lookupSetter(exec, id);
- JSC::JSValue getter = thisObject->lookupGetter(exec, id);
- if ((flags & QScriptValue::PropertyGetter) || (flags & QScriptValue::PropertySetter)) {
- if (!jsValue) {
- // deleting getter/setter
- if ((flags & QScriptValue::PropertyGetter) && (flags & QScriptValue::PropertySetter)) {
- // deleting both: just delete the property
- thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false);
- } else if (flags & QScriptValue::PropertyGetter) {
- // preserve setter, if there is one
- thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false);
- if (setter && setter.isObject())
- thisObject->defineSetter(exec, id, JSC::asObject(setter));
- } else { // flags & QScriptValue::PropertySetter
- // preserve getter, if there is one
- thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false);
- if (getter && getter.isObject())
- thisObject->defineGetter(exec, id, JSC::asObject(getter));
- }
- } else {
- if (jsValue.isObject()) { // ### should check if it has callData()
- // defining getter/setter
- if (id == exec->propertyNames().underscoreProto) {
- qWarning("QScriptValue::setProperty() failed: "
- "cannot set getter or setter of native property `__proto__'");
- } else {
- if (flags & QScriptValue::PropertyGetter)
- thisObject->defineGetter(exec, id, JSC::asObject(jsValue));
- if (flags & QScriptValue::PropertySetter)
- thisObject->defineSetter(exec, id, JSC::asObject(jsValue));
- }
- } else {
- qWarning("QScriptValue::setProperty(): getter/setter must be a function");
- }
- }
- } else {
- // setting the value
- if (getter && getter.isObject() && !(setter && setter.isObject())) {
- qWarning("QScriptValue::setProperty() failed: "
- "property '%s' has a getter but no setter",
- qPrintable(QString(id.ustring())));
- return;
- }
- if (!jsValue) {
- // ### check if it's a getter/setter property
- thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false);
- } else if (flags != QScriptValue::KeepExistingFlags) {
- if (thisObject->hasOwnProperty(exec, id))
- thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false); // ### hmmm - can't we just update the attributes?
- unsigned attribs = 0;
- if (flags & QScriptValue::ReadOnly)
- attribs |= JSC::ReadOnly;
- if (flags & QScriptValue::SkipInEnumeration)
- attribs |= JSC::DontEnum;
- if (flags & QScriptValue::Undeletable)
- attribs |= JSC::DontDelete;
- attribs |= flags & QScriptValue::UserRange;
- thisObject->putWithAttributes(exec, id, jsValue, attribs);
- } else {
- JSC::PutPropertySlot slot;
- thisObject->put(exec, id, jsValue, slot);
- }
- }
-}
-
-QScriptValue::PropertyFlags QScriptValuePrivate::propertyFlags(const JSC::Identifier &id,
- const QScriptValue::ResolveFlags &mode) const
-{
- JSC::ExecState *exec = engine->currentFrame;
- JSC::JSObject *object = JSC::asObject(jscValue);
- unsigned attribs = 0;
- JSC::PropertyDescriptor descriptor;
- if (object->getOwnPropertyDescriptor(exec, id, descriptor))
- attribs = descriptor.attributes();
- else if (!object->getPropertyAttributes(exec, id, attribs)) {
- if ((mode & QScriptValue::ResolvePrototype) && object->prototype() && object->prototype().isObject()) {
- QScriptValue proto = engine->scriptValueFromJSCValue(object->prototype());
- return QScriptValuePrivate::get(proto)->propertyFlags(id, mode);
- }
- return 0;
- }
- QScriptValue::PropertyFlags result = 0;
- if (attribs & JSC::ReadOnly)
- result |= QScriptValue::ReadOnly;
- if (attribs & JSC::DontEnum)
- result |= QScriptValue::SkipInEnumeration;
- if (attribs & JSC::DontDelete)
- result |= QScriptValue::Undeletable;
- //We cannot rely on attribs JSC::Setter/Getter because they are not necesserly set by JSC (bug?)
- if (attribs & JSC::Getter || !object->lookupGetter(exec, id).isUndefinedOrNull())
- result |= QScriptValue::PropertyGetter;
- if (attribs & JSC::Setter || !object->lookupSetter(exec, id).isUndefinedOrNull())
- result |= QScriptValue::PropertySetter;
- if (attribs & QScript::QObjectMemberAttribute)
- result |= QScriptValue::QObjectMember;
- result |= QScriptValue::PropertyFlag(attribs & QScriptValue::UserRange);
- return result;
-}
-
-QVariant &QScriptValuePrivate::variantValue() const
-{
- Q_ASSERT(jscValue.inherits(&QScriptObject::info));
- QScriptObjectDelegate *delegate = static_cast<QScriptObject*>(JSC::asObject(jscValue))->delegate();
- Q_ASSERT(delegate && (delegate->type() == QScriptObjectDelegate::Variant));
- return static_cast<QScript::QVariantDelegate*>(delegate)->value();
-}
-
-void QScriptValuePrivate::setVariantValue(const QVariant &value)
-{
- Q_ASSERT(jscValue.inherits(&QScriptObject::info));
- QScriptObjectDelegate *delegate = static_cast<QScriptObject*>(JSC::asObject(jscValue))->delegate();
- Q_ASSERT(delegate && (delegate->type() == QScriptObjectDelegate::Variant));
- static_cast<QScript::QVariantDelegate*>(delegate)->setValue(value);
-}
-
void QScriptValuePrivate::detachFromEngine()
{
if (isJSC())
@@ -707,9 +453,9 @@ QScriptValue &QScriptValue::operator=(const QScriptValue &other)
bool QScriptValue::isError() const
{
Q_D(const QScriptValue);
- if (!d || !d->isObject())
+ if (!d || !d->isJSC())
return false;
- return d->jscValue.inherits(&JSC::ErrorInstance::info);
+ return QScriptEnginePrivate::isError(d->jscValue);
}
/*!
@@ -721,9 +467,9 @@ bool QScriptValue::isError() const
bool QScriptValue::isArray() const
{
Q_D(const QScriptValue);
- if (!d || !d->isObject())
+ if (!d || !d->isJSC())
return false;
- return d->jscValue.inherits(&JSC::JSArray::info);
+ return QScriptEnginePrivate::isArray(d->jscValue);
}
/*!
@@ -735,9 +481,9 @@ bool QScriptValue::isArray() const
bool QScriptValue::isDate() const
{
Q_D(const QScriptValue);
- if (!d || !d->isObject())
+ if (!d || !d->isJSC())
return false;
- return d->jscValue.inherits(&JSC::DateInstance::info);
+ return QScriptEnginePrivate::isDate(d->jscValue);
}
/*!
@@ -749,9 +495,9 @@ bool QScriptValue::isDate() const
bool QScriptValue::isRegExp() const
{
Q_D(const QScriptValue);
- if (!d || !d->isObject())
+ if (!d || !d->isJSC())
return false;
- return d->jscValue.inherits(&JSC::RegExpObject::info);
+ return QScriptEnginePrivate::isRegExp(d->jscValue);
}
/*!
@@ -816,7 +562,8 @@ QScriptValue QScriptValue::scope() const
if (!d || !d->isObject())
return QScriptValue();
// ### make hidden property
- return d->property(QLatin1String("__qt_scope__"), QScriptValue::ResolveLocal);
+ JSC::JSValue result = d->property(QLatin1String("__qt_scope__"), QScriptValue::ResolveLocal);
+ return d->engine->scriptValueFromJSCValue(result);
}
/*!
@@ -910,9 +657,9 @@ QScriptValue ToPrimitive(const QScriptValue &object, JSC::PreferredPrimitiveType
Q_ASSERT(pp->engine != 0);
JSC::ExecState *exec = pp->engine->currentFrame;
JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
+ QScriptEnginePrivate::saveException(exec, &savedException);
JSC::JSValue result = JSC::asObject(pp->jscValue)->toPrimitive(exec, hint);
- QScriptValuePrivate::restoreException(exec, savedException);
+ QScriptEnginePrivate::restoreException(exec, savedException);
return pp->engine->scriptValueFromJSCValue(result);
}
@@ -1103,9 +850,9 @@ bool QScriptValue::equals(const QScriptValue &other) const
if (eng_p) {
JSC::ExecState *exec = eng_p->currentFrame;
JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
+ QScriptEnginePrivate::saveException(exec, &savedException);
bool result = JSC::JSValue::equal(exec, d->jscValue, other.d_ptr->jscValue);
- QScriptValuePrivate::restoreException(exec, savedException);
+ QScriptEnginePrivate::restoreException(exec, savedException);
return result;
}
}
@@ -1191,21 +938,10 @@ QString QScriptValue::toString() const
switch (d->type) {
case QScriptValuePrivate::JavaScriptCore: {
JSC::ExecState *exec = d->engine ? d->engine->currentFrame : 0;
- JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
- JSC::UString str = d->jscValue.toString(exec);
- if (exec && exec->hadException() && !str.size()) {
- JSC::JSValue savedException2;
- QScriptValuePrivate::saveException(exec, &savedException2);
- str = savedException2.toString(exec);
- QScriptValuePrivate::restoreException(exec, savedException2);
- }
- if (savedException)
- QScriptValuePrivate::restoreException(exec, savedException);
- return str;
+ return QScriptEnginePrivate::toString(exec, d->jscValue);
}
case QScriptValuePrivate::Number:
- return JSC::UString::from(d->numberValue);
+ return QScript::ToString(d->numberValue);
case QScriptValuePrivate::String:
return d->stringValue;
}
@@ -1232,16 +968,12 @@ qsreal QScriptValue::toNumber() const
switch (d->type) {
case QScriptValuePrivate::JavaScriptCore: {
JSC::ExecState *exec = d->engine ? d->engine->currentFrame : 0;
- JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
- qsreal result = d->jscValue.toNumber(exec);
- QScriptValuePrivate::restoreException(exec, savedException);
- return result;
+ return QScriptEnginePrivate::toNumber(exec, d->jscValue);
}
case QScriptValuePrivate::Number:
return d->numberValue;
case QScriptValuePrivate::String:
- return ((JSC::UString)d->stringValue).toDouble();
+ return QScript::ToNumber(d->stringValue);
}
return 0;
}
@@ -1259,16 +991,12 @@ bool QScriptValue::toBoolean() const
switch (d->type) {
case QScriptValuePrivate::JavaScriptCore: {
JSC::ExecState *exec = d->engine ? d->engine->currentFrame : 0;
- JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
- bool result = d->jscValue.toBoolean(exec);
- QScriptValuePrivate::restoreException(exec, savedException);
- return result;
+ return QScriptEnginePrivate::toBool(exec, d->jscValue);
}
case QScriptValuePrivate::Number:
- return (d->numberValue != 0) && !qIsNaN(d->numberValue);
+ return QScript::ToBool(d->numberValue);
case QScriptValuePrivate::String:
- return (!d->stringValue.isEmpty());
+ return QScript::ToBool(d->stringValue);
}
return false;
}
@@ -1295,16 +1023,12 @@ bool QScriptValue::toBool() const
switch (d->type) {
case QScriptValuePrivate::JavaScriptCore: {
JSC::ExecState *exec = d->engine ? d->engine->currentFrame : 0;
- JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
- bool result = d->jscValue.toBoolean(exec);
- QScriptValuePrivate::restoreException(exec, savedException);
- return result;
+ return QScriptEnginePrivate::toBool(exec, d->jscValue);
}
case QScriptValuePrivate::Number:
- return (d->numberValue != 0) && !qIsNaN(d->numberValue);
+ return QScript::ToBool(d->numberValue);
case QScriptValuePrivate::String:
- return (!d->stringValue.isEmpty());
+ return QScript::ToBool(d->stringValue);
}
return false;
}
@@ -1329,16 +1053,12 @@ qint32 QScriptValue::toInt32() const
switch (d->type) {
case QScriptValuePrivate::JavaScriptCore: {
JSC::ExecState *exec = d->engine ? d->engine->currentFrame : 0;
- JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
- qint32 result = d->jscValue.toInt32(exec);
- QScriptValuePrivate::restoreException(exec, savedException);
- return result;
+ return QScriptEnginePrivate::toInt32(exec, d->jscValue);
}
case QScriptValuePrivate::Number:
return QScript::ToInt32(d->numberValue);
case QScriptValuePrivate::String:
- return QScript::ToInt32(((JSC::UString)d->stringValue).toDouble());
+ return QScript::ToInt32(d->stringValue);
}
return 0;
}
@@ -1363,16 +1083,12 @@ quint32 QScriptValue::toUInt32() const
switch (d->type) {
case QScriptValuePrivate::JavaScriptCore: {
JSC::ExecState *exec = d->engine ? d->engine->currentFrame : 0;
- JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
- quint32 result = d->jscValue.toUInt32(exec);
- QScriptValuePrivate::restoreException(exec, savedException);
- return result;
+ return QScriptEnginePrivate::toUInt32(exec, d->jscValue);
}
case QScriptValuePrivate::Number:
- return QScript::ToUint32(d->numberValue);
+ return QScript::ToUInt32(d->numberValue);
case QScriptValuePrivate::String:
- return QScript::ToUint32(((JSC::UString)d->stringValue).toDouble());
+ return QScript::ToUInt32(d->stringValue);
}
return 0;
}
@@ -1396,13 +1112,13 @@ quint16 QScriptValue::toUInt16() const
return 0;
switch (d->type) {
case QScriptValuePrivate::JavaScriptCore: {
- // ### no equivalent function in JSC
- return QScript::ToUint16(toNumber());
+ JSC::ExecState *exec = d->engine ? d->engine->currentFrame : 0;
+ return QScriptEnginePrivate::toUInt16(exec, d->jscValue);
}
case QScriptValuePrivate::Number:
- return QScript::ToUint16(d->numberValue);
+ return QScript::ToUInt16(d->numberValue);
case QScriptValuePrivate::String:
- return QScript::ToUint16(((JSC::UString)d->stringValue).toDouble());
+ return QScript::ToUInt16(d->stringValue);
}
return 0;
}
@@ -1427,16 +1143,12 @@ qsreal QScriptValue::toInteger() const
switch (d->type) {
case QScriptValuePrivate::JavaScriptCore: {
JSC::ExecState *exec = d->engine ? d->engine->currentFrame : 0;
- JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
- qsreal result = d->jscValue.toInteger(exec);
- QScriptValuePrivate::restoreException(exec, savedException);
- return result;
+ return QScriptEnginePrivate::toInteger(exec, d->jscValue);
}
case QScriptValuePrivate::Number:
return QScript::ToInteger(d->numberValue);
case QScriptValuePrivate::String:
- return QScript::ToInteger(((JSC::UString)d->stringValue).toDouble());
+ return QScript::ToInteger(d->stringValue);
}
return 0;
}
@@ -1469,40 +1181,10 @@ QVariant QScriptValue::toVariant() const
if (!d)
return QVariant();
switch (d->type) {
- case QScriptValuePrivate::JavaScriptCore:
- if (isObject()) {
- if (isVariant())
- return d->variantValue();
-#ifndef QT_NO_QOBJECT
- else if (isQObject())
- return qVariantFromValue(toQObject());
-#endif
- else if (isDate())
- return QVariant(toDateTime());
-#ifndef QT_NO_REGEXP
- else if (isRegExp())
- return QVariant(toRegExp());
-#endif
- else if (isArray())
- return QScriptEnginePrivate::variantListFromArray(*this);
- else if (QScriptDeclarativeClass *dc = QScriptDeclarativeClass::scriptClass(*this))
- return dc->toVariant(QScriptDeclarativeClass::object(*this));
- // try to convert to primitive
- JSC::ExecState *exec = d->engine->currentFrame;
- JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
- JSC::JSValue prim = d->jscValue.toPrimitive(exec);
- QScriptValuePrivate::restoreException(exec, savedException);
- if (!prim.isObject())
- return d->engine->scriptValueFromJSCValue(prim).toVariant();
- } else if (isNumber()) {
- return QVariant(toNumber());
- } else if (isString()) {
- return QVariant(toString());
- } else if (isBool()) {
- return QVariant(toBool());
- }
- return QVariant();
+ case QScriptValuePrivate::JavaScriptCore: {
+ JSC::ExecState *exec = d->engine ? d->engine->currentFrame : 0;
+ return QScriptEnginePrivate::toVariant(exec, d->jscValue);
+ }
case QScriptValuePrivate::Number:
return QVariant(d->numberValue);
case QScriptValuePrivate::String:
@@ -1534,10 +1216,9 @@ QScriptValue QScriptValue::toObject() const
QDateTime QScriptValue::toDateTime() const
{
Q_D(const QScriptValue);
- if (!isDate())
+ if (!d || !d->engine)
return QDateTime();
- qsreal t = static_cast<JSC::DateInstance*>(JSC::asObject(d->jscValue))->internalNumber();
- return QScript::ToDateTime(t, Qt::LocalTime);
+ return QScriptEnginePrivate::toDateTime(d->engine->currentFrame, d->jscValue);
}
#ifndef QT_NO_REGEXP
@@ -1551,13 +1232,9 @@ QDateTime QScriptValue::toDateTime() const
QRegExp QScriptValue::toRegExp() const
{
Q_D(const QScriptValue);
- if (!isRegExp())
- return QRegExp();
- QString pattern = d->property(QLatin1String("source"), QScriptValue::ResolvePrototype).toString();
- Qt::CaseSensitivity kase = Qt::CaseSensitive;
- if (d->property(QLatin1String("ignoreCase"), QScriptValue::ResolvePrototype).toBool())
- kase = Qt::CaseInsensitive;
- return QRegExp(pattern, kase, QRegExp::RegExp2);
+ if (!d || !d->engine)
+ return QRegExp();
+ return QScriptEnginePrivate::toRegExp(d->engine->currentFrame, d->jscValue);
}
#endif // QT_NO_REGEXP
@@ -1574,19 +1251,9 @@ QRegExp QScriptValue::toRegExp() const
QObject *QScriptValue::toQObject() const
{
Q_D(const QScriptValue);
- if (isQObject()) {
- QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
- QScriptObjectDelegate *delegate = object->delegate();
- if (delegate->type() == QScriptObjectDelegate::DeclarativeClassObject)
- return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass()->toQObject(QScriptDeclarativeClass::object(*this));
- return static_cast<QScript::QObjectDelegate*>(delegate)->value();
- } else if (isVariant()) {
- QVariant var = toVariant();
- int type = var.userType();
- if ((type == QMetaType::QObjectStar) || (type == QMetaType::QWidgetStar))
- return *reinterpret_cast<QObject* const *>(var.constData());
- }
- return 0;
+ if (!d || !d->engine)
+ return 0;
+ return QScriptEnginePrivate::toQObject(d->engine->currentFrame, d->jscValue);
}
/*!
@@ -1598,9 +1265,9 @@ QObject *QScriptValue::toQObject() const
const QMetaObject *QScriptValue::toQMetaObject() const
{
Q_D(const QScriptValue);
- if (isQMetaObject())
- return static_cast<QScript::QMetaObjectWrapperObject*>(JSC::asObject(d->jscValue))->value();
- return 0;
+ if (!d || !d->engine)
+ return 0;
+ return QScriptEnginePrivate::toQMetaObject(d->engine->currentFrame, d->jscValue);
}
/*!
@@ -1634,8 +1301,15 @@ void QScriptValue::setProperty(const QString &name, const QScriptValue &value,
Q_D(QScriptValue);
if (!d || !d->isObject())
return;
- JSC::ExecState *exec = d->engine->currentFrame;
- d->setProperty(JSC::Identifier(exec, name), value, flags);
+ QScriptEnginePrivate *valueEngine = QScriptValuePrivate::getEngine(value);
+ if (valueEngine && (valueEngine != d->engine)) {
+ qWarning("QScriptValue::setProperty(%s) failed: "
+ "cannot set value created in a different engine",
+ qPrintable(name));
+ return;
+ }
+ JSC::JSValue jsValue = d->engine->scriptValueToJSCValue(value);
+ d->setProperty(name, jsValue, flags);
}
/*!
@@ -1659,7 +1333,7 @@ QScriptValue QScriptValue::property(const QString &name,
Q_D(const QScriptValue);
if (!d || !d->isObject())
return QScriptValue();
- return d->property(name, mode);
+ return d->engine->scriptValueFromJSCValue(d->property(name, mode));
}
/*!
@@ -1681,7 +1355,7 @@ QScriptValue QScriptValue::property(quint32 arrayIndex,
Q_D(const QScriptValue);
if (!d || !d->isObject())
return QScriptValue();
- return d->property(arrayIndex, mode);
+ return d->engine->scriptValueFromJSCValue(d->property(arrayIndex, mode));
}
/*!
@@ -1708,33 +1382,8 @@ void QScriptValue::setProperty(quint32 arrayIndex, const QScriptValue &value,
"cannot set value created in a different engine");
return;
}
- JSC::ExecState *exec = d->engine->currentFrame;
- JSC::JSValue jscValue = d->engine->scriptValueToJSCValue(value);
- if (!jscValue) {
- JSC::asObject(d->jscValue)->deleteProperty(exec, arrayIndex, /*checkDontDelete=*/false);
- } else {
- if ((flags & QScriptValue::PropertyGetter) || (flags & QScriptValue::PropertySetter)) {
- // fall back to string-based setProperty(), since there is no
- // JSC::JSObject::defineGetter(unsigned)
- d->setProperty(JSC::Identifier::from(exec, arrayIndex), value, flags);
- } else {
- if (flags != QScriptValue::KeepExistingFlags) {
-// if (JSC::asObject(d->jscValue)->hasOwnProperty(exec, arrayIndex))
-// JSC::asObject(d->jscValue)->deleteProperty(exec, arrayIndex);
- unsigned attribs = 0;
- if (flags & QScriptValue::ReadOnly)
- attribs |= JSC::ReadOnly;
- if (flags & QScriptValue::SkipInEnumeration)
- attribs |= JSC::DontEnum;
- if (flags & QScriptValue::Undeletable)
- attribs |= JSC::DontDelete;
- attribs |= flags & QScriptValue::UserRange;
- JSC::asObject(d->jscValue)->putWithAttributes(exec, arrayIndex, jscValue, attribs);
- } else {
- JSC::asObject(d->jscValue)->put(exec, arrayIndex, jscValue);
- }
- }
- }
+ JSC::JSValue jsValue = d->engine->scriptValueToJSCValue(value);
+ d->setProperty(arrayIndex, jsValue, flags);
}
/*!
@@ -1755,7 +1404,7 @@ QScriptValue QScriptValue::property(const QScriptString &name,
Q_D(const QScriptValue);
if (!d || !d->isObject() || !QScriptStringPrivate::isValid(name))
return QScriptValue();
- return d->property(name.d_ptr->identifier, mode);
+ return d->engine->scriptValueFromJSCValue(d->property(name.d_ptr->identifier, mode));
}
/*!
@@ -1778,7 +1427,15 @@ void QScriptValue::setProperty(const QScriptString &name,
Q_D(QScriptValue);
if (!d || !d->isObject() || !QScriptStringPrivate::isValid(name))
return;
- d->setProperty(name.d_ptr->identifier, value, flags);
+ QScriptEnginePrivate *valueEngine = QScriptValuePrivate::getEngine(value);
+ if (valueEngine && (valueEngine != d->engine)) {
+ qWarning("QScriptValue::setProperty(%s) failed: "
+ "cannot set value created in a different engine",
+ qPrintable(name.toString()));
+ return;
+ }
+ JSC::JSValue jsValue = d->engine->scriptValueToJSCValue(value);
+ d->setProperty(name.d_ptr->identifier, jsValue, flags);
}
/*!
@@ -1882,12 +1539,12 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
JSC::ArgList jscArgs(argsVector.data(), argsVector.size());
JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
+ QScriptEnginePrivate::saveException(exec, &savedException);
JSC::JSValue result = JSC::call(exec, callee, callType, callData, jscThisObject, jscArgs);
if (exec->hadException()) {
result = exec->exception();
} else {
- QScriptValuePrivate::restoreException(exec, savedException);
+ QScriptEnginePrivate::restoreException(exec, savedException);
}
return d->engine->scriptValueFromJSCValue(result);
}
@@ -1963,12 +1620,12 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
}
JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
+ QScriptEnginePrivate::saveException(exec, &savedException);
JSC::JSValue result = JSC::call(exec, callee, callType, callData, jscThisObject, applyArgs);
if (exec->hadException()) {
result = exec->exception();
} else {
- QScriptValuePrivate::restoreException(exec, savedException);
+ QScriptEnginePrivate::restoreException(exec, savedException);
}
return d->engine->scriptValueFromJSCValue(result);
}
@@ -2015,12 +1672,12 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args)
JSC::ArgList jscArgs(argsVector.data(), argsVector.size());
JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
+ QScriptEnginePrivate::saveException(exec, &savedException);
JSC::JSObject *result = JSC::construct(exec, callee, constructType, constructData, jscArgs);
if (exec->hadException()) {
result = JSC::asObject(exec->exception());
} else {
- QScriptValuePrivate::restoreException(exec, savedException);
+ QScriptEnginePrivate::restoreException(exec, savedException);
}
return d->engine->scriptValueFromJSCValue(result);
}
@@ -2074,13 +1731,13 @@ QScriptValue QScriptValue::construct(const QScriptValue &arguments)
}
JSC::JSValue savedException;
- QScriptValuePrivate::saveException(exec, &savedException);
+ QScriptEnginePrivate::saveException(exec, &savedException);
JSC::JSObject *result = JSC::construct(exec, callee, constructType, constructData, applyArgs);
if (exec->hadException()) {
if (exec->exception().isObject())
result = JSC::asObject(exec->exception());
} else {
- QScriptValuePrivate::restoreException(exec, savedException);
+ QScriptEnginePrivate::restoreException(exec, savedException);
}
return d->engine->scriptValueFromJSCValue(result);
}
@@ -2229,11 +1886,9 @@ bool QScriptValue::isObject() const
bool QScriptValue::isVariant() const
{
Q_D(const QScriptValue);
- if (!d || !d->isJSC() || !d->jscValue.inherits(&QScriptObject::info))
+ if (!d || !d->isJSC())
return false;
- QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
- QScriptObjectDelegate *delegate = object->delegate();
- return (delegate && (delegate->type() == QScriptObjectDelegate::Variant));
+ return QScriptEnginePrivate::isVariant(d->jscValue);
}
/*!
@@ -2248,13 +1903,9 @@ bool QScriptValue::isVariant() const
bool QScriptValue::isQObject() const
{
Q_D(const QScriptValue);
- if (!d || !d->isJSC() || !d->jscValue.inherits(&QScriptObject::info))
+ if (!d || !d->isJSC())
return false;
- QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
- QScriptObjectDelegate *delegate = object->delegate();
- return (delegate && (delegate->type() == QScriptObjectDelegate::QtObject ||
- (delegate->type() == QScriptObjectDelegate::DeclarativeClassObject &&
- static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass()->isQObject())));
+ return QScriptEnginePrivate::isQObject(d->jscValue);
}
/*!
@@ -2266,9 +1917,9 @@ bool QScriptValue::isQObject() const
bool QScriptValue::isQMetaObject() const
{
Q_D(const QScriptValue);
- if (!d || !d->isObject())
+ if (!d || !d->isJSC())
return false;
- return JSC::asObject(d->jscValue)->inherits(&QScript::QMetaObjectWrapperObject::info);
+ return QScriptEnginePrivate::isQMetaObject(d->jscValue);
}
/*!
@@ -2299,7 +1950,7 @@ QScriptValue QScriptValue::data() const
return d->engine->scriptValueFromJSCValue(scriptObject->data());
} else {
// ### make hidden property
- return d->property(QLatin1String("__qt_data__"), QScriptValue::ResolveLocal);
+ return property(QLatin1String("__qt_data__"), QScriptValue::ResolveLocal);
}
}
diff --git a/src/script/api/qscriptvalue_p.h b/src/script/api/qscriptvalue_p.h
index 7440d21..77b7330 100644
--- a/src/script/api/qscriptvalue_p.h
+++ b/src/script/api/qscriptvalue_p.h
@@ -69,9 +69,6 @@ public:
inline bool isJSC() const;
inline bool isObject() const;
- QVariant &variantValue() const;
- void setVariantValue(const QVariant &value);
-
static inline QScriptValuePrivate *get(const QScriptValue &q)
{
return q.d_ptr.data();
@@ -89,14 +86,16 @@ public:
return q.d_ptr->engine;
}
- inline QScriptValue property(const JSC::Identifier &id, int resolveMode) const;
- QScriptValue propertyHelper(const JSC::Identifier &id, int resolveMode) const;
- inline QScriptValue property(quint32 index, int resolveMode) const;
- QScriptValue propertyHelper(quint32, int resolveMode) const;
- inline QScriptValue property(const QString &, int resolveMode) const;
- void setProperty(const JSC::Identifier &id, const QScriptValue &value,
- const QScriptValue::PropertyFlags &flags);
- QScriptValue::PropertyFlags propertyFlags(
+ inline JSC::JSValue property(const JSC::Identifier &id, int resolveMode) const;
+ inline JSC::JSValue property(quint32 index, int resolveMode) const;
+ inline JSC::JSValue property(const QString &, int resolveMode) const;
+ inline void setProperty(const QString &name, const JSC::JSValue &value,
+ const QScriptValue::PropertyFlags &flags);
+ inline void setProperty(const JSC::Identifier &id, const JSC::JSValue &value,
+ const QScriptValue::PropertyFlags &flags);
+ inline void setProperty(quint32 index, const JSC::JSValue &value,
+ const QScriptValue::PropertyFlags &flags);
+ inline QScriptValue::PropertyFlags propertyFlags(
const JSC::Identifier &id, const QScriptValue::ResolveFlags &mode) const;
void detachFromEngine();
@@ -109,9 +108,6 @@ public:
return -1;
}
- static inline void saveException(JSC::ExecState*, JSC::JSValue*);
- static inline void restoreException(JSC::ExecState*, JSC::JSValue);
-
QScriptEnginePrivate *engine;
Type type;
JSC::JSValue jscValue;
diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp
index a3dd239..ce0a08e 100644
--- a/src/script/bridge/qscriptclassobject.cpp
+++ b/src/script/bridge/qscriptclassobject.cpp
@@ -206,7 +206,7 @@ JSC::JSValue JSC_HOST_CALL ClassObjectDelegate::call(JSC::ExecState *exec, JSC::
QVariant result = scriptClass->extension(QScriptClass::Callable, qVariantFromValue(ctx));
eng_p->popContext();
eng_p->currentFrame = oldFrame;
- return eng_p->jscValueFromVariant(result);
+ return QScriptEnginePrivate::jscValueFromVariant(exec, result);
}
JSC::ConstructType ClassObjectDelegate::getConstructData(QScriptObject*, JSC::ConstructData &constructData)
diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp
index ce2fc23..1d11ede 100644
--- a/src/script/bridge/qscriptdeclarativeclass.cpp
+++ b/src/script/bridge/qscriptdeclarativeclass.cpp
@@ -207,25 +207,17 @@ QScriptDeclarativeClass::newObjectValue(QScriptEngine *engine,
QScriptDeclarativeClass *QScriptDeclarativeClass::scriptClass(const QScriptValue &v)
{
QScriptValuePrivate *d = QScriptValuePrivate::get(v);
- if (!d || !d->isJSC() || !d->jscValue.inherits(&QScriptObject::info))
+ if (!d || !d->isJSC())
return 0;
- QScriptObject *scriptObject = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
- QScriptObjectDelegate *delegate = scriptObject->delegate();
- if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
- return 0;
- return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass();
+ return QScriptEnginePrivate::declarativeClass(d->jscValue);
}
QScriptDeclarativeClass::Object *QScriptDeclarativeClass::object(const QScriptValue &v)
{
QScriptValuePrivate *d = QScriptValuePrivate::get(v);
- if (!d || !d->isJSC() || !d->jscValue.inherits(&QScriptObject::info))
- return 0;
- QScriptObject *scriptObject = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
- QScriptObjectDelegate *delegate = scriptObject->delegate();
- if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
+ if (!d || !d->isJSC())
return 0;
- return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->object();
+ return QScriptEnginePrivate::declarativeObject(d->jscValue);
}
QScriptValue QScriptDeclarativeClass::function(const QScriptValue &v, const Identifier &name)
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp
index db312bc..30e5a26 100644
--- a/src/script/bridge/qscriptqobject.cpp
+++ b/src/script/bridge/qscriptqobject.cpp
@@ -169,17 +169,15 @@ static inline QByteArray methodName(const QMetaMethod &method)
return signature.left(signature.indexOf('('));
}
-static QVariant variantFromValue(QScriptEnginePrivate *eng,
- int targetType, const QScriptValue &value)
+static QVariant variantFromValue(JSC::ExecState *exec, int targetType, JSC::JSValue value)
{
QVariant v(targetType, (void *)0);
- Q_ASSERT(eng);
- if (QScriptEnginePrivate::convert(value, targetType, v.data(), eng))
+ if (QScriptEnginePrivate::convertValue(exec, value, targetType, v.data()))
return v;
if (uint(targetType) == QVariant::LastType)
- return value.toVariant();
- if (value.isVariant()) {
- v = value.toVariant();
+ return QScriptEnginePrivate::toVariant(exec, value);
+ if (QScriptEnginePrivate::isVariant(value)) {
+ v = QScriptEnginePrivate::variantValue(value);
if (v.canConvert(QVariant::Type(targetType))) {
v.convert(QVariant::Type(targetType));
return v;
@@ -591,38 +589,38 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
bool converted = true;
int matchDistance = 0;
for (int i = 0; converted && i < mtd.argumentCount(); ++i) {
- QScriptValue actual;
+ JSC::JSValue actual;
if (i < (int)scriptArgs.size())
- actual = engine->scriptValueFromJSCValue(scriptArgs.at(i));
+ actual = scriptArgs.at(i);
else
- actual = QScriptValue(QScriptValue::UndefinedValue);
+ actual = JSC::jsUndefined();
QScriptMetaType argType = mtd.argumentType(i);
int tid = -1;
QVariant v;
if (argType.isUnresolved()) {
v = QVariant(QMetaType::QObjectStar, (void *)0);
- converted = engine->convertToNativeQObject(
- actual, argType.name(), reinterpret_cast<void* *>(v.data()));
+ converted = QScriptEnginePrivate::convertToNativeQObject(
+ exec, actual, argType.name(), reinterpret_cast<void* *>(v.data()));
} else if (argType.isVariant()) {
- if (actual.isVariant()) {
- v = actual.toVariant();
+ if (QScriptEnginePrivate::isVariant(actual)) {
+ v = QScriptEnginePrivate::variantValue(actual);
} else {
- v = actual.toVariant();
+ v = QScriptEnginePrivate::toVariant(exec, actual);
converted = v.isValid() || actual.isUndefined() || actual.isNull();
}
} else {
tid = argType.typeId();
v = QVariant(tid, (void *)0);
- converted = QScriptEnginePrivate::convert(actual, tid, v.data(), engine);
+ converted = QScriptEnginePrivate::convertValue(exec, actual, tid, v.data());
if (exec->hadException())
return exec->exception();
}
if (!converted) {
- if (actual.isVariant()) {
+ if (QScriptEnginePrivate::isVariant(actual)) {
if (tid == -1)
tid = argType.typeId();
- QVariant vv = actual.toVariant();
+ QVariant vv = QScriptEnginePrivate::variantValue(actual);
if (vv.canConvert(QVariant::Type(tid))) {
v = vv;
converted = v.convert(QVariant::Type(tid));
@@ -649,14 +647,14 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
}
if (m.isValid()) {
if (actual.isNumber()) {
- int ival = actual.toInt32();
+ int ival = QScriptEnginePrivate::toInt32(exec, actual);
if (m.valueToKey(ival) != 0) {
qVariantSetValue(v, ival);
converted = true;
matchDistance += 10;
}
} else {
- QString sval = actual.toString();
+ QString sval = QScriptEnginePrivate::toString(exec, actual);
int ival = m.keyToValue(sval.toLatin1());
if (ival != -1) {
qVariantSetValue(v, ival);
@@ -718,7 +716,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
matchDistance += 10;
break;
}
- } else if (actual.isDate()) {
+ } else if (QScriptEnginePrivate::isDate(actual)) {
switch (tid) {
case QMetaType::QDateTime:
// perfect
@@ -733,7 +731,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
matchDistance += 10;
break;
}
- } else if (actual.isRegExp()) {
+ } else if (QScriptEnginePrivate::isRegExp(actual)) {
switch (tid) {
case QMetaType::QRegExp:
// perfect
@@ -742,14 +740,14 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
matchDistance += 10;
break;
}
- } else if (actual.isVariant()) {
+ } else if (QScriptEnginePrivate::isVariant(actual)) {
if (argType.isVariant()
- || (actual.toVariant().userType() == tid)) {
+ || (QScriptEnginePrivate::toVariant(exec, actual).userType() == tid)) {
// perfect
} else {
matchDistance += 10;
}
- } else if (actual.isArray()) {
+ } else if (QScriptEnginePrivate::isArray(actual)) {
switch (tid) {
case QMetaType::QStringList:
case QMetaType::QVariantList:
@@ -759,7 +757,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
matchDistance += 10;
break;
}
- } else if (actual.isQObject()) {
+ } else if (QScriptEnginePrivate::isQObject(actual)) {
switch (tid) {
case QMetaType::QObjectStar:
case QMetaType::QWidgetStar:
@@ -953,13 +951,11 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
} else {
QScriptMetaType retType = chosenMethod.returnType();
if (retType.isVariant()) {
- result = engine->jscValueFromVariant(*(QVariant *)params[0]);
+ result = QScriptEnginePrivate::jscValueFromVariant(exec, *(QVariant *)params[0]);
} else if (retType.typeId() != 0) {
- result = engine->scriptValueToJSCValue(engine->create(retType.typeId(), params[0]));
- if (!result) {
- QScriptValue sv = QScriptEnginePrivate::get(engine)->newVariant(QVariant(retType.typeId(), params[0]));
- result = engine->scriptValueToJSCValue(sv);
- }
+ result = QScriptEnginePrivate::create(exec, retType.typeId(), params[0]);
+ if (!result)
+ result = engine->newVariant(QVariant(retType.typeId(), params[0]));
} else {
result = JSC::jsUndefined();
}
@@ -1065,15 +1061,13 @@ JSC::JSValue QtPropertyFunction::execute(JSC::ExecState *exec,
{
JSC::JSValue result = JSC::jsUndefined();
- // ### don't go via QScriptValue
QScriptEnginePrivate *engine = scriptEngineFromExec(exec);
thisValue = engine->toUsableValue(thisValue);
- QScriptValue object = engine->scriptValueFromJSCValue(thisValue);
- QObject *qobject = object.toQObject();
+ QObject *qobject = QScriptEnginePrivate::toQObject(exec, thisValue);
while ((!qobject || (qobject->metaObject() != data->meta))
- && object.prototype().isObject()) {
- object = object.prototype();
- qobject = object.toQObject();
+ && JSC::asObject(thisValue)->prototype().isObject()) {
+ thisValue = JSC::asObject(thisValue)->prototype();
+ qobject = QScriptEnginePrivate::toQObject(exec, thisValue);
}
Q_ASSERT_X(qobject, Q_FUNC_INFO, "this-object must be a QObject");
@@ -1094,7 +1088,7 @@ JSC::JSValue QtPropertyFunction::execute(JSC::ExecState *exec,
if (scriptable)
QScriptablePrivate::get(scriptable)->engine = oldEngine;
- result = engine->jscValueFromVariant(v);
+ result = QScriptEnginePrivate::jscValueFromVariant(exec, v);
}
} else {
// set
@@ -1106,9 +1100,7 @@ JSC::JSValue QtPropertyFunction::execute(JSC::ExecState *exec,
// string to enum value
v = (QString)arg.toString(exec);
} else {
- // ### don't go via QScriptValue
- QScriptValue tmp = engine->scriptValueFromJSCValue(arg);
- v = variantFromValue(engine, prop.userType(), tmp);
+ v = variantFromValue(exec, prop.userType(), arg);
}
QScriptable *scriptable = scriptableFromQObject(qobject);
@@ -1237,7 +1229,7 @@ bool QObjectDelegate::getOwnPropertySlot(QScriptObject *object, JSC::ExecState *
if (!prop.isValid())
val = JSC::jsUndefined();
else
- val = eng->jscValueFromVariant(prop.read(qobject));
+ val = QScriptEnginePrivate::jscValueFromVariant(exec, prop.read(qobject));
slot.setValue(val);
}
return true;
@@ -1247,7 +1239,7 @@ bool QObjectDelegate::getOwnPropertySlot(QScriptObject *object, JSC::ExecState *
index = qobject->dynamicPropertyNames().indexOf(name);
if (index != -1) {
- JSC::JSValue val = eng->jscValueFromVariant(qobject->property(name));
+ JSC::JSValue val = QScriptEnginePrivate::jscValueFromVariant(exec, qobject->property(name));
slot.setValue(val);
return true;
}
@@ -1274,8 +1266,7 @@ bool QObjectDelegate::getOwnPropertySlot(QScriptObject *object, JSC::ExecState *
QObject *child = children.at(index);
if (child->objectName() == QString(propertyName.ustring())) {
QScriptEngine::QObjectWrapOptions opt = QScriptEngine::PreferExistingWrapperObject;
- QScriptValue tmp = QScriptEnginePrivate::get(eng)->newQObject(child, QScriptEngine::QtOwnership, opt);
- slot.setValue(eng->scriptValueToJSCValue(tmp));
+ slot.setValue(eng->newQObject(child, QScriptEngine::QtOwnership, opt));
return true;
}
}
@@ -1370,7 +1361,7 @@ bool QObjectDelegate::getOwnPropertyDescriptor(QScriptObject *object, JSC::ExecS
if (!prop.isValid())
val = JSC::jsUndefined();
else
- val = eng->jscValueFromVariant(prop.read(qobject));
+ val = QScriptEnginePrivate::jscValueFromVariant(exec, prop.read(qobject));
descriptor.setDescriptor(val, attributes);
}
return true;
@@ -1380,7 +1371,7 @@ bool QObjectDelegate::getOwnPropertyDescriptor(QScriptObject *object, JSC::ExecS
index = qobject->dynamicPropertyNames().indexOf(name);
if (index != -1) {
- JSC::JSValue val = eng->jscValueFromVariant(qobject->property(name));
+ JSC::JSValue val = QScriptEnginePrivate::jscValueFromVariant(exec, qobject->property(name));
descriptor.setDescriptor(val, QObjectMemberAttribute);
return true;
}
@@ -1410,8 +1401,8 @@ bool QObjectDelegate::getOwnPropertyDescriptor(QScriptObject *object, JSC::ExecS
QObject *child = children.at(index);
if (child->objectName() == QString(propertyName.ustring())) {
QScriptEngine::QObjectWrapOptions opt = QScriptEngine::PreferExistingWrapperObject;
- QScriptValue tmp = QScriptEnginePrivate::get(eng)->newQObject(child, QScriptEngine::QtOwnership, opt);
- descriptor.setDescriptor(eng->scriptValueToJSCValue(tmp), JSC::ReadOnly | JSC::DontDelete | JSC::DontEnum);
+ descriptor.setDescriptor(eng->newQObject(child, QScriptEngine::QtOwnership, opt),
+ JSC::ReadOnly | JSC::DontDelete | JSC::DontEnum);
return true;
}
}
@@ -1490,7 +1481,7 @@ void QObjectDelegate::put(QScriptObject *object, JSC::ExecState* exec,
// string to enum value
v = (QString)value.toString(exec);
} else {
- v = eng->jscValueToVariant(value, prop.userType());
+ v = QScriptEnginePrivate::jscValueToVariant(exec, value, prop.userType());
}
(void)prop.write(qobject, v);
}
@@ -1512,7 +1503,7 @@ void QObjectDelegate::put(QScriptObject *object, JSC::ExecState* exec,
index = qobject->dynamicPropertyNames().indexOf(name);
if ((index != -1) || (opt & QScriptEngine::AutoCreateDynamicProperties)) {
- QVariant v = eng->scriptValueFromJSCValue(value).toVariant();
+ QVariant v = QScriptEnginePrivate::toVariant(exec, value);
(void)qobject->setProperty(name, v);
return;
}
@@ -2178,24 +2169,23 @@ void QObjectConnectionManager::execute(int slotIndex, void **argv)
JSC::ExecState *exec = engine->currentFrame;
QVarLengthArray<JSC::JSValue, 8> argsVector(argc);
for (int i = 0; i < argc; ++i) {
- // ### optimize -- no need to convert via QScriptValue
- QScriptValue actual;
+ JSC::JSValue actual;
void *arg = argv[i + 1];
QByteArray typeName = parameterTypes.at(i);
int argType = QMetaType::type(parameterTypes.at(i));
if (!argType) {
if (typeName == "QVariant") {
- actual = engine->scriptValueFromVariant(*reinterpret_cast<QVariant*>(arg));
+ actual = QScriptEnginePrivate::jscValueFromVariant(exec, *reinterpret_cast<QVariant*>(arg));
} else {
qWarning("QScriptEngine: Unable to handle unregistered datatype '%s' "
"when invoking handler of signal %s::%s",
typeName.constData(), meta->className(), method.signature());
- actual = QScriptValue(QScriptValue::UndefinedValue);
+ actual = JSC::jsUndefined();
}
} else {
- actual = engine->create(argType, arg);
+ actual = QScriptEnginePrivate::create(exec, argType, arg);
}
- argsVector[i] = engine->scriptValueToJSCValue(actual);
+ argsVector[i] = actual;
}
JSC::ArgList jscArgs(argsVector.data(), argsVector.size());
diff --git a/src/script/bridge/qscriptvariant.cpp b/src/script/bridge/qscriptvariant.cpp
index 0287d24..b4f0365 100644
--- a/src/script/bridge/qscriptvariant.cpp
+++ b/src/script/bridge/qscriptvariant.cpp
@@ -133,7 +133,7 @@ static JSC::JSValue JSC_HOST_CALL variantProtoFuncToString(JSC::ExecState *exec,
bool QVariantDelegate::compareToObject(QScriptObject *, JSC::ExecState *exec, JSC::JSObject *o2)
{
const QVariant &variant1 = value();
- return variant1 == scriptEngineFromExec(exec)->scriptValueFromJSCValue(o2).toVariant();
+ return variant1 == QScriptEnginePrivate::toVariant(exec, o2);
}
QVariantPrototype::QVariantPrototype(JSC::ExecState* exec, WTF::PassRefPtr<JSC::Structure> structure,
diff --git a/src/testlib/qbenchmark.h b/src/testlib/qbenchmark.h
index 38a0e52..46f51ca 100644
--- a/src/testlib/qbenchmark.h
+++ b/src/testlib/qbenchmark.h
@@ -43,7 +43,7 @@
#define QBENCHMARK_H
#include <QtTest/qtest_global.h>
-#include <QtTest/private/qbenchmarkmetric_p.h>
+#include <QtTest/qbenchmarkmetric.h>
QT_BEGIN_HEADER
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index ca10b01..5c9dd55 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1551,7 +1551,11 @@ FatalSignalHandler::FatalSignalHandler()
#ifndef Q_WS_QWS
// Don't overwrite any non-default handlers
// however, we need to replace the default QWS handlers
- if (oldact.sa_flags & SA_SIGINFO || oldact.sa_handler != SIG_DFL) {
+ if (
+#ifdef SA_SIGINFO
+ oldact.sa_flags & SA_SIGINFO ||
+#endif
+ oldact.sa_handler != SIG_DFL) {
sigaction(fatalSignals[i], &oldact, 0);
} else
#endif
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 3034f30..5fd2dca 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -11,7 +11,6 @@ TEMPLATE = subdirs
maketestselftest \
moc \
uic \
- uic3 \
guiapplauncher \
#atwrapper \ # These tests need significant updating,
#uiloader \ # they have hardcoded machine names etc.
@@ -69,6 +68,9 @@ Q3SUBDIRS += \
q3uridrag \
q3widgetstack
+!cross_compile:Q3SUBDIRS += \
+ uic3
+
SUBDIRS += \
# exceptionsafety_objects \ shouldn't enable it
languagechange \
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index b4a0d0f..9dc7230 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -29,7 +29,7 @@ SUBDIRS += \
qmlgraphicsitem \ # Cover
qmlgraphicslistview \ # Cover
qmlgraphicsloader \ # Cover
- qmlgraphicsmouseregion \ # Cover
+ qmlgraphicsmousearea \ # Cover
qmlgraphicsparticles \ # Cover
qmlgraphicspathview \ # Cover
qmlgraphicspositioners \ # Cover
@@ -40,7 +40,6 @@ SUBDIRS += \
qmlinstruction \ # Cover
qmllanguage \ # Cover
qmllist \ # Cover
- qmllistaccessor \ # Cover
qmllistmodel \ # Cover
qmlmetaproperty \ # Cover
qmlmetatype \ # Cover
diff --git a/tests/auto/declarative/qmlanimations/data/badtype4.qml b/tests/auto/declarative/qmlanimations/data/badtype4.qml
index 2ffed37..e80762f 100644
--- a/tests/auto/declarative/qmlanimations/data/badtype4.qml
+++ b/tests/auto/declarative/qmlanimations/data/badtype4.qml
@@ -10,7 +10,7 @@ Rectangle {
color: "red"
width: 50; height: 50
x: 100; y: 100
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1";
}
diff --git a/tests/auto/declarative/qmlanimations/data/dotproperty.qml b/tests/auto/declarative/qmlanimations/data/dotproperty.qml
index 08bb5d8..9f0e699 100644
--- a/tests/auto/declarative/qmlanimations/data/dotproperty.qml
+++ b/tests/auto/declarative/qmlanimations/data/dotproperty.qml
@@ -9,7 +9,7 @@ Rectangle {
color: "red"
width: 50; height: 50
x: 100; y: 100
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1";
}
diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml b/tests/auto/declarative/qmlanimations/data/mixedtype1.qml
index b46270c..6770366 100644
--- a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml
+++ b/tests/auto/declarative/qmlanimations/data/mixedtype1.qml
@@ -10,7 +10,7 @@ Rectangle {
color: "red"
width: 50; height: 50
x: 100; y: 100
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1";
}
diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml b/tests/auto/declarative/qmlanimations/data/mixedtype2.qml
index 15537f1..80c9473 100644
--- a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml
+++ b/tests/auto/declarative/qmlanimations/data/mixedtype2.qml
@@ -10,7 +10,7 @@ Rectangle {
color: "red"
width: 50; height: 50
x: 100; y: 100
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1";
}
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml
index 2f7fd4a..b13b94b 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml
+++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml
@@ -22,7 +22,7 @@ Rectangle {
NumberAnimation { targets: theRect; properties: "x" }
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: parent.state = "moved"
}
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml
index ae59157..033c5c1 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml
+++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml
@@ -22,7 +22,7 @@ Rectangle {
NumberAnimation { target: theRect; property: "y"; to: 200 }
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: parent.state = "moved"
}
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml
index 5aaaab8..d0704c9 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml
+++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml
@@ -22,7 +22,7 @@ Rectangle {
NumberAnimation { targets: theRect; properties: "y" }
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: parent.state = "moved"
}
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml
index b7ebb1b..e70c95c 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml
+++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml
@@ -22,7 +22,7 @@ Rectangle {
NumberAnimation { target: theRect; properties: "x" }
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: parent.state = "moved"
}
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml
index 9034fc5..b9e27da 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml
+++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml
@@ -22,7 +22,7 @@ Rectangle {
NumberAnimation { targets: theRect; property: "x" }
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: parent.state = "moved"
}
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml
index 3d8be51..7417ed1 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml
+++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml
@@ -22,7 +22,7 @@ Rectangle {
NumberAnimation { targets: theItem; properties: "x" }
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: parent.state = "moved"
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/binding.qml b/tests/auto/declarative/qmlbehaviors/data/binding.qml
index e0c3321..201da37 100644
--- a/tests/auto/declarative/qmlbehaviors/data/binding.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/binding.qml
@@ -9,9 +9,9 @@ Rectangle {
objectName: "MyRect"
width: 100; height: 100; color: "green"
x: basex
- x: Behavior { NumberAnimation { duration: 200; } }
+ x: Behavior { NumberAnimation { duration: 500; } }
}
- MouseRegion {
+ MouseArea {
id: clicker
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/color.qml b/tests/auto/declarative/qmlbehaviors/data/color.qml
index 6598703..91dbbd1 100644
--- a/tests/auto/declarative/qmlbehaviors/data/color.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/color.qml
@@ -7,9 +7,9 @@ Rectangle {
objectName: "MyRect"
width: 100; height: 100;
color: "green"
- color: Behavior { ColorAnimation { duration: 200; } }
+ color: Behavior { ColorAnimation { duration: 500; } }
}
- MouseRegion {
+ MouseArea {
id: clicker
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml b/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml
index ba507c4..8d032f0 100644
--- a/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml
@@ -6,6 +6,6 @@ Rectangle {
id: rect
objectName: "MyRect"
width: 100; height: 100; color: "green"
- x: Behavior { NumberAnimation { duration: 200; } }
+ x: Behavior { NumberAnimation { duration: 500; } }
}
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/disabled.qml b/tests/auto/declarative/qmlbehaviors/data/disabled.qml
index e7b8d51..3c7078a 100644
--- a/tests/auto/declarative/qmlbehaviors/data/disabled.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/disabled.qml
@@ -12,7 +12,7 @@ Rectangle {
NumberAnimation { duration: 200; }
}
}
- MouseRegion {
+ MouseArea {
id: clicker
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/empty.qml b/tests/auto/declarative/qmlbehaviors/data/empty.qml
index 412e26c..95d934a 100644
--- a/tests/auto/declarative/qmlbehaviors/data/empty.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/empty.qml
@@ -8,7 +8,7 @@ Rectangle {
width: 100; height: 100; color: "green"
x: Behavior {}
}
- MouseRegion {
+ MouseArea {
id: clicker
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/explicit.qml b/tests/auto/declarative/qmlbehaviors/data/explicit.qml
index ba36d93..1b2025a 100644
--- a/tests/auto/declarative/qmlbehaviors/data/explicit.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/explicit.qml
@@ -8,10 +8,10 @@ Rectangle {
width: 100; height: 100; color: "green"
x: Behavior {
objectName: "MyBehavior";
- NumberAnimation { target: rect; property: "x"; duration: 200; }
+ NumberAnimation { target: rect; property: "x"; duration: 500; }
}
}
- MouseRegion {
+ MouseArea {
id: clicker
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml b/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml
index 4f127c1..14883d4 100644
--- a/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml
@@ -6,9 +6,9 @@ Rectangle {
id: rect
objectName: "MyRect"
width: 100; height: 100; color: "green"
- pos: Behavior { PropertyAnimation { duration: 200; } }
+ pos: Behavior { PropertyAnimation { duration: 500; } }
}
- MouseRegion {
+ MouseArea {
id: clicker
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml b/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml
index 19d70b6..b43ddbc 100644
--- a/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml
@@ -6,9 +6,9 @@ Rectangle {
id: rect
objectName: "MyRect"
width: 100; height: 100; color: "green"
- pos.x: Behavior { NumberAnimation { duration: 200; } }
+ pos.x: Behavior { NumberAnimation { duration: 500; } }
}
- MouseRegion {
+ MouseArea {
id: clicker
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml b/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml
index 59cbd1a..f267a05 100644
--- a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml
@@ -11,7 +11,7 @@ Rectangle {
NumberAnimation { targets: rect; properties: "y"; duration: 200; }
}
}
- MouseRegion {
+ MouseArea {
id: clicker
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/parent.qml b/tests/auto/declarative/qmlbehaviors/data/parent.qml
index 4f4911b..7c7fdcb 100644
--- a/tests/auto/declarative/qmlbehaviors/data/parent.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/parent.qml
@@ -8,7 +8,7 @@ Rectangle {
width: 100; height: 100; color: "green"
parent: Behavior {
SequentialAnimation {
- PauseAnimation { duration: 200 }
+ PauseAnimation { duration: 500 }
PropertyAction {}
}
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml b/tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml
index 693a595..ba744b1 100644
--- a/tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml
@@ -12,7 +12,7 @@ Rectangle {
NumberAnimation { duration: 1000 }
}
}
- MouseRegion {
+ MouseArea {
id: clicker
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml b/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml
index 4383a0b..a91ca88 100644
--- a/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml
@@ -11,6 +11,6 @@ Rectangle {
id: rect
objectName: "MyRect"
width: 100; height: 100; color: "green"
- x: Behavior { NumberAnimation { duration: 200; } }
+ x: Behavior { NumberAnimation { duration: 500; } }
}
}
diff --git a/tests/auto/declarative/qmlbehaviors/data/simple.qml b/tests/auto/declarative/qmlbehaviors/data/simple.qml
index 37c3915..ac98ed0 100644
--- a/tests/auto/declarative/qmlbehaviors/data/simple.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/simple.qml
@@ -8,10 +8,10 @@ Rectangle {
width: 100; height: 100; color: "green"
x: Behavior {
objectName: "MyBehavior";
- NumberAnimation { duration: 200; }
+ NumberAnimation { duration: 500; }
}
}
- MouseRegion {
+ MouseArea {
id: clicker
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp
index 99ec728..e31b600 100644
--- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp
+++ b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp
@@ -79,7 +79,7 @@ void tst_qmlbehaviors::simpleBehavior()
QVERIFY(qobject_cast<QmlBehavior*>(rect->findChild<QmlBehavior*>("MyBehavior"))->animation());
rect->setState("moved");
- QTest::qWait(100);
+ QTest::qWait(200);
qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
}
@@ -92,7 +92,7 @@ void tst_qmlbehaviors::scriptTriggered()
QVERIFY(rect);
rect->setColor(QColor("red"));
- QTest::qWait(100);
+ QTest::qWait(200);
qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
}
@@ -108,7 +108,7 @@ void tst_qmlbehaviors::cppTriggered()
QVERIFY(innerRect);
innerRect->setProperty("x", 200);
- QTest::qWait(100);
+ QTest::qWait(200);
qreal x = innerRect->x();
QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
}
@@ -132,7 +132,7 @@ void tst_qmlbehaviors::colorBehavior()
QVERIFY(rect);
rect->setState("red");
- QTest::qWait(100);
+ QTest::qWait(200);
QColor color = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->color();
QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered
}
@@ -145,11 +145,11 @@ void tst_qmlbehaviors::parentBehavior()
QVERIFY(rect);
rect->setState("reparented");
- QTest::qWait(100);
+ QTest::qWait(200);
QmlGraphicsItem *newParent = rect->findChild<QmlGraphicsItem*>("NewParent");
QmlGraphicsItem *parent = rect->findChild<QmlGraphicsRectangle*>("MyRect")->parentItem();
QVERIFY(parent != newParent);
- QTest::qWait(300);
+ QTest::qWait(600);
parent = rect->findChild<QmlGraphicsRectangle*>("MyRect")->parentItem();
QVERIFY(parent == newParent);
}
@@ -162,29 +162,29 @@ void tst_qmlbehaviors::replaceBinding()
QVERIFY(rect);
rect->setState("moved");
- QTest::qWait(100);
+ QTest::qWait(200);
QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
QVERIFY(innerRect);
qreal x = innerRect->x();
QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
- QTest::qWait(300);
+ QTest::qWait(600);
QCOMPARE(innerRect->x(), (qreal)200);
rect->setProperty("basex", 10);
QCOMPARE(innerRect->x(), (qreal)200);
rect->setProperty("movedx", 210);
- QTest::qWait(300);
+ QTest::qWait(600);
QCOMPARE(innerRect->x(), (qreal)210);
rect->setState("");
- QTest::qWait(100);
+ QTest::qWait(200);
x = innerRect->x();
QVERIFY(x > 10 && x < 210); //i.e. the behavior has been triggered
- QTest::qWait(300);
+ QTest::qWait(600);
QCOMPARE(innerRect->x(), (qreal)10);
rect->setProperty("movedx", 200);
QCOMPARE(innerRect->x(), (qreal)10);
rect->setProperty("basex", 20);
- QTest::qWait(300);
+ QTest::qWait(600);
QCOMPARE(innerRect->x(), (qreal)20);
}
@@ -197,7 +197,7 @@ void tst_qmlbehaviors::group()
QVERIFY(rect);
rect->setState("moved");
- QTest::qWait(100);
+ QTest::qWait(200);
qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
}
@@ -209,7 +209,7 @@ void tst_qmlbehaviors::group()
QVERIFY(rect);
rect->setState("moved");
- QTest::qWait(100);
+ QTest::qWait(200);
qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
}
@@ -236,7 +236,7 @@ void tst_qmlbehaviors::explicitSelection()
QVERIFY(rect);
rect->setState("moved");
- QTest::qWait(100);
+ QTest::qWait(200);
qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
}
diff --git a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
index 2e668ad..ba07331 100644
--- a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
+++ b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
@@ -825,7 +825,7 @@ int main(int argc, char *argv[])
"width: 10; height: 20; scale: blueRect.scale;"
"Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }"
"Text { color: blueRect.color; }"
- "MouseRegion {"
+ "MouseArea {"
"onEntered: { console.log('hello') }"
"}"
"}";
diff --git a/tests/auto/declarative/qmlecmascript/data/listProperties.qml b/tests/auto/declarative/qmlecmascript/data/listProperties.qml
index cae1721..810f9b6 100644
--- a/tests/auto/declarative/qmlecmascript/data/listProperties.qml
+++ b/tests/auto/declarative/qmlecmascript/data/listProperties.qml
@@ -9,12 +9,6 @@ MyQmlObject {
QtObject { property int a: 11 }
]
- objectQmlListProperty: [
- QtObject { property int a: 10 },
- QtObject { property int a: 1 },
- QtObject { property int a: 39 }
- ]
-
Script {
function calcTest1() {
var rv = 0;
@@ -24,21 +18,10 @@ MyQmlObject {
return rv;
}
- function calcTest2() {
- var rv = 0;
- for (var ii = 0; ii < root.objectQmlListProperty.length; ++ii) {
- rv += root.objectQmlListProperty[ii].a;
- }
- return rv;
- }
}
property int test1: calcTest1();
property int test2: root.objectListProperty.length
- property int test3: calcTest2();
- property int test4: root.objectQmlListProperty.length
- property bool test5: root.objectQmlListProperty[1] != undefined
- property bool test6: root.objectQmlListProperty[100] == undefined
- property bool test7: root.objectListProperty[1] != undefined
- property bool test8: root.objectListProperty[100] == undefined
+ property bool test3: root.objectListProperty[1] != undefined
+ property bool test4: root.objectListProperty[100] == undefined
}
diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h
index 330664f..0af72cb 100644
--- a/tests/auto/declarative/qmlecmascript/testtypes.h
+++ b/tests/auto/declarative/qmlecmascript/testtypes.h
@@ -77,8 +77,7 @@ class MyQmlObject : public QObject
Q_PROPERTY(int value READ value WRITE setValue)
Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
- Q_PROPERTY(QmlList<QObject *> *objectQmlListProperty READ objectQmlListProperty CONSTANT)
- Q_PROPERTY(QList<QObject *> *objectListProperty READ objectListProperty CONSTANT)
+ Q_PROPERTY(QmlListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
public:
@@ -107,8 +106,7 @@ public:
emit objectChanged();
}
- QmlList<QObject *> *objectQmlListProperty() { return &m_objectQmlList; }
- QList<QObject *> *objectListProperty() { return &m_objectQList; }
+ QmlListProperty<QObject> objectListProperty() { return QmlListProperty<QObject>(this, m_objectQList); }
bool methodCalled() const { return m_methodCalled; }
bool methodIntCalled() const { return m_methodIntCalled; }
@@ -150,7 +148,6 @@ private:
QObject *m_object;
QString m_string;
- QmlConcreteList<QObject *> m_objectQmlList;
QList<QObject *> m_objectQList;
int m_value;
int m_resetProperty;
@@ -162,11 +159,11 @@ QML_DECLARE_TYPE(MyQmlObject);
class MyQmlContainer : public QObject
{
Q_OBJECT
- Q_PROPERTY(QList<MyQmlObject*>* children READ children CONSTANT)
+ Q_PROPERTY(QmlListProperty<MyQmlObject> children READ children CONSTANT)
public:
MyQmlContainer() {}
- QList<MyQmlObject*> *children() { return &m_children; }
+ QmlListProperty<MyQmlObject> children() { return QmlListProperty<MyQmlObject>(this, m_children); }
private:
QList<MyQmlObject*> m_children;
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index 0ef836f..b30ad1c 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -365,7 +365,6 @@ void tst_qmlecmascript::basicExpressions()
QCOMPARE(expr.value(), result);
}
-Q_DECLARE_METATYPE(QList<QObject *>);
void tst_qmlecmascript::arrayExpressions()
{
QObject obj1;
@@ -985,12 +984,8 @@ void tst_qmlecmascript::listProperties()
QCOMPARE(object->property("test1").toInt(), 21);
QCOMPARE(object->property("test2").toInt(), 2);
- QCOMPARE(object->property("test3").toInt(), 50);
- QCOMPARE(object->property("test4").toInt(), 3);
- QCOMPARE(object->property("test5").toBool(), true);
- QCOMPARE(object->property("test6").toBool(), true);
- QCOMPARE(object->property("test7").toBool(), true);
- QCOMPARE(object->property("test8").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
}
void tst_qmlecmascript::exceptionClearsOnReeval()
@@ -1612,7 +1607,9 @@ void tst_qmlecmascript::listToVariant()
QObject *object = component.create(&context);
QVERIFY(object != 0);
- QCOMPARE(object->property("test"), QVariant::fromValue(container.children()));
+ QVariant v = object->property("test");
+ QCOMPARE(v.userType(), qMetaTypeId<QmlListReference>());
+ QVERIFY(qvariant_cast<QmlListReference>(v).object() == &container);
delete object;
}
diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
index 00127e5..2520d4a 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
+++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
@@ -645,45 +645,29 @@ void tst_QmlGraphicsGridView::currentIndex()
QCOMPARE(gridview->viewportY(), 0.0);
// Test keys
+ qApp->setActiveWindow(canvas);
canvas->show();
canvas->setFocus();
qApp->processEvents();
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Down);
QCOMPARE(gridview->currentIndex(), 3);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Up);
QCOMPARE(gridview->currentIndex(), 0);
gridview->setFlow(QmlGraphicsGridView::TopToBottom);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Right);
QCOMPARE(gridview->currentIndex(), 5);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Left);
QCOMPARE(gridview->currentIndex(), 0);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Down);
QCOMPARE(gridview->currentIndex(), 1);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Up);
QCOMPARE(gridview->currentIndex(), 0);
diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml b/tests/auto/declarative/qmlgraphicsmousearea/data/dragproperties.qml
index 5acb3e4..4cd78da 100644
--- a/tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml
+++ b/tests/auto/declarative/qmlgraphicsmousearea/data/dragproperties.qml
@@ -14,7 +14,7 @@ Rectangle {
height: 100
opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200
Text { text: blackRect.opacity}
- MouseRegion {
+ MouseArea {
objectName: "mouseregion"
anchors.fill: parent
drag.target: blackRect
@@ -25,4 +25,4 @@ Rectangle {
drag.maximumY: whiteRect.height-blackRect.height
}
}
- } \ No newline at end of file
+ }
diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro b/tests/auto/declarative/qmlgraphicsmousearea/qmlgraphicsmousearea.pro
index 7a7c8bd..f85bf0f 100644
--- a/tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro
+++ b/tests/auto/declarative/qmlgraphicsmousearea/qmlgraphicsmousearea.pro
@@ -3,7 +3,7 @@ contains(QT_CONFIG,declarative): QT += declarative gui network
macx:CONFIG -= app_bundle
HEADERS += ../shared/testhttpserver.h
-SOURCES += tst_qmlgraphicsmouseregion.cpp ../shared/testhttpserver.cpp
+SOURCES += tst_qmlgraphicsmousearea.cpp ../shared/testhttpserver.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp b/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp
index 82da9c8..869a7bd 100644
--- a/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp
+++ b/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp
@@ -41,10 +41,10 @@
#include <QtTest/QtTest>
#include <QtTest/QSignalSpy>
-#include <private/qmlgraphicsmouseregion_p.h>
+#include <private/qmlgraphicsmousearea_p.h>
#include <QtDeclarative/qmlview.h>
-class tst_QmlGraphicsMouseRegion: public QObject
+class tst_QmlGraphicsMouseArea: public QObject
{
Q_OBJECT
private slots:
@@ -53,7 +53,7 @@ private:
QmlView *createView(const QString &filename);
};
-void tst_QmlGraphicsMouseRegion::dragProperties()
+void tst_QmlGraphicsMouseArea::dragProperties()
{
QmlView *canvas = createView(SRCDIR "/data/dragproperties.qml");
canvas->execute();
@@ -61,7 +61,7 @@ void tst_QmlGraphicsMouseRegion::dragProperties()
canvas->setFocus();
QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsMouseRegion *mouseRegion = canvas->rootObject()->findChild<QmlGraphicsMouseRegion*>("mouseregion");
+ QmlGraphicsMouseArea *mouseRegion = canvas->rootObject()->findChild<QmlGraphicsMouseArea*>("mouseregion");
QmlGraphicsDrag *drag = mouseRegion->drag();
QVERIFY(mouseRegion != 0);
QVERIFY(drag != 0);
@@ -124,7 +124,7 @@ void tst_QmlGraphicsMouseRegion::dragProperties()
QCOMPARE(ymaxSpy.count(),1);
}
-QmlView *tst_QmlGraphicsMouseRegion::createView(const QString &filename)
+QmlView *tst_QmlGraphicsMouseArea::createView(const QString &filename)
{
QmlView *canvas = new QmlView(0);
canvas->setFixedSize(240,320);
@@ -134,6 +134,6 @@ QmlView *tst_QmlGraphicsMouseRegion::createView(const QString &filename)
return canvas;
}
-QTEST_MAIN(tst_QmlGraphicsMouseRegion)
+QTEST_MAIN(tst_QmlGraphicsMouseArea)
-#include "tst_qmlgraphicsmouseregion.moc"
+#include "tst_qmlgraphicsmousearea.moc"
diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
index 072f740..b986a64 100644
--- a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
+++ b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
@@ -268,31 +268,31 @@ void tst_QmlGraphicsPathView::path()
QCOMPARE(obj->startY(), 100.);
QVERIFY(obj->path() != QPainterPath());
- QList<QmlGraphicsPathElement*> *list = obj->pathElements();
- QCOMPARE(list->count(), 5);
+ QmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 5);
- QmlGraphicsPathAttribute* attr = qobject_cast<QmlGraphicsPathAttribute*>(list->at(0));
+ QmlGraphicsPathAttribute* attr = qobject_cast<QmlGraphicsPathAttribute*>(list.at(0));
QVERIFY(attr != 0);
QCOMPARE(attr->name(), QString("scale"));
QCOMPARE(attr->value(), 1.0);
- QmlGraphicsPathQuad* quad = qobject_cast<QmlGraphicsPathQuad*>(list->at(1));
+ QmlGraphicsPathQuad* quad = qobject_cast<QmlGraphicsPathQuad*>(list.at(1));
QVERIFY(quad != 0);
QCOMPARE(quad->x(), 120.);
QCOMPARE(quad->y(), 25.);
QCOMPARE(quad->controlX(), 260.);
QCOMPARE(quad->controlY(), 75.);
- QmlGraphicsPathPercent* perc = qobject_cast<QmlGraphicsPathPercent*>(list->at(2));
+ QmlGraphicsPathPercent* perc = qobject_cast<QmlGraphicsPathPercent*>(list.at(2));
QVERIFY(perc != 0);
QCOMPARE(perc->value(), 0.3);
- QmlGraphicsPathLine* line = qobject_cast<QmlGraphicsPathLine*>(list->at(3));
+ QmlGraphicsPathLine* line = qobject_cast<QmlGraphicsPathLine*>(list.at(3));
QVERIFY(line != 0);
QCOMPARE(line->x(), 120.);
QCOMPARE(line->y(), 100.);
- QmlGraphicsPathCubic* cubic = qobject_cast<QmlGraphicsPathCubic*>(list->at(4));
+ QmlGraphicsPathCubic* cubic = qobject_cast<QmlGraphicsPathCubic*>(list.at(4));
QVERIFY(cubic != 0);
QCOMPARE(cubic->x(), 180.);
QCOMPARE(cubic->y(), 0.);
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
index 9e3a028..c971840 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
+++ b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
@@ -188,14 +188,14 @@ void tst_QmlGraphicsRepeater::objectList()
{
QmlView *canvas = createView(SRCDIR "/data/objlist.qml");
- QObjectList* data = new QObjectList;
+ QObjectList data;
for(int i=0; i<100; i++){
- *data << new QObject();
- data->back()->setProperty("idx", i);
+ data << new QObject();
+ data.back()->setProperty("idx", i);
}
QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", QVariant::fromValue<QObjectList*>(data));
+ ctxt->setContextProperty("testData", QVariant::fromValue(data));
canvas->execute();
qApp->processEvents();
diff --git a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp
index 9c753ce..38d024a 100644
--- a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp
+++ b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp
@@ -421,13 +421,6 @@ void tst_qmlinstruction::dump()
{
QmlInstruction i;
- i.line = 37;
- i.type = QmlInstruction::StoreObjectQmlList;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
i.line = 38;
i.type = QmlInstruction::StoreObjectQList;
data->bytecode << i;
@@ -450,15 +443,6 @@ void tst_qmlinstruction::dump()
{
QmlInstruction i;
- i.line = 41;
- i.type = QmlInstruction::FetchQmlList;
- i.fetchQmlList.property = 31;
- i.fetchQmlList.type = 3;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
i.line = 42;
i.type = QmlInstruction::FetchQList;
i.fetch.property = 32;
@@ -569,20 +553,18 @@ void tst_qmlinstruction::dump()
<< "34\t\t34\tSTORE_VALUE_SOURCE\t29\t4"
<< "35\t\t35\tSTORE_VALUE_INTERCEPTOR\t30\t-4"
<< "36\t\t36\tBEGIN\t\t\t4"
- << "37\t\t37\tSTORE_OBJECT_QMLLIST"
- << "38\t\t38\tSTORE_OBJECT_QLIST"
- << "39\t\t39\tASSIGN_OBJECT_LIST"
- << "40\t\t40\tFETCH_ATTACHED\t\t23"
- << "41\t\t41\tFETCH_QMLLIST\t\t31\t3"
- << "42\t\t42\tFETCH_QLIST\t\t32"
- << "43\t\t43\tFETCH\t\t\t33"
- << "44\t\t44\tFETCH_VALUE\t\t34\t6"
- << "45\t\t45\tPOP"
- << "46\t\t46\tPOP_QLIST"
- << "47\t\t47\tPOP_VALUE\t\t35\t8"
- << "48\t\t48\tDEFER\t\t\t7"
- << "49\t\tNA\tDEFER\t\t\t7"
- << "50\t\t50\tXXX UNKOWN INSTRUCTION\t49"
+ << "37\t\t38\tSTORE_OBJECT_QLIST"
+ << "38\t\t39\tASSIGN_OBJECT_LIST"
+ << "39\t\t40\tFETCH_ATTACHED\t\t23"
+ << "40\t\t42\tFETCH_QLIST\t\t32"
+ << "41\t\t43\tFETCH\t\t\t33"
+ << "42\t\t44\tFETCH_VALUE\t\t34\t6"
+ << "43\t\t45\tPOP"
+ << "44\t\t46\tPOP_QLIST"
+ << "45\t\t47\tPOP_VALUE\t\t35\t8"
+ << "46\t\t48\tDEFER\t\t\t7"
+ << "47\t\tNA\tDEFER\t\t\t7"
+ << "48\t\t50\tXXX UNKOWN INSTRUCTION\t47"
<< "-------------------------------------------------------------------------------";
messages = QStringList();
diff --git a/tests/auto/declarative/qmllanguage/data/interfaceQmlList.qml b/tests/auto/declarative/qmllanguage/data/interfaceQmlList.qml
deleted file mode 100644
index 8392bea..0000000
--- a/tests/auto/declarative/qmllanguage/data/interfaceQmlList.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import Test 1.0
-MyContainer {
- qmllistInterfaces: [
- MyQmlObject {},
- MyQmlObject {}
- ]
-}
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.1.errors.txt b/tests/auto/declarative/qmllanguage/data/listAssignment.1.errors.txt
deleted file mode 100644
index d68d487..0000000
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.1.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-3:24:Cannot assign primitives to lists
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.1.qml b/tests/auto/declarative/qmllanguage/data/listAssignment.1.qml
deleted file mode 100644
index 4240425..0000000
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.1.qml
+++ /dev/null
@@ -1,4 +0,0 @@
-import Test 1.0
-MyContainer {
- qmllistInterfaces: 1
-}
diff --git a/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml b/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml
index 779c6d4..32b5b6c 100644
--- a/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml
+++ b/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml
@@ -23,7 +23,7 @@ Item {
width: 200; height: 50
Text { text: name }
Text { text: '$'+cost; anchors.right: parent.right }
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: fruitModel.remove(index)
}
diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h
index 0dc957f..27b45e4 100644
--- a/tests/auto/declarative/qmllanguage/testtypes.h
+++ b/tests/auto/declarative/qmllanguage/testtypes.h
@@ -447,22 +447,19 @@ QML_DECLARE_TYPE(MyTypeObject);
class MyContainer : public QObject
{
Q_OBJECT
- Q_PROPERTY(QList<QObject*>* children READ children)
- Q_PROPERTY(QList<MyInterface*>* qlistInterfaces READ qlistInterfaces)
- Q_PROPERTY(QmlList<MyInterface*>* qmllistInterfaces READ qmllistInterfaces)
+ Q_PROPERTY(QmlListProperty<QObject> children READ children)
+ Q_PROPERTY(QmlListProperty<MyInterface> qlistInterfaces READ qlistInterfaces)
Q_CLASSINFO("DefaultProperty", "children");
public:
MyContainer() {}
- QList<QObject*> *children() { return &m_children; }
- QList<MyInterface *> *qlistInterfaces() { return &m_interfaces; }
- QmlList<MyInterface *> *qmllistInterfaces() { return &m_qmlinterfaces; }
- const QmlConcreteList<MyInterface *> &qmllistAccessor() const { return m_qmlinterfaces; }
+ QmlListProperty<QObject> children() { return QmlListProperty<QObject>(this, m_children); }
+ QList<QObject *> *getChildren() { return &m_children; }
+ QmlListProperty<MyInterface> qlistInterfaces() { return QmlListProperty<MyInterface>(this, m_interfaces); }
+ QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; }
-private:
QList<QObject*> m_children;
QList<MyInterface *> m_interfaces;
- QmlConcreteList<MyInterface *> m_qmlinterfaces;
};
QML_DECLARE_TYPE(MyContainer);
@@ -534,12 +531,12 @@ namespace MyNamespace {
class MySecondNamespacedType : public QObject
{
Q_OBJECT
- Q_PROPERTY(QmlList<MyNamespace::MyNamespacedType *> *list READ list);
+ Q_PROPERTY(QmlListProperty<MyNamespace::MyNamespacedType> list READ list);
public:
- QmlList<MyNamespacedType *> *list() { return &m_list; }
+ QmlListProperty<MyNamespacedType> list() { return QmlListProperty<MyNamespacedType>(this, m_list); }
private:
- QmlConcreteList<MyNamespacedType *> m_list;
+ QList<MyNamespacedType *> m_list;
};
}
QML_DECLARE_TYPE(MyNamespace::MyNamespacedType);
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
index c4636f3..4090e1d 100644
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
@@ -76,7 +76,6 @@ private slots:
void simpleObject();
void simpleContainer();
void interfaceProperty();
- void interfaceQmlList();
void interfaceQList();
void assignObjectToSignal();
void assignObjectToVariant();
@@ -233,7 +232,6 @@ void tst_qmllanguage::errors_data()
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("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;
@@ -354,7 +352,7 @@ void tst_qmllanguage::simpleContainer()
VERIFY_ERRORS(0);
MyContainer *container= qobject_cast<MyContainer*>(component.create());
QVERIFY(container != 0);
- QCOMPARE(container->children()->count(),2);
+ QCOMPARE(container->getChildren()->count(),2);
}
void tst_qmllanguage::interfaceProperty()
@@ -367,26 +365,15 @@ void tst_qmllanguage::interfaceProperty()
QVERIFY(object->interface()->id == 913);
}
-void tst_qmllanguage::interfaceQmlList()
-{
- QmlComponent component(&engine, TEST_FILE("interfaceQmlList.qml"));
- VERIFY_ERRORS(0);
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container != 0);
- QVERIFY(container->qmllistAccessor().count() == 2);
- for(int ii = 0; ii < 2; ++ii)
- QVERIFY(container->qmllistAccessor().at(ii)->id == 913);
-}
-
void tst_qmllanguage::interfaceQList()
{
QmlComponent component(&engine, TEST_FILE("interfaceQList.qml"));
VERIFY_ERRORS(0);
MyContainer *container= qobject_cast<MyContainer*>(component.create());
QVERIFY(container != 0);
- QVERIFY(container->qlistInterfaces()->count() == 2);
+ QVERIFY(container->getQListInterfaces()->count() == 2);
for(int ii = 0; ii < 2; ++ii)
- QVERIFY(container->qlistInterfaces()->at(ii)->id == 913);
+ QVERIFY(container->getQListInterfaces()->at(ii)->id == 913);
}
void tst_qmllanguage::assignObjectToSignal()
@@ -425,8 +412,8 @@ void tst_qmllanguage::assignQmlComponent()
VERIFY_ERRORS(0);
MyContainer *object = qobject_cast<MyContainer *>(component.create());
QVERIFY(object != 0);
- QVERIFY(object->children()->count() == 1);
- QObject *child = object->children()->at(0);
+ QVERIFY(object->getChildren()->count() == 1);
+ QObject *child = object->getChildren()->at(0);
QCOMPARE(child->property("x"), QVariant(10));
QCOMPARE(child->property("y"), QVariant(11));
}
@@ -504,7 +491,7 @@ void tst_qmllanguage::rootAsQmlComponent()
MyContainer *object = qobject_cast<MyContainer *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->property("x"), QVariant(11));
- QCOMPARE(object->children()->count(), 2);
+ QCOMPARE(object->getChildren()->count(), 2);
}
// Tests that components can be specified inline
@@ -514,8 +501,8 @@ void tst_qmllanguage::inlineQmlComponents()
VERIFY_ERRORS(0);
MyContainer *object = qobject_cast<MyContainer *>(component.create());
QVERIFY(object != 0);
- QCOMPARE(object->children()->count(), 1);
- QmlComponent *comp = qobject_cast<QmlComponent *>(object->children()->at(0));
+ QCOMPARE(object->getChildren()->count(), 1);
+ QmlComponent *comp = qobject_cast<QmlComponent *>(object->getChildren()->at(0));
QVERIFY(comp != 0);
MyQmlObject *compObject = qobject_cast<MyQmlObject *>(comp->create());
QVERIFY(compObject != 0);
@@ -529,9 +516,9 @@ void tst_qmllanguage::idProperty()
VERIFY_ERRORS(0);
MyContainer *object = qobject_cast<MyContainer *>(component.create());
QVERIFY(object != 0);
- QCOMPARE(object->children()->count(), 1);
+ QCOMPARE(object->getChildren()->count(), 1);
MyTypeObject *child =
- qobject_cast<MyTypeObject *>(object->children()->at(0));
+ qobject_cast<MyTypeObject *>(object->getChildren()->at(0));
QVERIFY(child != 0);
QCOMPARE(child->id(), QString("myObjectId"));
QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
@@ -1034,13 +1021,13 @@ void tst_qmllanguage::defaultPropertyListOrder()
MyContainer *container = qobject_cast<MyContainer *>(component.create());
QVERIFY(container != 0);
- QCOMPARE(container->children()->count(), 6);
- QCOMPARE(container->children()->at(0)->property("index"), QVariant(0));
- QCOMPARE(container->children()->at(1)->property("index"), QVariant(1));
- QCOMPARE(container->children()->at(2)->property("index"), QVariant(2));
- QCOMPARE(container->children()->at(3)->property("index"), QVariant(3));
- QCOMPARE(container->children()->at(4)->property("index"), QVariant(4));
- QCOMPARE(container->children()->at(5)->property("index"), QVariant(5));
+ 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_qmllanguage::declaredPropertyValues()
diff --git a/tests/auto/declarative/qmllist/data/MyType.qml b/tests/auto/declarative/qmllist/data/MyType.qml
new file mode 100644
index 0000000..d08f35b
--- /dev/null
+++ b/tests/auto/declarative/qmllist/data/MyType.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+
+QtObject {
+ property int a
+}
diff --git a/tests/auto/declarative/qmllist/data/engineTypes.qml b/tests/auto/declarative/qmllist/data/engineTypes.qml
new file mode 100644
index 0000000..670aee4
--- /dev/null
+++ b/tests/auto/declarative/qmllist/data/engineTypes.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+QtObject {
+ property list<MyType> myList
+
+ myList: [ MyType { a: 1 },
+ MyType { a: 9 } ]
+
+}
diff --git a/tests/auto/declarative/qmllist/data/variantToList.qml b/tests/auto/declarative/qmllist/data/variantToList.qml
new file mode 100644
index 0000000..0c2d0aa
--- /dev/null
+++ b/tests/auto/declarative/qmllist/data/variantToList.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+QtObject {
+ property list<QtObject> myList;
+ myList: QtObject {}
+
+ property var value: myList
+ property int test: value.length
+}
+
diff --git a/tests/auto/declarative/qmllist/tst_qmllist.cpp b/tests/auto/declarative/qmllist/tst_qmllist.cpp
index 4ffbbb8..76def1c 100644
--- a/tests/auto/declarative/qmllist/tst_qmllist.cpp
+++ b/tests/auto/declarative/qmllist/tst_qmllist.cpp
@@ -38,9 +38,27 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include <qtest.h>
+#include <QUrl>
+#include <QFileInfo>
+#include <QDir>
+#include <QmlEngine>
+#include <QmlComponent>
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlprivate.h>
+#include <QDebug>
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename));
+}
+
+inline QUrl TEST_FILE(const char *filename)
+{
+ return TEST_FILE(QLatin1String(filename));
+}
class tst_QmlList : public QObject
{
@@ -49,28 +67,506 @@ public:
tst_QmlList() {}
private slots:
- void interface();
+ 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();
};
-void tst_QmlList::interface()
+class TestType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QmlListProperty<TestType> data READ dataProperty);
+ Q_PROPERTY(int intProperty READ intProperty);
+
+public:
+ TestType() : property(this, data) {}
+ QmlListProperty<TestType> dataProperty() { return property; }
+ int intProperty() const { return 10; }
+
+ QList<TestType *> data;
+ QmlListProperty<TestType> property;
+};
+QML_DECLARE_TYPE(TestType);
+QML_DEFINE_NOCREATE_TYPE(TestType);
+
+void tst_QmlList::qmllistreference()
+{
+ TestType tt;
+
+ QmlListReference r(&tt, "data");
+ QVERIFY(r.isValid() == true);
+ QCOMPARE(r.count(), 0);
+
+ tt.data.append(&tt);
+ QCOMPARE(r.count(), 1);
+}
+
+void tst_QmlList::qmllistreference_invalid()
+{
+ TestType tt;
+
+ // Invalid
+ {
+ QmlListReference 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
+ {
+ QmlListReference 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
+ {
+ QmlListReference 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_QmlList::isValid()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.isValid() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.isValid() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.isValid() == true);
+ delete tt;
+ QVERIFY(ref.isValid() == false);
+ }
+}
+
+void tst_QmlList::object()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.object() == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.object() == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.object() == tt);
+ delete tt;
+ QVERIFY(ref.object() == 0);
+ }
+}
+
+void tst_QmlList::listElementType()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.listElementType() == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.listElementType() == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
+ delete tt;
+ QVERIFY(ref.listElementType() == 0);
+ }
+}
+
+void tst_QmlList::canAppend()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.canAppend() == true);
+ delete tt;
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.append = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.canAppend() == false);
+ }
+}
+
+void tst_QmlList::canAt()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.canAt() == true);
+ delete tt;
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.at = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.canAt() == false);
+ }
+}
+
+void tst_QmlList::canClear()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.canClear() == true);
+ delete tt;
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.clear = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.canClear() == false);
+ }
+}
+
+void tst_QmlList::canCount()
+{
+ TestType *tt = new TestType;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.canCount() == true);
+ delete tt;
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.count = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.canCount() == false);
+ }
+}
+
+void tst_QmlList::append()
+{
+ TestType *tt = new TestType;
+ QObject object;
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.append(tt) == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.append(tt) == false);
+ }
+
+ {
+ QmlListReference 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;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.append(&tt) == false);
+ }
+}
+
+void tst_QmlList::at()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ QmlListReference 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;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.at(0) == 0);
+ }
+}
+
+void tst_QmlList::clear()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ QmlListReference ref(tt, "data");
+ QVERIFY(ref.clear() == true);
+ QVERIFY(tt->data.count() == 0);
+ delete tt;
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.clear = 0;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.clear() == false);
+ }
+}
+
+void tst_QmlList::count()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QmlListReference ref;
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ QmlListReference ref(tt, "blah");
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ QmlListReference 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;
+ QmlListReference ref(&tt, "data");
+ QVERIFY(ref.count() == 0);
+ }
+}
+
+void tst_QmlList::copy()
+{
+ TestType tt;
+ tt.data.append(&tt);
+ tt.data.append(0);
+ tt.data.append(&tt);
+
+ QmlListReference *r1 = new QmlListReference(&tt, "data");
+ QVERIFY(r1->count() == 3);
+
+ QmlListReference r2(*r1);
+ QmlListReference 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_QmlList::qmlmetaproperty()
+{
+ TestType tt;
+ tt.data.append(&tt);
+ tt.data.append(0);
+ tt.data.append(&tt);
+
+ QmlMetaProperty prop(&tt, QLatin1String("data"));
+ QVariant v = prop.read();
+ QVERIFY(v.userType() == qMetaTypeId<QmlListReference>());
+ QmlListReference ref = qvariant_cast<QmlListReference>(v);
+ QVERIFY(ref.count() == 3);
+ QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
+}
+
+void tst_QmlList::engineTypes()
+{
+ QmlEngine engine;
+ QmlComponent component(&engine, TEST_FILE("engineTypes.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+
+ QmlMetaProperty p1(o, QLatin1String("myList"));
+ QVERIFY(p1.propertyCategory() == QmlMetaProperty::Normal);
+
+ QmlMetaProperty p2(o, QLatin1String("myList"), engine.rootContext());
+ QVERIFY(p2.propertyCategory() == QmlMetaProperty::List);
+ QVariant v = p2.read();
+ QVERIFY(v.userType() == qMetaTypeId<QmlListReference>());
+ QmlListReference ref = qvariant_cast<QmlListReference>(v);
+ QVERIFY(ref.count() == 2);
+ QVERIFY(ref.listElementType());
+ QVERIFY(ref.listElementType() != &QObject::staticMetaObject);
+
+ delete o;
+}
+
+void tst_QmlList::variantToList()
{
- QmlConcreteList<QObject*> list;
- QObject *obj = new QObject;
- obj->setObjectName("foo");
- list.append(obj);
- QVERIFY(list.count() == 1);
- QCOMPARE(list.at(0), obj);
+ QmlEngine engine;
+ QmlComponent component(&engine, TEST_FILE("variantToList.qml"));
- QmlPrivate::ListInterface *li = (QmlPrivate::ListInterface*)&list;
+ QObject *o = component.create();
+ QVERIFY(o);
- void *ptr[1];
- li->at(0, ptr);
- QVERIFY(li->count() == 1);
- QCOMPARE(ptr[0], obj);
+ QVERIFY(o->property("value").userType() == qMetaTypeId<QmlListReference>());
+ QCOMPARE(o->property("test").toInt(), 1);
- li->removeAt(0);
- QVERIFY(li->count() == 0);
- QVERIFY(list.count() == 0);
+ delete o;
}
QTEST_MAIN(tst_QmlList)
diff --git a/tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro b/tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro
deleted file mode 100644
index ce2915e..0000000
--- a/tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmllistaccessor.cpp
diff --git a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp
deleted file mode 100644
index 3efe847..0000000
--- a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp
+++ /dev/null
@@ -1,452 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qml.h>
-#include <private/qmllistaccessor_p.h>
-#include <QDebug>
-
-class tst_QmlListAccessor : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlListAccessor() {}
-
-private slots:
- void invalid();
- void qmllist();
- void qlist();
- void qstringlist();
- void qvariantlist();
- void qobject();
- void instance();
- void integer();
-};
-
-void tst_QmlListAccessor::invalid()
-{
- QmlListAccessor accessor;
-
- QCOMPARE(accessor.list(), QVariant());
- QVERIFY(!accessor.isValid());
- QCOMPARE(accessor.type(), QmlListAccessor::Invalid);
-
- QCOMPARE(accessor.count(), 0);
- QVERIFY(!accessor.append(QVariant(10)));
- QVERIFY(!accessor.insert(0, QVariant(10)));
- QVERIFY(!accessor.removeAt(0));
- QVERIFY(!accessor.clear());
-
- accessor.setList(QVariant());
-
- QCOMPARE(accessor.list(), QVariant());
- QVERIFY(!accessor.isValid());
- QCOMPARE(accessor.type(), QmlListAccessor::Invalid);
-
- QCOMPARE(accessor.count(), 0);
- QVERIFY(!accessor.append(QVariant(10)));
- QVERIFY(!accessor.insert(0, QVariant(10)));
- QVERIFY(!accessor.removeAt(0));
- QVERIFY(!accessor.clear());
-}
-
-void tst_QmlListAccessor::qmllist()
-{
- QmlConcreteList<QObject*> list;
- QObject *obj = new QObject(this);
- QObject *obj2 = new QObject(this);
- QObject *obj3 = new QObject(this);
-
- list.append(obj);
- QVERIFY(list.count() == 1);
- QCOMPARE(list.at(0), obj);
-
- QmlListAccessor accessor;
- accessor.setList(qVariantFromValue((QmlList<QObject*>*)&list));
- QCOMPARE(accessor.list(), qVariantFromValue((QmlList<QObject*>*)&list));
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::QmlList);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QCOMPARE(accessor.count(), 1);
-
- // at
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(0)), obj);
-
- // append
- accessor.append(qVariantFromValue(obj2));
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 2);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj2);
- QCOMPARE(list.count(), 2);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj2);
-
- // insert
- accessor.insert(1, qVariantFromValue(obj3));
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 3);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj3);
- QCOMPARE(list.count(), 3);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj3);
- QCOMPARE(list.at(2), obj2);
-
- // removeAt
- accessor.removeAt(1);
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 2);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj2);
- QCOMPARE(list.count(), 2);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj2);
-
- // clear
- accessor.clear();
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 0);
- QCOMPARE(list.count(), 0);
-}
-
-void tst_QmlListAccessor::qlist()
-{
- QList<QObject*> list;
- QObject *obj = new QObject(this);
- QObject *obj2 = new QObject(this);
- QObject *obj3 = new QObject(this);
-
- list.append(obj);
- QVERIFY(list.count() == 1);
- QCOMPARE(list.at(0), obj);
-
- QmlListAccessor accessor;
- accessor.setList(qVariantFromValue((QList<QObject*>*)&list));
- QCOMPARE(accessor.list(), qVariantFromValue((QList<QObject*>*)&list));
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::QListPtr);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QCOMPARE(accessor.count(), 1);
-
- // at
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(0)), obj);
-
- // append
- accessor.append(qVariantFromValue(obj2));
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 2);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj2);
- QCOMPARE(list.count(), 2);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj2);
-
- // insert
- accessor.insert(1, qVariantFromValue(obj3));
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 3);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj3);
- QCOMPARE(list.count(), 3);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj3);
- QCOMPARE(list.at(2), obj2);
-
- // removeAt
- accessor.removeAt(1);
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 2);
- QCOMPARE(qvariant_cast<QObject*>(accessor.at(1)), obj2);
- QCOMPARE(list.count(), 2);
- QCOMPARE(list.at(0), obj);
- QCOMPARE(list.at(1), obj2);
-
- // clear
- accessor.clear();
- QVERIFY(accessor.isValid());
- QCOMPARE(accessor.count(), 0);
- QCOMPARE(list.count(), 0);
-}
-
-void tst_QmlListAccessor::qstringlist()
-{
- QStringList list;
- list.append(QLatin1String("Item1"));
- list.append(QLatin1String("Item2"));
- QVERIFY(list.count() == 2);
-
- QmlListAccessor accessor;
- accessor.setList(list);
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::StringList);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QVERIFY(accessor.count() == 2);
-
- // at
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // append
- QVERIFY(!accessor.append(QVariant("Item3")));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // insert
- QVERIFY(!accessor.insert(1, QVariant("MiddleItem")));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // removeAt
- QVERIFY(!accessor.removeAt(1));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // clear
- QVERIFY(!accessor.clear());
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-}
-
-void tst_QmlListAccessor::qvariantlist()
-{
- QVariantList list;
- list.append(QLatin1String("Item1"));
- list.append(QLatin1String("Item2"));
- QVERIFY(list.count() == 2);
-
- QmlListAccessor accessor;
- accessor.setList(list);
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::VariantList);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QVERIFY(accessor.count() == 2);
-
- // at
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // append
- QVERIFY(!accessor.append(QVariant("Item3")));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // insert
- QVERIFY(!accessor.insert(1, QVariant("MiddleItem")));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // removeAt
- QVERIFY(!accessor.removeAt(1));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-
- // clear
- QVERIFY(!accessor.clear());
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 2);
- QCOMPARE(qvariant_cast<QString>(accessor.at(0)), QLatin1String("Item1"));
- QCOMPARE(qvariant_cast<QString>(accessor.at(1)), QLatin1String("Item2"));
-}
-
-void tst_QmlListAccessor::qobject()
-{
- QObject *obj = new QObject(this);
-
- QmlListAccessor accessor;
- accessor.setList(qVariantFromValue(obj));
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::Instance);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QVERIFY(accessor.count() == 1);
-
- // at
- QCOMPARE(accessor.at(0), qVariantFromValue(obj));
-
- // append
- QVERIFY(!accessor.append(qVariantFromValue((QObject *)0)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(obj));
-
- // insert
- QVERIFY(!accessor.insert(0, qVariantFromValue((QObject *)0)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(obj));
-
- // removeAt
- QVERIFY(!accessor.removeAt(0));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(obj));
-
- // clear
- QVERIFY(!accessor.clear());
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(obj));
-}
-
-void tst_QmlListAccessor::instance()
-{
- QRect r;
-
- QmlListAccessor accessor;
- accessor.setList(r);
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::Instance);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QVERIFY(accessor.count() == 1);
-
- // at
- QCOMPARE(accessor.at(0), qVariantFromValue(r));
-
- // append
- QVERIFY(!accessor.append(qVariantFromValue(r)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(r));
-
- // insert
- QVERIFY(!accessor.insert(0, qVariantFromValue(r)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(r));
-
- // removeAt
- QVERIFY(!accessor.removeAt(0));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(r));
-
- // clear
- QVERIFY(!accessor.clear());
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 1);
- QCOMPARE(accessor.at(0), qVariantFromValue(r));
-}
-
-void tst_QmlListAccessor::integer()
-{
- int r = 13;
-
- QmlListAccessor accessor;
- accessor.setList(r);
-
- // type
- QCOMPARE(accessor.type(), QmlListAccessor::Integer);
-
- // isValid
- QVERIFY(accessor.isValid());
-
- // count
- QVERIFY(accessor.count() == 13);
-
- // at
- QCOMPARE(accessor.at(4), qVariantFromValue(4));
-
- // append
- QVERIFY(!accessor.append(qVariantFromValue(r)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 13);
- QCOMPARE(accessor.at(4), qVariantFromValue(4));
-
- // insert
- QVERIFY(!accessor.insert(0, qVariantFromValue(r)));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 13);
- QCOMPARE(accessor.at(4), qVariantFromValue(4));
-
- // removeAt
- QVERIFY(!accessor.removeAt(0));
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 13);
- QCOMPARE(accessor.at(4), qVariantFromValue(4));
-
- // clear
- QVERIFY(!accessor.clear());
- QVERIFY(accessor.isValid());
- QVERIFY(accessor.count() == 13);
- QCOMPARE(accessor.at(4), qVariantFromValue(4));
-}
-
-QTEST_MAIN(tst_QmlListAccessor)
-
-#include "tst_qmllistaccessor.moc"
diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
index 91ff727..050cd3f 100644
--- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
+++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
@@ -73,13 +73,11 @@ private:
class MyContainer : public QObject
{
Q_OBJECT
- Q_PROPERTY(QList<MyQmlObject*>* children READ children)
- Q_PROPERTY(QmlList<MyQmlObject*>* qmlChildren READ qmlChildren)
+ Q_PROPERTY(QmlListProperty<MyQmlObject> children READ children)
public:
MyContainer() {}
- QList<MyQmlObject*> *children() { return &m_children; }
- QmlConcreteList<MyQmlObject *> *qmlChildren() { return &m_qmlChildren; }
+ QmlListProperty<MyQmlObject> children() { return QmlListProperty<MyQmlObject>(this, m_children); }
static MyAttached *qmlAttachedProperties(QObject *o) {
return new MyAttached(o);
@@ -87,7 +85,6 @@ public:
private:
QList<MyQmlObject*> m_children;
- QmlConcreteList<MyQmlObject *> m_qmlChildren;
};
QML_DECLARE_TYPE(MyContainer);
@@ -118,7 +115,6 @@ private slots:
// Functionality
void writeObjectToList();
void writeListToList();
- void writeObjectToQmlList();
//writeToReadOnly();
@@ -1078,13 +1074,14 @@ void tst_qmlmetaproperty::writeObjectToList()
containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
QVERIFY(container != 0);
- QVERIFY(container->children()->size() == 1);
+ QmlListReference list(container, "children");
+ QVERIFY(list.count() == 1);
MyQmlObject *object = new MyQmlObject;
QmlMetaProperty prop(container, "children");
prop.write(qVariantFromValue(object));
- QCOMPARE(container->children()->size(), 2);
- QCOMPARE(container->children()->at(1), object);
+ QCOMPARE(list.count(), 1);
+ QCOMPARE(list.at(0), object);
}
Q_DECLARE_METATYPE(QList<QObject *>);
@@ -1094,13 +1091,14 @@ void tst_qmlmetaproperty::writeListToList()
containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
QVERIFY(container != 0);
- QVERIFY(container->children()->size() == 1);
+ QmlListReference list(container, "children");
+ QVERIFY(list.count() == 1);
QList<QObject*> objList;
objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject();
QmlMetaProperty prop(container, "children");
prop.write(qVariantFromValue(objList));
- QCOMPARE(container->children()->size(), 4);
+ QCOMPARE(list.count(), 4);
//XXX need to try this with read/write prop (for read-only it correctly doesn't write)
/*QList<MyQmlObject*> typedObjList;
@@ -1109,21 +1107,6 @@ void tst_qmlmetaproperty::writeListToList()
QCOMPARE(container->children()->size(), 1);*/
}
-void tst_qmlmetaproperty::writeObjectToQmlList()
-{
- QmlComponent containerComponent(&engine);
- containerComponent.setData("import Test 1.0\nMyContainer { qmlChildren: MyQmlObject {} }", QUrl());
- MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
- QVERIFY(container != 0);
- QVERIFY(container->qmlChildren()->size() == 1);
-
- MyQmlObject *object = new MyQmlObject;
- QmlMetaProperty prop(container, "qmlChildren");
- prop.write(qVariantFromValue(object));
- QCOMPARE(container->qmlChildren()->size(), 2);
- QCOMPARE(container->qmlChildren()->at(1), object);
-}
-
void tst_qmlmetaproperty::crashOnValueProperty()
{
QmlEngine *engine = new QmlEngine;
diff --git a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
index 6d1887f..750ccf8 100644
--- a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
+++ b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
@@ -67,10 +67,6 @@ private slots:
void qmlPropertyValueInterceptorCast();
void isList();
- void isQmlList();
-
- void listCount();
- void listAt();
void defaultObject();
};
@@ -346,85 +342,12 @@ void tst_qmlmetatype::qmlPropertyValueInterceptorCast()
void tst_qmlmetatype::isList()
{
- QCOMPARE(QmlMetaType::isList(QVariant()), false);
QCOMPARE(QmlMetaType::isList(QVariant::Invalid), false);
QCOMPARE(QmlMetaType::isList(QVariant::Int), false);
- QCOMPARE(QmlMetaType::isList(QVariant(10)), false);
-
- QList<TestType *> list;
- QmlConcreteList<TestType *> qmllist;
-
- QCOMPARE(QmlMetaType::isList(qMetaTypeId<QList<TestType *>*>()), true);
- QCOMPARE(QmlMetaType::isList(QVariant::fromValue(&list)), true);
- QCOMPARE(QmlMetaType::isList(qMetaTypeId<QmlList<TestType *>*>()), false);
- QCOMPARE(QmlMetaType::isList(QVariant::fromValue((QmlList<TestType *>*)&qmllist)), false);
-}
-void tst_qmlmetatype::isQmlList()
-{
- QCOMPARE(QmlMetaType::isQmlList(QVariant::Invalid), false);
- QCOMPARE(QmlMetaType::isQmlList(QVariant::Int), false);
-
- QCOMPARE(QmlMetaType::isQmlList(qMetaTypeId<QList<TestType *>*>()), false);
- QCOMPARE(QmlMetaType::isQmlList(qMetaTypeId<QmlList<TestType *>*>()), true);
-}
+ QmlListProperty<TestType> list;
-void tst_qmlmetatype::listCount()
-{
- QCOMPARE(QmlMetaType::listCount(QVariant()), 0);
- QCOMPARE(QmlMetaType::listCount(QVariant(10)), 0);
-
- QList<TestType *> list;
- QVariant listVar = QVariant::fromValue(&list);
- QmlConcreteList<TestType *> qmllist;
- QVariant qmllistVar = QVariant::fromValue((QmlList<TestType *>*)&qmllist);
-
- QCOMPARE(QmlMetaType::listCount(listVar), 0);
- QCOMPARE(QmlMetaType::listCount(qmllistVar), 0);
-
- list.append(0); list.append(0); list.append(0);
- qmllist.append(0); qmllist.append(0); qmllist.append(0);
-
- QCOMPARE(QmlMetaType::listCount(listVar), 3);
- QCOMPARE(QmlMetaType::listCount(qmllistVar), 0);
-}
-
-void tst_qmlmetatype::listAt()
-{
- QCOMPARE(QmlMetaType::listAt(QVariant(), 0), QVariant());
- QCOMPARE(QmlMetaType::listAt(QVariant(10), 0), QVariant());
- QCOMPARE(QmlMetaType::listAt(QVariant(), 10), QVariant());
- QCOMPARE(QmlMetaType::listAt(QVariant(10), 10), QVariant());
- QCOMPARE(QmlMetaType::listAt(QVariant(), -10), QVariant());
- QCOMPARE(QmlMetaType::listAt(QVariant(10), -10), QVariant());
-
- QList<TestType *> list;
- QVariant listVar = QVariant::fromValue(&list);
- QmlConcreteList<TestType *> qmllist;
- QVariant qmllistVar = QVariant::fromValue((QmlList<TestType *>*)&qmllist);
-
- QCOMPARE(QmlMetaType::listAt(listVar, 0), QVariant());
- QCOMPARE(QmlMetaType::listAt(listVar, 2), QVariant());
- QCOMPARE(QmlMetaType::listAt(listVar, -1), QVariant());
-
- QCOMPARE(QmlMetaType::listAt(qmllistVar, 0), QVariant());
- QCOMPARE(QmlMetaType::listAt(qmllistVar, 2), QVariant());
- QCOMPARE(QmlMetaType::listAt(qmllistVar, -1), QVariant());
-
- TestType ttype;
- QVariant ttypeVar = QVariant::fromValue(&ttype);
- QVariant nullttypeVar = QVariant::fromValue((TestType *)0);
-
- list.append(0); list.append(&ttype); list.append(0);
- qmllist.append(0); qmllist.append(&ttype); qmllist.append(0);
-
- QCOMPARE(QmlMetaType::listAt(listVar, 0), nullttypeVar);
- QCOMPARE(QmlMetaType::listAt(listVar, 1), ttypeVar);
- QCOMPARE(QmlMetaType::listAt(listVar, -1), QVariant());
-
- QCOMPARE(QmlMetaType::listAt(qmllistVar, 0), QVariant());
- QCOMPARE(QmlMetaType::listAt(qmllistVar, 2), QVariant());
- QCOMPARE(QmlMetaType::listAt(qmllistVar, -1), QVariant());
+ QCOMPARE(QmlMetaType::isList(qMetaTypeId<QmlListProperty<TestType> >()), true);
}
void tst_qmlmetatype::defaultObject()
diff --git a/tests/auto/declarative/qmlstates/data/illegalTempState.qml b/tests/auto/declarative/qmlstates/data/illegalTempState.qml
index 2702be4..0dc39ae 100644
--- a/tests/auto/declarative/qmlstates/data/illegalTempState.qml
+++ b/tests/auto/declarative/qmlstates/data/illegalTempState.qml
@@ -14,7 +14,7 @@ Rectangle {
}
]
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: card.state = "placed"
}
diff --git a/tests/auto/declarative/qmlstates/data/legalTempState.qml b/tests/auto/declarative/qmlstates/data/legalTempState.qml
index 54c97b9..9be984c 100644
--- a/tests/auto/declarative/qmlstates/data/legalTempState.qml
+++ b/tests/auto/declarative/qmlstates/data/legalTempState.qml
@@ -16,7 +16,7 @@ Rectangle {
}
]
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: card.state = "placed"
}
diff --git a/tests/auto/declarative/qmlstates/data/parentChange.qml b/tests/auto/declarative/qmlstates/data/parentChange.qml
index 087da6b..b8c7818 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange.qml
+++ b/tests/auto/declarative/qmlstates/data/parentChange.qml
@@ -12,7 +12,7 @@ Rectangle {
color: "red"
}
}
- MouseRegion {
+ MouseArea {
id: clickable
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlstates/data/parentChange2.qml b/tests/auto/declarative/qmlstates/data/parentChange2.qml
index f0b00f5..8b23591 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange2.qml
+++ b/tests/auto/declarative/qmlstates/data/parentChange2.qml
@@ -15,7 +15,7 @@ Rectangle {
color: "red"
}
}
- MouseRegion {
+ MouseArea {
id: clickable
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlstates/data/parentChange3.qml b/tests/auto/declarative/qmlstates/data/parentChange3.qml
index 2aa507c..ddf9268 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange3.qml
+++ b/tests/auto/declarative/qmlstates/data/parentChange3.qml
@@ -16,7 +16,7 @@ Rectangle {
color: "red"
}
}
- MouseRegion {
+ MouseArea {
id: clickable
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlstates/data/parentChange4.qml b/tests/auto/declarative/qmlstates/data/parentChange4.qml
index d00274b..34d667a 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange4.qml
+++ b/tests/auto/declarative/qmlstates/data/parentChange4.qml
@@ -9,7 +9,7 @@ Rectangle {
width: 100; height: 100
color: "red"
}
- MouseRegion {
+ MouseArea {
id: clickable
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlstates/data/parentChange5.qml b/tests/auto/declarative/qmlstates/data/parentChange5.qml
index f75e2a3..56bdd89 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange5.qml
+++ b/tests/auto/declarative/qmlstates/data/parentChange5.qml
@@ -9,7 +9,7 @@ Rectangle {
width: 100; height: 100
color: "red"
}
- MouseRegion {
+ MouseArea {
id: clickable
anchors.fill: parent
}
diff --git a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
index 81145a8..b910c85 100644
--- a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
+++ b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
@@ -407,8 +407,12 @@ void tst_qmlstates::parentChange()
QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
QVERIFY(innerRect != 0);
- qmlExecuteDeferred(rect->states()->at(0));
- QmlParentChange *pChange = qobject_cast<QmlParentChange*>(rect->states()->at(0)->changes()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QmlParentChange *pChange = qobject_cast<QmlParentChange*>(state->operationAt(0));
QVERIFY(pChange != 0);
QmlGraphicsItem *nParent = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("NewParent"));
QVERIFY(nParent != 0);
@@ -510,8 +514,12 @@ void tst_qmlstates::anchorChanges()
QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
QVERIFY(innerRect != 0);
- qmlExecuteDeferred(rect->states()->at(0));
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
rect->setState("right");
@@ -565,8 +573,12 @@ void tst_qmlstates::anchorChanges3()
QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
QVERIFY(bottomGuideline != 0);
- qmlExecuteDeferred(rect->states()->at(0));
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
rect->setState("reanchored");
@@ -611,8 +623,12 @@ void tst_qmlstates::anchorChanges4()
QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
QVERIFY(bottomGuideline != 0);
- qmlExecuteDeferred(rect->states()->at(0));
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
rect->setState("reanchored");
@@ -642,8 +658,12 @@ void tst_qmlstates::anchorChanges5()
QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
QVERIFY(bottomGuideline != 0);
- qmlExecuteDeferred(rect->states()->at(0));
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
QVERIFY(aChanges != 0);
rect->setState("reanchored");
@@ -700,7 +720,11 @@ void tst_qmlstates::explicitChanges()
QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
- qmlExecuteDeferred(rect->states()->at(0));
+ QmlListReference list(rect, "states");
+ QmlState *state = qobject_cast<QmlState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
QmlPropertyChanges *changes = qobject_cast<QmlPropertyChanges*>(rect->findChild<QmlPropertyChanges*>("changes"));
QVERIFY(changes != 0);
QVERIFY(changes->isExplicit());
@@ -802,7 +826,7 @@ void tst_qmlstates::deletingChange()
QmlState *state = rect->findChild<QmlState*>();
QVERIFY(state != 0);
qmlExecuteDeferred(state);
- QCOMPARE(state->changes()->count(), 1);
+ QCOMPARE(state->operationCount(), 1);
rect->setState("blue");
QCOMPARE(rect->color(),QColor("red"));
diff --git a/tests/auto/declarative/visual/Package_Views/packageviews.qml b/tests/auto/declarative/visual/Package_Views/packageviews.qml
index dcfe7de..b577e45 100644
--- a/tests/auto/declarative/visual/Package_Views/packageviews.qml
+++ b/tests/auto/declarative/visual/Package_Views/packageviews.qml
@@ -29,14 +29,14 @@ Rectangle {
delegate: Package {
Rectangle {
id: listItem; Package.name: "list"; width:root.width/2; height: 50; color: "transparent"; border.color: "white"
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: myState.state = myState.state == "list" ? "grid" : "list"
}
}
Rectangle {
id: gridItem; Package.name: "grid"; width:50; height: 50; color: "transparent"; border.color: "white"
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: myState.state = myState.state == "list" ? "grid" : "list"
}
diff --git a/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml b/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml
index 5230ca4..70c14cf 100644
--- a/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml
+++ b/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml
@@ -20,7 +20,7 @@ Rectangle {
x: 50 + 50
}
PropertyChanges {
- target: myMouseRegion
+ target: myMouseArea
onClicked: page.state = ''
}
}
@@ -32,8 +32,8 @@ Rectangle {
}
}
]
- MouseRegion {
- id: myMouseRegion
+ MouseArea {
+ id: myMouseArea
anchors.fill: parent
onClicked: { page.state= 'hello' }
}
diff --git a/tests/auto/declarative/visual/animation/colorAnimation/colorAnimation.qml b/tests/auto/declarative/visual/animation/colorAnimation/colorAnimation.qml
index 0e98d7e..f205ae8 100644
--- a/tests/auto/declarative/visual/animation/colorAnimation/colorAnimation.qml
+++ b/tests/auto/declarative/visual/animation/colorAnimation/colorAnimation.qml
@@ -34,7 +34,7 @@ Rectangle {
}
}
]
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: { mainrect.state = 'second' }
}
diff --git a/tests/auto/declarative/visual/animation/easing/easing.qml b/tests/auto/declarative/visual/animation/easing/easing.qml
index f81400b..9c814eb 100644
--- a/tests/auto/declarative/visual/animation/easing/easing.qml
+++ b/tests/auto/declarative/visual/animation/easing/easing.qml
@@ -186,7 +186,7 @@ Rectangle {
}
}
}
- MouseRegion {
+ MouseArea {
id: mouse
anchors.fill: layout
}
diff --git a/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml b/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml
index 7021e05..1980b91 100644
--- a/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml
+++ b/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml
@@ -14,7 +14,7 @@ Rectangle {
color: "red"
}
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: parent.state = "state1"
}
diff --git a/tests/auto/declarative/visual/animation/parentAction/parentAction.qml b/tests/auto/declarative/visual/animation/parentAction/parentAction.qml
index e4f4406..eb3103e 100644
--- a/tests/auto/declarative/visual/animation/parentAction/parentAction.qml
+++ b/tests/auto/declarative/visual/animation/parentAction/parentAction.qml
@@ -15,7 +15,7 @@ Rectangle {
color: "red"
}
}
- MouseRegion {
+ MouseArea {
id: clickable
anchors.fill: parent
}
diff --git a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
index 68671e1..593f495 100644
--- a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
+++ b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
@@ -7,7 +7,7 @@ Rectangle {
width: 100; height: 100
color: "red"
}
- MouseRegion {
+ MouseArea {
id: clickable
anchors.fill: parent
}
diff --git a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml
index 359346f..d80631f 100644
--- a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml
+++ b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml
@@ -19,7 +19,7 @@ Rectangle {
Item { id: topGuideline2; y: 50 }
Item { id: bottomGuideline2; y: 175 }
- MouseRegion {
+ MouseArea {
id: wholeArea
anchors.fill: parent
onClicked: {
@@ -55,7 +55,7 @@ Rectangle {
NumberAnimation { properties: "x,y,width,height" }
}
- MouseRegion {
+ MouseArea {
width: 50; height: 50
anchors.right: parent.right
anchors.bottom: parent.bottom
diff --git a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
index f121906..30d587a 100644
--- a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
+++ b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
@@ -7,7 +7,7 @@ Rectangle {
width: 100; height: 100
color: "red"
}
- MouseRegion {
+ MouseArea {
id: clickable
anchors.fill: parent
}
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml b/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml
index cc15755..6204aa9 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml
+++ b/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml
@@ -25,7 +25,7 @@ Rectangle {
Repeater {
model: list
Rectangle { width: 300; height: 200; color: mr.pressed ? "black" : dayColor
- MouseRegion {
+ MouseArea {
id: mr
anchors.fill: parent
}
@@ -49,7 +49,7 @@ Rectangle {
height: 48
y: parent.height - 50
color: "red"
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: flick.interactive = flick.interactive ? false : true
}
@@ -62,7 +62,7 @@ Rectangle {
x: 66
y: parent.height - 50
color: "green"
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: flick.pressDelay = flick.pressDelay > 0 ? 0 : 500
}
@@ -75,7 +75,7 @@ Rectangle {
x: 130
y: parent.height - 50
color: "yellow"
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: flick.overShoot = flick.overShoot > 0 ? 0 : 30
}
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview.qml b/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview.qml
index 70018b6..0adfa02 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview.qml
+++ b/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview.qml
@@ -22,7 +22,7 @@ Rectangle {
width: 85; height: 85; color: lColor
scale: wrapper.PathView.scale
- MouseRegion { anchors.fill: parent }
+ MouseArea { anchors.fill: parent }
transform: Rotation {
id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2
diff --git a/tests/auto/declarative/visual/qmlmouseregion/drag.qml b/tests/auto/declarative/visual/qmlmouseregion/drag.qml
index ab4c280..dbb2a24 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/drag.qml
+++ b/tests/auto/declarative/visual/qmlmouseregion/drag.qml
@@ -8,7 +8,7 @@ Rectangle{
id: draggable
width:40; height:40; color: "lightsteelblue"
y:20
- MouseRegion{
+ MouseArea{
anchors.fill: parent
drag.target: draggable
drag.axis: "XandYAxis"
diff --git a/tests/auto/declarative/visual/qmlmouseregion/mouseregion.qml b/tests/auto/declarative/visual/qmlmouseregion/mouseregion.qml
index ab4223d..3c722d0 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/mouseregion.qml
+++ b/tests/auto/declarative/visual/qmlmouseregion/mouseregion.qml
@@ -9,7 +9,7 @@ Rectangle {
Rectangle {
width: 98; height: 48
color: "red"
- MouseRegion {
+ MouseArea {
id: mr1
anchors.fill: parent
enabled: false
@@ -22,7 +22,7 @@ Rectangle {
x: 100
width: 98; height: 48
color: "red"
- MouseRegion {
+ MouseArea {
id: mr2
anchors.fill: parent
acceptedButtons: Qt.RightButton
@@ -42,7 +42,7 @@ Rectangle {
x: 200
width: 98; height: 48
color: "red"
- MouseRegion {
+ MouseArea {
id: mr3
anchors.fill: parent
onPressAndHold: {
@@ -56,7 +56,7 @@ Rectangle {
x: 300
width: 98; height: 48
color: "red"
- MouseRegion {
+ MouseArea {
id: mr4
anchors.fill: parent
onPressed: {
@@ -74,7 +74,7 @@ Rectangle {
y: 50
width: 98; height: 48
color: "red"
- MouseRegion {
+ MouseArea {
id: mr5
anchors.fill: parent
hoverEnabled: true
@@ -93,7 +93,7 @@ Rectangle {
y: 50
width: 98; height: 48
color: "red"
- MouseRegion {
+ MouseArea {
id: mr6
anchors.fill: parent
onClicked: {
@@ -111,7 +111,7 @@ Rectangle {
y: 50
width: 98; height: 48
color: "red"
- MouseRegion {
+ MouseArea {
id: mr7
anchors.fill: parent
enabled: false
diff --git a/tests/auto/declarative/visual/qmlspringfollow/follow.qml b/tests/auto/declarative/visual/qmlspringfollow/follow.qml
index 8a713a2..a85a778 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/follow.qml
+++ b/tests/auto/declarative/visual/qmlspringfollow/follow.qml
@@ -44,7 +44,7 @@ Rectangle {
}
// Follow mouse
- MouseRegion {
+ MouseArea {
id: mouseRegion
anchors.fill: parent
Rectangle {
diff --git a/tests/auto/declarative/visual/selftest_noimages/selftest_noimages.qml b/tests/auto/declarative/visual/selftest_noimages/selftest_noimages.qml
index 21a19bc..da7f9b6 100644
--- a/tests/auto/declarative/visual/selftest_noimages/selftest_noimages.qml
+++ b/tests/auto/declarative/visual/selftest_noimages/selftest_noimages.qml
@@ -2,7 +2,7 @@ import Qt 4.6
Text {
property string error: "not pressed"
text: (new Date()).valueOf()
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onPressed: error=""
}
diff --git a/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml b/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml
index 2478932..72e672d 100644
--- a/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml
+++ b/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml
@@ -11,7 +11,7 @@ Grid {
anchors.fill: parent
settings.autoLoadImages: false
url: "test-img.html"
- MouseRegion {
+ MouseArea {
anchors.fill: parent
onClicked: { parent.settings.autoLoadImages=true; label.text=""; parent.reload.trigger() }
}
diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp
index 5c72c7a..07fdbc3 100644
--- a/tests/auto/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/qbytearray/tst_qbytearray.cpp
@@ -111,6 +111,7 @@ private slots:
void remove();
void replace_data();
void replace();
+ void replaceWithSpecifiedLength();
void indexOf_data();
void indexOf();
void lastIndexOf_data();
@@ -840,6 +841,18 @@ void tst_QByteArray::replace()
QCOMPARE(str2.replace(pos, len, after.data()), expected);
}
+void tst_QByteArray::replaceWithSpecifiedLength()
+{
+ const char after[] = "zxc\0vbnmqwert";
+ int lenAfter = 6;
+ QByteArray ba("abcdefghjk");
+ ba.replace(0,2,after,lenAfter);
+
+ const char _expected[] = "zxc\0vbcdefghjk";
+ QByteArray expected(_expected,sizeof(_expected)-1);
+ QCOMPARE(ba,expected);
+}
+
void tst_QByteArray::indexOf_data()
{
QTest::addColumn<QByteArray>("haystack");
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index d020d8f..66cfeb7 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -44,6 +44,7 @@
#include <QtCore/qpropertyanimation.h>
#include <QtCore/qvariantanimation.h>
#include <QtGui/qwidget.h>
+#include "../../shared/util.h"
//TESTED_CLASS=QPropertyAnimation
//TESTED_FILES=
@@ -1095,7 +1096,7 @@ void tst_QPropertyAnimation::valueChanged()
QTest::qWait(anim.duration() + 100);
- QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
+ QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped);
QCOMPARE(anim.currentTime(), anim.duration());
//let's check that the values go forward
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index e638e287..12686bb 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -191,6 +191,7 @@ private slots:
void increaseReadBufferSize();
void taskQtBug5799ConnectionErrorWaitForConnected();
void taskQtBug5799ConnectionErrorEventLoop();
+ void taskQtBug7054TimeoutErrorResetting();
void invalidProxy_data();
void invalidProxy();
@@ -2236,6 +2237,30 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorEventLoop()
QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
}
+void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting()
+{
+ QTcpSocket *socket = newSocket();
+
+ socket->connectToHost(QtNetworkSettings::serverName(), 443);
+ QVERIFY(socket->waitForConnected(5*1000));
+ QVERIFY(socket->error() == QAbstractSocket::UnknownSocketError);
+
+ // We connected to the HTTPS port. Wait two seconds to receive data. We will receive
+ // nothing because we would need to start the SSL handshake
+ QVERIFY(!socket->waitForReadyRead(2*1000));
+ QVERIFY(socket->error() == QAbstractSocket::SocketTimeoutError);
+
+ // Now write some crap to make the server disconnect us. 4 lines are enough.
+ socket->write("a\r\nb\r\nc\r\nd\r\n");
+ socket->waitForBytesWritten(2*1000);
+
+ // we try to waitForReadyRead another time, but this time instead of a timeout we
+ // should get a better error since the server disconnected us
+ QVERIFY(!socket->waitForReadyRead(2*1000));
+ // It must NOT be the SocketTimeoutError that had been set before
+ QVERIFY(socket->error() == QAbstractSocket::RemoteHostClosedError);
+}
+
void tst_QTcpSocket::invalidProxy_data()
{
QTest::addColumn<int>("type");
diff --git a/tests/auto/symbols/tst_symbols.cpp b/tests/auto/symbols/tst_symbols.cpp
index 70abc43..28970eb 100644
--- a/tests/auto/symbols/tst_symbols.cpp
+++ b/tests/auto/symbols/tst_symbols.cpp
@@ -211,6 +211,10 @@ void tst_Symbols::prefix()
<< "winfnt_driver_class"
<< "pshinter_module_class"
<< "psnames_module_class"
+ // C symbols from Qt
+ << "qt_addObject"
+ << "qt_removeObject"
+ << "qt_startup_hook"
;
QHash<QString,QStringList> excusedPrefixes;
@@ -278,6 +282,10 @@ void tst_Symbols::prefix()
<< "cti" // ctiTrampoline and ctiVMThrowTrampoline from the JIT
#ifdef QT_NAMESPACE
<< "QWeb" // Webkit is only 'namespace aware'
+ << "qWeb"
+ << "qt"
+ << "QGraphicsWebView"
+ << "operator"
#endif
;
@@ -330,6 +338,8 @@ void tst_Symbols::prefix()
symbol = symbol.mid(symbol.indexOf(' ') + 1);
}
+ if (symbol.mid(symbol.indexOf(' ')+1).startsWith("std::"))
+ continue;
if (symbol.startsWith("_") || symbol.startsWith("std::"))
continue;
if (symbol.startsWith("vtable ") || symbol.startsWith("VTT for ") ||
@@ -341,6 +351,8 @@ void tst_Symbols::prefix()
continue;
if (symbol.startsWith(ns + "operator"))
continue;
+ if (symbol.startsWith("operator new") || symbol.startsWith("operator delete"))
+ continue;
if (symbol.startsWith("guard variable for "))
continue;
if (symbol.contains("(" + ns + "QTextStream"))
diff --git a/tests/benchmarks/declarative/painting/paintbenchmark.cpp b/tests/benchmarks/declarative/painting/paintbenchmark.cpp
index 9231b67..073e14e 100644
--- a/tests/benchmarks/declarative/painting/paintbenchmark.cpp
+++ b/tests/benchmarks/declarative/painting/paintbenchmark.cpp
@@ -43,6 +43,7 @@
#include <QPixmap>
#include <QImage>
#include <QPainter>
+#include <QPainterPath>
#include <QGLWidget>
#include <QTextLayout>
#include <QVBoxLayout>
@@ -218,6 +219,28 @@ void paint_QPixmapCachedRoundedRect(QPainter &p)
}
}
+void paint_pathCacheRoundedRect(QPainter &p)
+{
+ static bool first = true;
+ static QPainterPath path[lines];
+ if (first) {
+ for (int j = 0; j < lines; ++j) {
+ path[j].addRoundedRect(QRectF(0,0,(j+1)*50, spacing-1), 8, 8);
+ }
+ first = false;
+ }
+ p.setRenderHint(QPainter::Antialiasing, true);
+ p.setPen(Qt::black);
+ p.setBrush(Qt::red);
+ for (int i = 0; i < count; i++) {
+ for (int j = 0; j < lines; ++j) {
+ p.translate(0,j*spacing);
+ p.drawPath(path[j]);
+ p.translate(0,-j*spacing);
+ }
+ }
+}
+
void paint_QPixmap63x63_opaque(QPainter &p)
{
static bool first = true;
@@ -290,6 +313,7 @@ struct {
{ "CachedText", &paint_QPixmapCachedText },
{ "RoundedRect", &paint_RoundedRect },
{ "CachedRoundedRect", &paint_QPixmapCachedRoundedRect },
+ { "PathCacheRoundedRect", &paint_pathCacheRoundedRect },
{ "QPixmap63x63_opaque", &paint_QPixmap63x63_opaque },
{ "QPixmap64x64_opaque", &paint_QPixmap64x64_opaque },
{ "QPixmap63x63", &paint_QPixmap63x63 },
diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml
index 210c515..996602c 100644
--- a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml
@@ -24,7 +24,7 @@ Item {
Text { },
Text { },
Text { },
- MouseRegion { }
+ MouseArea { }
]
}
diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml
index 943634f..9f79c34 100644
--- a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml
@@ -24,7 +24,7 @@ Item {
Text { },
Text { },
Text { },
- MouseRegion { }
+ MouseArea { }
]
}
diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml
index ce986b5..335aeb8 100644
--- a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml
@@ -24,7 +24,7 @@ Item {
Text { },
Text { },
Text { },
- MouseRegion { }
+ MouseArea { }
]
}
diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml
index 25e9c62..97bad47 100644
--- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml
@@ -30,7 +30,7 @@ Item {
Text { }
}
}
- MouseRegion { }
+ 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
index ee3f9d1..36dda15 100644
--- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml
@@ -27,7 +27,7 @@ Item {
Text { }
Text { }
}
- MouseRegion { }
+ MouseArea { }
}
}
}
diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml
index 4c46ec1..396e27d 100644
--- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml
+++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml
@@ -30,7 +30,7 @@ Item {
Text { }
}
}
- MouseRegion { }
+ MouseArea { }
}
}
}
diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp
index c8655a4..d9e9c3b 100644
--- a/tools/qdoc3/cppcodeparser.cpp
+++ b/tools/qdoc3/cppcodeparser.cpp
@@ -1033,7 +1033,10 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc,
#ifdef QDOC_QML
else if (command == COMMAND_QMLINHERITS) {
setLink(node, Node::InheritsLink, arg);
- }
+ if (node->subType() == Node::QmlClass) {
+ QmlClassNode::addInheritedBy(arg,node);
+ }
+ }
else if (command == COMMAND_QMLDEFAULT) {
QmlPropGroupNode* qpgn = static_cast<QmlPropGroupNode*>(node);
qpgn->setDefault();
@@ -2299,14 +2302,6 @@ void CppCodeParser::createExampleFileNodes(FakeNode *fake)
QString imagesPath = fullPath + "/images";
QStringList imageFiles = Config::getFilesHere(imagesPath,exampleImageFilter);
-#if 0
- qDebug() << "examplePath:" << examplePath;
- qDebug() << " exampleFiles" << exampleFiles;
- qDebug() << "imagesPath:" << imagesPath;
- qDebug() << "fullPath:" << fullPath;
- qDebug() << " imageFiles" << imageFiles;
-#endif
-
if (!exampleFiles.isEmpty()) {
// move main.cpp and to the end, if it exists
QString mainCpp;
diff --git a/tools/qdoc3/generator.cpp b/tools/qdoc3/generator.cpp
index 9b58d7f..a7ab453 100644
--- a/tools/qdoc3/generator.cpp
+++ b/tools/qdoc3/generator.cpp
@@ -641,33 +641,6 @@ void Generator::generateExampleFiles(const FakeNode *fake, CodeMarker *marker)
}
#endif
-void Generator::generateModuleWarning(const ClassNode *classe,
- CodeMarker *marker)
-{
- QString module = classe->moduleName();
- if (!module.isEmpty()) {
- Text text;
- if (!editionModuleMap["DesktopLight"].contains(module)) {
- text << Atom::ParaLeft
- << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
- << "This class is not part of the Qt GUI Framework Edition."
- << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD)
- << Atom::ParaRight;
- }
- else if (module == "Qt3Support") {
- text << Atom::ParaLeft
- << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
- << "Note to Qt GUI Framework Edition users:"
- << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD)
- << " This class is only available in the "
- << Atom(Atom::AutoLink, "Qt Full Framework Edition")
- << "." << Atom::ParaRight;
- }
-
- generateText(text, classe, marker);
- }
-}
-
QString Generator::indent(int level, const QString& markedCode)
{
if (level == 0)
@@ -1213,6 +1186,32 @@ void Generator::appendSortedNames(Text& text,
}
}
+void Generator::appendSortedNames(Text& text,
+ const Node* base,
+ const NodeList& subs,
+ CodeMarker *marker)
+{
+ NodeList::ConstIterator r;
+ QMap<QString,Text> classMap;
+ int index = 0;
+
+ r = subs.begin();
+ while (r != subs.end()) {
+ Text className;
+ appendFullName(className, (*r), base, marker);
+ classMap[className.toString().toLower()] = className;
+ ++r;
+ }
+
+ QStringList classNames = classMap.keys();
+ classNames.sort();
+
+ foreach (const QString &className, classNames) {
+ text << classMap[className];
+ text << separator(index++, classNames.count());
+ }
+}
+
int Generator::skipAtoms(const Atom *atom, Atom::Type type) const
{
int skipAhead = 0;
diff --git a/tools/qdoc3/generator.h b/tools/qdoc3/generator.h
index 06f7f88..50ffb0a 100644
--- a/tools/qdoc3/generator.h
+++ b/tools/qdoc3/generator.h
@@ -124,7 +124,6 @@ class Generator
Node::SubType subtype,
const QString& tag);
void generateExampleFiles(const FakeNode *fake, CodeMarker *marker);
- void generateModuleWarning(const ClassNode *classe, CodeMarker *marker);
virtual int skipAtoms(const Atom *atom, Atom::Type type) const;
virtual QString fullName(const Node *node,
@@ -170,6 +169,13 @@ class Generator
const QList<RelatedClass> &classes,
CodeMarker *marker);
+ protected:
+ void appendSortedNames(Text& text,
+ const Node* base,
+ const NodeList& subs,
+ CodeMarker *marker);
+
+ private:
QString amp;
QString lt;
QString gt;
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index e341a03..0477ebb 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -73,6 +73,7 @@ QString HtmlGenerator::sinceTitles[] =
" New Typedefs",
" New Properties",
" New Variables",
+ " New QML Elements",
" New Qml Properties",
" New Qml Signals",
" New Qml Methods",
@@ -687,6 +688,8 @@ int HtmlGenerator::generateAtom(const Atom *atom,
nsmap = newSinceMaps.find(atom->string());
NewClassMaps::const_iterator ncmap;
ncmap = newClassMaps.find(atom->string());
+ NewClassMaps::const_iterator nqcmap;
+ nqcmap = newQmlClassMaps.find(atom->string());
if ((nsmap != newSinceMaps.constEnd()) && !nsmap.value().isEmpty()) {
QList<Section> sections;
QList<Section>::ConstIterator s;
@@ -697,6 +700,10 @@ int HtmlGenerator::generateAtom(const Atom *atom,
while (n != nsmap.value().constEnd()) {
const Node* node = n.value();
switch (node->type()) {
+ case Node::Fake:
+ if (node->subType() == Node::QmlClass)
+ sections[QmlClass].appendMember((Node*)node);
+ break;
case Node::Namespace:
sections[Namespace].appendMember((Node*)node);
break;
@@ -782,6 +789,8 @@ int HtmlGenerator::generateAtom(const Atom *atom,
out() << "<h3>" << protectEnc((*s).name) << "</h3>\n";
if (idx == Class)
generateCompactList(0, marker, ncmap.value(), QString("Q"));
+ else if (idx == QmlClass)
+ generateCompactList(0, marker, nqcmap.value(), QString("Q"));
else if (idx == MemberFunction) {
ParentMaps parentmaps;
ParentMaps::iterator pmap;
@@ -1261,7 +1270,6 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner,
generateIncludes(inner, marker);
generateStatus(inner, marker);
if (classe) {
- generateModuleWarning(classe, marker);
generateInherits(classe, marker);
generateInheritedBy(classe, marker);
}
@@ -1525,6 +1533,7 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker)
generateQmlInherits(qml_cn, marker);
generateQmlInstantiates(qml_cn, marker);
generateBrief(qml_cn, marker);
+ generateQmlInheritedBy(qml_cn, marker);
sections = marker->qmlSections(qml_cn,CodeMarker::Summary);
s = sections.begin();
while (s != sections.end()) {
@@ -2332,7 +2341,11 @@ void HtmlGenerator::generateCompactList(const Node *relative,
out() << "<a href=\""
<< linkForNode(it.value(), relative)
<< "\">";
- QStringList pieces = fullName(it.value(), relative, marker).split("::");
+ QStringList pieces;
+ if (it.value()->subType() == Node::QmlClass)
+ pieces << it.value()->name();
+ else
+ pieces = fullName(it.value(), relative, marker).split("::");
out() << protectEnc(pieces.last());
out() << "</a>";
if (pieces.size() > 1) {
@@ -3723,6 +3736,9 @@ void HtmlGenerator::findAllSince(const InnerNode *node)
NewClassMaps::iterator ncmap = newClassMaps.find(sinceVersion);
if (ncmap == newClassMaps.end())
ncmap = newClassMaps.insert(sinceVersion,NodeMap());
+ NewClassMaps::iterator nqcmap = newQmlClassMaps.find(sinceVersion);
+ if (nqcmap == newQmlClassMaps.end())
+ nqcmap = newQmlClassMaps.insert(sinceVersion,NodeMap());
if ((*child)->type() == Node::Function) {
FunctionNode *func = static_cast<FunctionNode *>(*child);
@@ -3742,6 +3758,15 @@ void HtmlGenerator::findAllSince(const InnerNode *node)
nsmap.value().insert(className,(*child));
ncmap.value().insert(className,(*child));
}
+ else if ((*child)->subType() == Node::QmlClass) {
+ QString className = (*child)->name();
+ if ((*child)->parent() &&
+ (*child)->parent()->type() == Node::Namespace &&
+ !(*child)->parent()->name().isEmpty())
+ className = (*child)->parent()->name()+"::"+className;
+ nsmap.value().insert(className,(*child));
+ nqcmap.value().insert(className,(*child));
+ }
}
else {
QString name = (*child)->name();
@@ -4309,6 +4334,26 @@ void HtmlGenerator::generateQmlInherits(const QmlClassNode* cn,
}
/*!
+ Output the "Inherit by" list for the QML element,
+ if it is inherited by any other elements.
+ */
+void HtmlGenerator::generateQmlInheritedBy(const QmlClassNode* cn,
+ CodeMarker* marker)
+{
+ if (cn) {
+ NodeList subs;
+ QmlClassNode::subclasses(cn->name(),subs);
+ if (!subs.isEmpty()) {
+ Text text;
+ text << Atom::ParaLeft << "Inherited by ";
+ appendSortedNames(text,cn,subs,marker);
+ text << Atom::ParaRight;
+ generateText(text, cn, marker);
+ }
+ }
+}
+
+/*!
Output the "[Xxx instantiates the C++ class QmlGraphicsXxx]"
line for the QML element, if there should be one.
diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h
index 369d6c3..8fe0331 100644
--- a/tools/qdoc3/htmlgenerator.h
+++ b/tools/qdoc3/htmlgenerator.h
@@ -90,6 +90,7 @@ class HtmlGenerator : public PageGenerator
Typedef,
Property,
Variable,
+ QmlClass,
QmlProperty,
QmlSignal,
QmlMethod,
@@ -185,6 +186,7 @@ class HtmlGenerator : public PageGenerator
const InnerNode *relative,
CodeMarker *marker);
void generateQmlInherits(const QmlClassNode* cn, CodeMarker* marker);
+ void generateQmlInheritedBy(const QmlClassNode* cn, CodeMarker* marker);
void generateQmlInstantiates(const QmlClassNode* qcn, CodeMarker* marker);
void generateInstantiatedBy(const ClassNode* cn, CodeMarker* marker);
#endif
@@ -325,6 +327,7 @@ class HtmlGenerator : public PageGenerator
NewSinceMaps newSinceMaps;
static QString sinceTitles[];
NewClassMaps newClassMaps;
+ NewClassMaps newQmlClassMaps;
static int id;
};
diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp
index ec574f8..5357597 100644
--- a/tools/qdoc3/node.cpp
+++ b/tools/qdoc3/node.cpp
@@ -1257,6 +1257,7 @@ bool TargetNode::isInnerNode() const
#ifdef QDOC_QML
bool QmlClassNode::qmlOnly = false;
+QMultiMap<QString,Node*> QmlClassNode::inheritedBy;
/*!
Constructs a Qml class node (i.e. a Fake node with the
@@ -1290,6 +1291,25 @@ QString QmlClassNode::fileBase() const
}
/*!
+ Record the fact that QML class \a base is inherited by
+ QML class \a sub.
+ */
+void QmlClassNode::addInheritedBy(const QString& base, Node* sub)
+{
+ inheritedBy.insert(base,sub);
+}
+
+/*!
+ Loads the list \a subs with the nodes of all the subclasses of \a base.
+ */
+void QmlClassNode::subclasses(const QString& base, NodeList& subs)
+{
+ subs.clear();
+ if (inheritedBy.contains(base))
+ subs = inheritedBy.values(base);
+}
+
+/*!
Constructs a Qml basic type node (i.e. a Fake node with
the subtype QmlBasicType. The new node has the given
\a parent and \a name.
diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h
index 021a052..3798e4e 100644
--- a/tools/qdoc3/node.h
+++ b/tools/qdoc3/node.h
@@ -383,11 +383,15 @@ class QmlClassNode : public FakeNode
const ClassNode* classNode() const { return cnode; }
virtual QString fileBase() const;
+ static void addInheritedBy(const QString& base, Node* sub);
+ static void subclasses(const QString& base, NodeList& subs);
+ public:
static bool qmlOnly;
+ static QMultiMap<QString,Node*> inheritedBy;
private:
- const ClassNode* cnode;
+ const ClassNode* cnode;
};
class QmlBasicTypeNode : public FakeNode
diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf
index 555e826..fb2c3c1 100644
--- a/tools/qdoc3/test/qt-build-docs.qdocconf
+++ b/tools/qdoc3/test/qt-build-docs.qdocconf
@@ -12,14 +12,6 @@ sourceencoding = UTF-8
outputencoding = UTF-8
naturallanguage = en_US
-edition.Desktop.modules = QtCore QtDBus QtGui QtNetwork QtOpenGL QtScript \
- QtScriptTools QtSql QtSvg QtWebKit QtXml QtXmlPatterns \
- Qt3Support QtHelp QtDesigner QtAssistant QAxContainer Phonon \
- QAxServer QtUiTools QtTest QtDBus
-
-edition.DesktopLight.modules = QtCore QtDBus QtGui Qt3SupportLight QtTest
-edition.DesktopLight.groups = -graphicsview-api
-
qhp.projects = Qt
qhp.Qt.file = qt.qhp
diff --git a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf
index 18b72a1..7a77f54 100644
--- a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf
+++ b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf
@@ -14,14 +14,6 @@ naturallanguage = zh-Hans
indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index
-edition.Desktop.modules = QtCore QtDBus QtGui QtNetwork QtOpenGL QtScript \
- QtScriptTools QtSql QtSvg QtWebKit QtXml QtXmlPatterns \
- Qt3Support QtHelp QtDesigner QtAssistant QAxContainer Phonon \
- QAxServer QtUiTools QtTest QtDBus
-
-edition.DesktopLight.modules = QtCore QtDBus QtGui Qt3SupportLight QtTest
-edition.DesktopLight.groups = -graphicsview-api
-
qhp.projects = Qt
qhp.Qt.file = qt.qhp
diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf
index f7757fb..d8b9136 100644
--- a/tools/qdoc3/test/qt.qdocconf
+++ b/tools/qdoc3/test/qt.qdocconf
@@ -14,13 +14,6 @@ sourceencoding = UTF-8
outputencoding = UTF-8
naturallanguage = en_US
-edition.Desktop.modules = QtCore QtDBus QtGui QtNetwork QtOpenGL QtScript \
- QtScriptTools QtSql QtSvg QtWebKit QtXml QtXmlPatterns \
- Qt3Support QtHelp QtDesigner QtAssistant QAxContainer Phonon \
- QAxServer QtUiTools QtTest QtDBus
-edition.DesktopLight.modules = QtCore QtDBus QtGui Qt3SupportLight QtTest
-edition.DesktopLight.groups = -graphicsview-api
-
qhp.projects = Qt
qhp.Qt.file = qt.qhp
diff --git a/tools/qmlviewer/content/Browser.qml b/tools/qmlviewer/content/Browser.qml
index 446045b..35120bc 100644
--- a/tools/qmlviewer/content/Browser.qml
+++ b/tools/qmlviewer/content/Browser.qml
@@ -90,7 +90,7 @@ Rectangle {
font.pixelSize: 32
color: (wrapper.ListView.isCurrentItem && root.keyPressed) ? palette.highlightedText : palette.windowText
}
- MouseRegion {
+ MouseArea {
id: mouseRegion
anchors.fill: parent
onClicked: { launch() }
@@ -211,7 +211,7 @@ Rectangle {
color: "transparent"
Image { anchors.centerIn: parent; source: "images/up.png" }
- MouseRegion { id: upRegion; anchors.centerIn: parent
+ MouseArea { id: upRegion; anchors.centerIn: parent
width: 56
height: 56
onClicked: if (folders.parentFolder != "") up()