aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cmake.conf2
-rw-r--r--cmake/QtDeclarativeSetup.cmake2
-rw-r--r--coin/module_config.yaml6
-rw-r--r--dependencies.yaml10
-rw-r--r--examples/qml/doc/src/qml-extending.qdoc6
-rw-r--r--examples/qml/dynamicscene/dynamicscene.qml2
-rw-r--r--examples/qml/locale/locale.qml31
-rw-r--r--examples/qml/networkaccessmanagerfactory/view.qml2
-rw-r--r--examples/qml/qml-i18n/qml-i18n.qml4
-rw-r--r--examples/qml/qmlextensionplugins/imports/TimeExample/Clock.qml2
-rw-r--r--examples/qml/qmlextensionplugins/plugins.qml2
-rw-r--r--examples/qml/referenceexamples/adding/example.qml2
-rw-r--r--examples/qml/referenceexamples/attached/example.qml4
-rw-r--r--examples/qml/referenceexamples/binding/example.qml4
-rw-r--r--examples/qml/referenceexamples/coercion/example.qml2
-rw-r--r--examples/qml/referenceexamples/default/example.qml2
-rw-r--r--examples/qml/referenceexamples/extended/example.qml2
-rw-r--r--examples/qml/referenceexamples/grouped/example.qml4
-rw-r--r--examples/qml/referenceexamples/methods/example.qml4
-rw-r--r--examples/qml/referenceexamples/properties/example.qml2
-rw-r--r--examples/qml/referenceexamples/signal/example.qml4
-rw-r--r--examples/qml/referenceexamples/valuesource/example.qml4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt1
-rw-r--r--examples/qml/tutorials/extending-qml/chapter1-basics/app.qml4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt1
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/app.qml4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt1
-rw-r--r--examples/qml/tutorials/extending-qml/chapter3-bindings/app.qml4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt1
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/app.qml4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt1
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/app.qml4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h6
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt3
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.h4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.h6
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/app.qml4
-rw-r--r--examples/qmltest/qmltest/tst_basic.qml4
-rw-r--r--examples/qmltest/qmltest/tst_item.qml4
-rw-r--r--examples/quick/animation/animation.qml2
-rw-r--r--examples/quick/animation/basics/animators.qml2
-rw-r--r--examples/quick/animation/basics/color-animation.qml4
-rw-r--r--examples/quick/animation/basics/property-animation.qml4
-rw-r--r--examples/quick/animation/behaviors/FocusRect.qml2
-rw-r--r--examples/quick/animation/behaviors/SideRect.qml2
-rw-r--r--examples/quick/animation/behaviors/behavior-example.qml2
-rw-r--r--examples/quick/animation/behaviors/tvtennis.qml2
-rw-r--r--examples/quick/animation/behaviors/wigglytext.qml4
-rw-r--r--examples/quick/animation/easing/easing.qml6
-rw-r--r--examples/quick/animation/pathanimation/pathanimation.qml4
-rw-r--r--examples/quick/animation/pathinterpolator/pathinterpolator.qml4
-rw-r--r--examples/quick/animation/states/states.qml4
-rw-r--r--examples/quick/animation/states/transitions.qml2
-rw-r--r--examples/quick/customitems/dialcontrol/Dial.qml2
-rw-r--r--examples/quick/customitems/dialcontrol/QuitButton.qml2
-rw-r--r--examples/quick/customitems/dialcontrol/dialcontrol.qml4
-rw-r--r--examples/quick/customitems/maskedmousearea/maskedmousearea.qml4
-rw-r--r--examples/quick/customitems/painteditem/textballoons.qml4
-rw-r--r--examples/quick/customitems/progressbar/content/ProgressBar.qml2
-rw-r--r--examples/quick/customitems/progressbar/main.qml2
-rw-r--r--examples/quick/customitems/scrollbar/ScrollBar.qml2
-rw-r--r--examples/quick/customitems/scrollbar/main.qml2
-rw-r--r--examples/quick/customitems/searchbox/SearchBox.qml2
-rw-r--r--examples/quick/customitems/searchbox/main.qml2
-rw-r--r--examples/quick/customitems/slideswitch/content/Switch.qml2
-rw-r--r--examples/quick/customitems/slideswitch/slideswitch.qml2
-rw-r--r--examples/quick/customitems/spinner/content/Spinner.qml2
-rw-r--r--examples/quick/customitems/spinner/main.qml2
-rw-r--r--examples/quick/customitems/tabwidget/TabWidget.qml2
-rw-r--r--examples/quick/customitems/tabwidget/main.qml2
-rw-r--r--examples/quick/delegatechooser/delegatechooser.qml8
-rw-r--r--examples/quick/draganddrop/tiles/DragTile.qml2
-rw-r--r--examples/quick/draganddrop/tiles/DropTile.qml14
-rw-r--r--examples/quick/draganddrop/tiles/tiles.qml2
-rw-r--r--examples/quick/draganddrop/views/Icon.qml2
-rw-r--r--examples/quick/imageprovider/imageprovider-example.qml2
-rw-r--r--examples/quick/imageresponseprovider/imageresponseprovider-example.qml2
-rw-r--r--examples/quick/models/stringlistmodel/view.qml2
-rw-r--r--examples/quick/particles/affectors/GreyButton.qml2
-rw-r--r--examples/quick/particles/affectors/move.qml4
-rw-r--r--examples/quick/particles/emitters/burstandpulse.qml4
-rw-r--r--examples/quick/particles/emitters/customemitter.qml4
-rw-r--r--examples/quick/particles/emitters/emitmask.qml4
-rw-r--r--examples/quick/particles/emitters/maximumemitted.qml4
-rw-r--r--examples/quick/particles/emitters/shapeanddirection.qml4
-rw-r--r--examples/quick/particles/emitters/trailemitter.qml4
-rw-r--r--examples/quick/particles/emitters/velocityfrommotion.qml4
-rw-r--r--examples/quick/pointerhandlers/components/FlashAnimation.qml8
-rw-r--r--examples/quick/pointerhandlers/map.qml2
-rw-r--r--examples/quick/pointerhandlers/pinchHandler.qml2
-rw-r--r--examples/quick/pointerhandlers/sidebar.qml121
-rw-r--r--examples/quick/quick-accessibility/Button.qml2
-rw-r--r--examples/quick/quick-accessibility/Checkbox.qml2
-rw-r--r--examples/quick/quick-accessibility/Slider.qml2
-rw-r--r--examples/quick/quickwidgets/qquickwidgetversuswindow_opengl/test.qml6
-rw-r--r--examples/quick/quickwidgets/quickwidget/rotatingsquare.qml2
-rw-r--r--examples/quick/scenegraph/customgeometry/main.qml4
-rw-r--r--examples/quick/scenegraph/custommaterial/main.qml4
-rw-r--r--examples/quick/scenegraph/d3d11underqml/main.qml4
-rw-r--r--examples/quick/scenegraph/fboitem/main.qml4
-rw-r--r--examples/quick/scenegraph/graph/main.qml4
-rw-r--r--examples/quick/scenegraph/graph/noisynode.cpp1
-rw-r--r--examples/quick/scenegraph/metaltextureimport/main.qml4
-rw-r--r--examples/quick/scenegraph/metalunderqml/main.qml4
-rw-r--r--examples/quick/scenegraph/openglunderqml/main.qml4
-rw-r--r--examples/quick/scenegraph/threadedanimation/main.qml4
-rw-r--r--examples/quick/scenegraph/twotextureproviders/main.qml4
-rw-r--r--examples/quick/scenegraph/vulkantextureimport/main.qml4
-rw-r--r--examples/quick/scenegraph/vulkanunderqml/main.qml4
-rw-r--r--examples/quick/shared/Button.qml4
-rw-r--r--examples/quick/shared/CheckBox.qml2
-rw-r--r--examples/quick/shared/FlickrRssModel.qml2
-rw-r--r--examples/quick/shared/Label.qml2
-rw-r--r--examples/quick/shared/LauncherList.qml6
-rw-r--r--examples/quick/shared/SimpleLauncherDelegate.qml2
-rw-r--r--examples/quick/shared/Slider.qml2
-rw-r--r--examples/quick/shared/TabSet.qml4
-rw-r--r--examples/quick/shared/TextField.qml2
-rw-r--r--examples/quick/tableview/gameoflife/main.qml12
-rw-r--r--examples/quick/tableview/pixelator/main.qml6
-rw-r--r--examples/quick/text/fonts/availableFonts.qml2
-rw-r--r--examples/quick/text/fonts/banner.qml2
-rw-r--r--examples/quick/text/fonts/fonts.qml2
-rw-r--r--examples/quick/text/fonts/hello.qml2
-rw-r--r--examples/quick/text/imgtag/TextWithImage.qml2
-rw-r--r--examples/quick/text/imgtag/imgtag.qml2
-rw-r--r--examples/quick/text/styledtext-layout.qml2
-rw-r--r--examples/quick/text/text.qml2
-rw-r--r--examples/quick/text/textselection/textselection.qml2
-rw-r--r--examples/quick/threading/threadedlistmodel/timedisplay.qml2
-rw-r--r--examples/quick/threading/threading.qml2
-rw-r--r--examples/quick/threading/workerscript/Spinner.qml2
-rw-r--r--examples/quick/threading/workerscript/workerscript.qml2
-rw-r--r--examples/quick/touchinteraction/flickable/Panel.qml2
-rw-r--r--examples/quick/touchinteraction/flickable/basic-flickable.qml2
-rw-r--r--examples/quick/touchinteraction/flickable/corkboards.qml2
-rw-r--r--examples/quick/touchinteraction/multipointtouch/AugmentedTouchPoint.qml4
-rw-r--r--examples/quick/touchinteraction/multipointtouch/BearWhackParticleSystem.qml4
-rw-r--r--examples/quick/touchinteraction/multipointtouch/ParticleFlame.qml4
-rw-r--r--examples/quick/touchinteraction/multipointtouch/bearwhack.qml4
-rw-r--r--examples/quick/touchinteraction/multipointtouch/multiflame.qml2
-rw-r--r--examples/quick/touchinteraction/pincharea/flickresize.qml2
-rw-r--r--examples/quick/touchinteraction/touchinteraction.qml2
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview1/PetsModel.qml2
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview1/dynamicview.qml10
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview2/PetsModel.qml2
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview2/dynamicview.qml2
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview3/PetsModel.qml2
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml4
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview4/ListSelector.qml2
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview4/PetsModel.qml2
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml4
-rw-r--r--examples/quick/tutorials/helloworld/Cell.qml2
-rw-r--r--examples/quick/tutorials/helloworld/tutorial1.qml2
-rw-r--r--examples/quick/tutorials/helloworld/tutorial2.qml2
-rw-r--r--examples/quick/tutorials/helloworld/tutorial3.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame1/Block.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame1/Button.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame1/samegame.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame2/Block.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame2/Button.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame2/samegame.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame3/Block.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame3/Button.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame3/Dialog.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame3/samegame.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame4/BoomBlock.qml4
-rw-r--r--examples/quick/tutorials/samegame/samegame4/Button.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame4/Dialog.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame4/samegame.qml2
-rw-r--r--examples/quick/views/delegatemodel/dragselection.qml6
-rw-r--r--examples/quick/views/delegatemodel/slideshow.qml4
-rw-r--r--examples/quick/views/gridview/gridview-example.qml2
-rw-r--r--examples/quick/views/listview/content/PetsModel.qml2
-rw-r--r--examples/quick/views/listview/content/PressAndHoldButton.qml2
-rw-r--r--examples/quick/views/listview/content/RecipesModel.qml2
-rw-r--r--examples/quick/views/listview/content/SmallText.qml2
-rw-r--r--examples/quick/views/listview/content/TextButton.qml2
-rw-r--r--examples/quick/views/listview/content/ToggleButton.qml2
-rw-r--r--examples/quick/views/listview/displaymargin.qml2
-rw-r--r--examples/quick/views/listview/dynamiclist.qml2
-rw-r--r--examples/quick/views/listview/expandingdelegates.qml2
-rw-r--r--examples/quick/views/listview/highlight.qml2
-rw-r--r--examples/quick/views/listview/highlightranges.qml2
-rw-r--r--examples/quick/views/listview/sections.qml2
-rw-r--r--examples/quick/views/objectmodel/objectmodel.qml4
-rw-r--r--examples/quick/views/package/Delegate.qml2
-rw-r--r--examples/quick/views/package/view.qml4
-rw-r--r--examples/quick/views/pathview/pathview-example.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter1/chapter1.pro5
-rw-r--r--examples/quickcontrols2/chattutorial/chapter2/chapter2.pro6
-rw-r--r--examples/quickcontrols2/chattutorial/chapter3/chapter3.pro6
-rw-r--r--examples/quickcontrols2/chattutorial/chapter4/chapter4.pro6
-rw-r--r--examples/quickcontrols2/chattutorial/chapter5/chapter5.pro6
-rw-r--r--examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc2
-rw-r--r--examples/quickcontrols2/contactlist/CMakeLists.txt39
-rw-r--r--examples/quickcontrols2/contactlist/contactlist.qml2
-rw-r--r--examples/quickcontrols2/eventcalendar/doc/src/qtquickcontrols2-eventcalendar.qdoc2
-rw-r--r--examples/quickcontrols2/flatstyle/CMakeLists.txt44
-rw-r--r--examples/quickcontrols2/gallery/CMakeLists.txt142
-rw-r--r--examples/quickcontrols2/imagine/automotive/CMakeLists.txt273
-rw-r--r--examples/quickcontrols2/imagine/musicplayer/CMakeLists.txt346
-rw-r--r--examples/quickcontrols2/ios/todolist/AppSettings.qml14
-rw-r--r--examples/quickcontrols2/ios/todolist/CMakeLists.txt84
-rw-r--r--examples/quickcontrols2/ios/todolist/Database.qml161
-rw-r--r--examples/quickcontrols2/ios/todolist/FontSizePage.qml44
-rw-r--r--examples/quickcontrols2/ios/todolist/HomePage.qml173
-rw-r--r--examples/quickcontrols2/ios/todolist/MaxTasksPage.qml36
-rw-r--r--examples/quickcontrols2/ios/todolist/NavBar.qml44
-rw-r--r--examples/quickcontrols2/ios/todolist/ProjectPage.qml256
-rw-r--r--examples/quickcontrols2/ios/todolist/SettingsPage.qml68
-rw-r--r--examples/quickcontrols2/ios/todolist/ToggleCompletedTasksPage.qml34
-rw-r--r--examples/quickcontrols2/ios/todolist/doc/images/qtquickcontrols2-todolist.pngbin0 -> 67497 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/doc/src/qtquickcontrols2-todolist.qdoc22
-rw-r--r--examples/quickcontrols2/ios/todolist/images/add-new.pngbin0 -> 312 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/add-new@2x.pngbin0 -> 569 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/add-new@3x.pngbin0 -> 1406 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/back-white.pngbin0 -> 201 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/back-white@2x.pngbin0 -> 290 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/back-white@3x.pngbin0 -> 730 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/back.pngbin0 -> 201 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/back@2x.pngbin0 -> 290 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/back@3x.pngbin0 -> 730 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/close-white.pngbin0 -> 319 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/close-white@2x.pngbin0 -> 459 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/close-white@3x.pngbin0 -> 707 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/close.pngbin0 -> 319 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/close@2x.pngbin0 -> 459 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/close@3x.pngbin0 -> 707 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/plus-math.pngbin0 -> 115 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/plus-math@2x.pngbin0 -> 120 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/plus-math@3x.pngbin0 -> 382 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/settings.pngbin0 -> 1399 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/settings@2x.pngbin0 -> 2878 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/images/settings@3x.pngbin0 -> 5929 bytes
-rw-r--r--examples/quickcontrols2/ios/todolist/main.qml32
-rw-r--r--examples/quickcontrols2/ios/todolist/qmldir2
-rw-r--r--examples/quickcontrols2/ios/todolist/src/main.cpp32
-rw-r--r--examples/quickcontrols2/ios/todolist/todolist.pro42
-rw-r--r--examples/quickcontrols2/sidepanel/CMakeLists.txt42
-rw-r--r--examples/quickcontrols2/swipetoremove/CMakeLists.txt32
-rw-r--r--examples/quickcontrols2/swipetoremove/swipetoremove.pro7
-rw-r--r--examples/quickcontrols2/texteditor/CMakeLists.txt42
-rw-r--r--examples/quickcontrols2/texteditor/documenthandler.cpp69
-rw-r--r--examples/quickcontrols2/texteditor/documenthandler.h16
-rw-r--r--examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml3
-rw-r--r--examples/quickcontrols2/texteditor/qml/texteditor.qml32
-rw-r--r--examples/quickcontrols2/texteditor/qtquickcontrols2.conf11
-rw-r--r--examples/quickcontrols2/texteditor/texteditor.qrc1
-rw-r--r--src/3rdparty/masm/assembler/ARM64Assembler.h4
-rw-r--r--src/3rdparty/masm/assembler/ARMv7Assembler.h4
-rw-r--r--src/3rdparty/masm/wtf/OSAllocatorPosix.cpp2
-rw-r--r--src/3rdparty/masm/wtf/Platform.h1
-rw-r--r--src/3rdparty/masm/yarr/YarrInterpreter.cpp4
-rw-r--r--src/3rdparty/masm/yarr/YarrParser.h2
-rw-r--r--src/CMakeLists.txt10
-rw-r--r--src/labs/animation/qquickboundaryrule.cpp4
-rw-r--r--src/labs/folderlistmodel/fileinfothread.cpp2
-rw-r--r--src/labs/folderlistmodel/qquickfolderlistmodel.cpp2
-rw-r--r--src/labs/models/qqmldelegatecomponent.cpp4
-rw-r--r--src/labs/models/qqmltablemodel.cpp2
-rw-r--r--src/labs/platform/doc/qtlabsplatform.qdocconf2
-rw-r--r--src/labs/platform/qquicklabsplatformdialog_p.h2
-rw-r--r--src/labs/platform/qquicklabsplatformfiledialog.cpp2
-rw-r--r--src/labs/platform/qquicklabsplatformfolderdialog.cpp1
-rw-r--r--src/labs/platform/qquicklabsplatformmenu.cpp16
-rw-r--r--src/labs/platform/qquicklabsplatformmenubar.cpp13
-rw-r--r--src/labs/platform/qquicklabsplatformmenuitem.cpp75
-rw-r--r--src/labs/platform/qquicklabsplatformmenuitem_p.h3
-rw-r--r--src/labs/platform/qquicklabsplatformmenuitemgroup.cpp10
-rw-r--r--src/labs/platform/qquicklabsplatformstandardpaths.cpp7
-rw-r--r--src/labs/platform/qquicklabsplatformstandardpaths_p.h4
-rw-r--r--src/labs/platform/widgets/qwidgetplatformfiledialog.cpp2
-rw-r--r--src/labs/platform/widgets/qwidgetplatformmenu.cpp5
-rw-r--r--src/labs/sharedimage/qsharedimageprovider.cpp2
-rw-r--r--src/labs/wavefrontmesh/qwavefrontmesh.cpp4
-rw-r--r--src/particles/qquickcustomaffector.cpp6
-rw-r--r--src/particles/qquickimageparticle.cpp27
-rw-r--r--src/particles/qquickimageparticle_p.h2
-rw-r--r--src/particles/qquickitemparticle.cpp8
-rw-r--r--src/particles/qquickmaskextruder.cpp4
-rw-r--r--src/particles/qquickparticleaffector.cpp4
-rw-r--r--src/particles/qquickparticlesystem.cpp48
-rw-r--r--src/particles/qquicktrailemitter.cpp2
-rw-r--r--src/plugins/qmllint/quick/quicklintplugin.cpp8
-rw-r--r--src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp28
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp5
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp12
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp6
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp10
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp16
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/inspecttool.cpp12
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp10
-rw-r--r--src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp6
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/proxytranslator.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp6
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp38
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp14
-rw-r--r--src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.cpp14
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp4
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp2
-rw-r--r--src/qml/Qt6AndroidQmlMacros.cmake20
-rw-r--r--src/qml/Qt6QmlMacros.cmake207
-rw-r--r--src/qml/animations/qabstractanimationjob.cpp10
-rw-r--r--src/qml/animations/qabstractanimationjob_p.h2
-rw-r--r--src/qml/common/qqmljsfixedpoolarray_p.h4
-rw-r--r--src/qml/common/qv4compileddata_p.h8
-rw-r--r--src/qml/common/qv4stringtoarrayindex_p.h2
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp8
-rw-r--r--src/qml/compiler/qv4compiler.cpp34
-rw-r--r--src/qml/compiler/qv4compilercontext.cpp14
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions.cpp22
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h2
-rw-r--r--src/qml/debugger/qqmlconfigurabledebugservice_p.h2
-rw-r--r--src/qml/debugger/qqmldebugconnector.cpp2
-rw-r--r--src/qml/doc/snippets/qmltc/tst_qmltc_examples.cpp2
-rw-r--r--src/qml/doc/src/cmake/cmake-properties.qdoc18
-rw-r--r--src/qml/doc/src/cmake/cmake-variables.qdoc2
-rw-r--r--src/qml/doc/src/cmake/qt_add_qml_module.qdoc10
-rw-r--r--src/qml/doc/src/cmake/qt_add_qml_plugin.qdoc2
-rw-r--r--src/qml/doc/src/cmake/qt_deploy_qml_imports.qdoc4
-rw-r--r--src/qml/doc/src/cmake/qt_generate_deploy_qml_app_script.qdoc4
-rw-r--r--src/qml/doc/src/cmake/qt_generate_foreign_qml_types.qdoc11
-rw-r--r--src/qml/doc/src/cmake/qt_import_qml_plugins.qdoc2
-rw-r--r--src/qml/doc/src/cmake/qt_query_qml_module.qdoc2
-rw-r--r--src/qml/doc/src/cmake/qt_target_compile_qml_to_cpp.qdoc2
-rw-r--r--src/qml/doc/src/cmake/qt_target_qml_sources.qdoc2
-rw-r--r--src/qml/doc/src/cppintegration/definetypes.qdoc69
-rw-r--r--src/qml/doc/src/includes/cmake-qml-qt-finalize-target-warning.qdocinc (renamed from src/qml/doc/src/includes/cmake-qml-qt-finalize-target-warning.cmake)3
-rw-r--r--src/qml/doc/src/qmlfunctions.qdoc8
-rw-r--r--src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc16
-rw-r--r--src/qml/doc/src/qmllanguageref/modules/identifiedmodules.qdoc12
-rw-r--r--src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc2
-rw-r--r--src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc8
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/directoryimports.qdoc5
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/imports.qdoc16
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc1
-rw-r--r--src/qml/doc/src/qmllanguageref/typesystem/valuetypes.qdoc86
-rw-r--r--src/qml/doc/src/qmltypereference.qdoc5
-rw-r--r--src/qml/doc/src/qtqml.qdoc37
-rw-r--r--src/qml/jit/qv4baselinejit_p.h2
-rw-r--r--src/qml/jsapi/qjsengine.cpp2
-rw-r--r--src/qml/jsapi/qjsmanagedvalue.cpp6
-rw-r--r--src/qml/jsapi/qjsvalue.cpp14
-rw-r--r--src/qml/jsruntime/qv4argumentsobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4arraybuffer_p.h5
-rw-r--r--src/qml/jsruntime/qv4arrayiterator_p.h2
-rw-r--r--src/qml/jsruntime/qv4compilationunitmapper.cpp11
-rw-r--r--src/qml/jsruntime/qv4compilationunitmapper_p.h1
-rw-r--r--src/qml/jsruntime/qv4context_p.h4
-rw-r--r--src/qml/jsruntime/qv4dataview_p.h2
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4engine.cpp65
-rw-r--r--src/qml/jsruntime/qv4engine_p.h13
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4errorobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4executableallocator.cpp2
-rw-r--r--src/qml/jsruntime/qv4executableallocator_p.h4
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit.cpp22
-rw-r--r--src/qml/jsruntime/qv4function.cpp4
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp23
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h4
-rw-r--r--src/qml/jsruntime/qv4generatorobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp14
-rw-r--r--src/qml/jsruntime/qv4identifiertable.cpp8
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp43
-rw-r--r--src/qml/jsruntime/qv4mapiterator_p.h2
-rw-r--r--src/qml/jsruntime/qv4memberdata_p.h2
-rw-r--r--src/qml/jsruntime/qv4module.cpp2
-rw-r--r--src/qml/jsruntime/qv4object.cpp2
-rw-r--r--src/qml/jsruntime/qv4persistent_p.h2
-rw-r--r--src/qml/jsruntime/qv4profiling.cpp2
-rw-r--r--src/qml/jsruntime/qv4promiseobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4propertykey.cpp2
-rw-r--r--src/qml/jsruntime/qv4qmlcontext_p.h4
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp110
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper_p.h62
-rw-r--r--src/qml/jsruntime/qv4reflect.cpp5
-rw-r--r--src/qml/jsruntime/qv4regexp.cpp12
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp18
-rw-r--r--src/qml/jsruntime/qv4regexpobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp17
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h6
-rw-r--r--src/qml/jsruntime/qv4setiterator_p.h2
-rw-r--r--src/qml/jsruntime/qv4stringiterator.cpp2
-rw-r--r--src/qml/jsruntime/qv4stringiterator_p.h2
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp58
-rw-r--r--src/qml/jsruntime/qv4stringobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4symbol_p.h2
-rw-r--r--src/qml/jsruntime/qv4typedarray_p.h2
-rw-r--r--src/qml/jsruntime/qv4urlobject.cpp16
-rw-r--r--src/qml/jsruntime/qv4urlobject_p.h4
-rw-r--r--src/qml/memory/qv4mm.cpp4
-rw-r--r--src/qml/parser/qqmljs.g12
-rw-r--r--src/qml/parser/qqmljsast_p.h2
-rw-r--r--src/qml/parser/qqmljslexer.cpp2
-rw-r--r--src/qml/qml/ftw/qbipointer_p.h5
-rw-r--r--src/qml/qml/ftw/qhashedstring_p.h10
-rw-r--r--src/qml/qml/ftw/qstringhash_p.h4
-rw-r--r--src/qml/qml/qqml.cpp16
-rw-r--r--src/qml/qml/qqmlapplicationengine.cpp4
-rw-r--r--src/qml/qml/qqmlbinding.cpp2
-rw-r--r--src/qml/qml/qqmlbinding_p.h8
-rw-r--r--src/qml/qml/qqmlcomponent.cpp44
-rw-r--r--src/qml/qml/qqmlcomponent.h2
-rw-r--r--src/qml/qml/qqmlcontext.cpp2
-rw-r--r--src/qml/qml/qqmlcontext_p.h2
-rw-r--r--src/qml/qml/qqmlcustomparser.cpp65
-rw-r--r--src/qml/qml/qqmlcustomparser_p.h2
-rw-r--r--src/qml/qml/qqmldata_p.h4
-rw-r--r--src/qml/qml/qqmldatablob.cpp14
-rw-r--r--src/qml/qml/qqmlengine.cpp2
-rw-r--r--src/qml/qml/qqmlerror.cpp4
-rw-r--r--src/qml/qml/qqmlextensionplugin.cpp23
-rw-r--r--src/qml/qml/qqmlfile.cpp101
-rw-r--r--src/qml/qml/qqmlimport.cpp94
-rw-r--r--src/qml/qml/qqmlincubator.cpp15
-rw-r--r--src/qml/qml/qqmlirloader.cpp10
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp2
-rw-r--r--src/qml/qml/qqmllist.h6
-rw-r--r--src/qml/qml/qqmllocale.cpp16
-rw-r--r--src/qml/qml/qqmllocale_p.h2
-rw-r--r--src/qml/qml/qqmlmetatype.cpp17
-rw-r--r--src/qml/qml/qqmlmetatypedata.cpp14
-rw-r--r--src/qml/qml/qqmlnotifier.cpp4
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp24
-rw-r--r--src/qml/qml/qqmlopenmetaobject.cpp22
-rw-r--r--src/qml/qml/qqmlpluginimporter.cpp10
-rw-r--r--src/qml/qml/qqmlproperty.cpp89
-rw-r--r--src/qml/qml/qqmlproperty.h2
-rw-r--r--src/qml/qml/qqmlpropertybinding.cpp8
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp53
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h18
-rw-r--r--src/qml/qml/qqmlpropertycachecreator.cpp6
-rw-r--r--src/qml/qml/qqmlpropertycachecreator_p.h27
-rw-r--r--src/qml/qml/qqmlpropertycachevector_p.h4
-rw-r--r--src/qml/qml/qqmlpropertydata_p.h1
-rw-r--r--src/qml/qml/qqmlpropertyresolver.cpp2
-rw-r--r--src/qml/qml/qqmlpropertyvalidator_p.h3
-rw-r--r--src/qml/qml/qqmlproxymetaobject.cpp8
-rw-r--r--src/qml/qml/qqmlscriptblob.cpp4
-rw-r--r--src/qml/qml/qqmlscriptdata.cpp4
-rw-r--r--src/qml/qml/qqmlscriptstring.cpp2
-rw-r--r--src/qml/qml/qqmltype.cpp22
-rw-r--r--src/qml/qml/qqmltypecompiler.cpp34
-rw-r--r--src/qml/qml/qqmltypecompiler_p.h2
-rw-r--r--src/qml/qml/qqmltypedata.cpp20
-rw-r--r--src/qml/qml/qqmltypeloader.cpp10
-rw-r--r--src/qml/qml/qqmltypemodule.cpp4
-rw-r--r--src/qml/qml/qqmltypenamecache.cpp4
-rw-r--r--src/qml/qml/qqmlvaluetype.cpp34
-rw-r--r--src/qml/qml/qqmlvaluetype_p.h38
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp36
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp11
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp37
-rw-r--r--src/qml/qmldirparser/qqmldirparser.cpp6
-rw-r--r--src/qml/qmldirparser/qqmlimportresolver.cpp4
-rw-r--r--src/qml/types/qqmlbind.cpp13
-rw-r--r--src/qml/types/qqmlconnections.cpp32
-rw-r--r--src/qml/util/qqmlpropertymap.cpp2
-rw-r--r--src/qmlcompiler/qdeferredpointer_p.h6
-rw-r--r--src/qmlcompiler/qqmljsbasicblocks.cpp16
-rw-r--r--src/qmlcompiler/qqmljscodegenerator.cpp132
-rw-r--r--src/qmlcompiler/qqmljscodegenerator_p.h7
-rw-r--r--src/qmlcompiler/qqmljscompilepass_p.h6
-rw-r--r--src/qmlcompiler/qqmljscompiler.cpp32
-rw-r--r--src/qmlcompiler/qqmljscompiler_p.h1
-rw-r--r--src/qmlcompiler/qqmljsfunctioninitializer.cpp4
-rw-r--r--src/qmlcompiler/qqmljsimporter.cpp10
-rw-r--r--src/qmlcompiler/qqmljsimportvisitor.cpp44
-rw-r--r--src/qmlcompiler/qqmljslinter.cpp34
-rw-r--r--src/qmlcompiler/qqmljslintercodegen.cpp1
-rw-r--r--src/qmlcompiler/qqmljsloadergenerator.cpp8
-rw-r--r--src/qmlcompiler/qqmljslogger.cpp6
-rw-r--r--src/qmlcompiler/qqmljslogger_p.h14
-rw-r--r--src/qmlcompiler/qqmljsmetatypes_p.h8
-rw-r--r--src/qmlcompiler/qqmljsresourcefilemapper.cpp2
-rw-r--r--src/qmlcompiler/qqmljsscope.cpp11
-rw-r--r--src/qmlcompiler/qqmljsscope_p.h28
-rw-r--r--src/qmlcompiler/qqmljsshadowcheck.cpp8
-rw-r--r--src/qmlcompiler/qqmljsstreamwriter.cpp2
-rw-r--r--src/qmlcompiler/qqmljstypepropagator.cpp43
-rw-r--r--src/qmlcompiler/qqmljstypepropagator_p.h9
-rw-r--r--src/qmlcompiler/qqmljstyperesolver.cpp171
-rw-r--r--src/qmlcompiler/qqmljstyperesolver_p.h7
-rw-r--r--src/qmlcompiler/qqmljsutils.cpp34
-rw-r--r--src/qmlcompiler/qqmljsutils_p.h2
-rw-r--r--src/qmldebug/qqmlprofilerclient_p_p.h2
-rw-r--r--src/qmldebug/qv4debugclient.cpp2
-rw-r--r--src/qmldom/qqmldomastcreator.cpp64
-rw-r--r--src/qmldom/qqmldomcomments.cpp10
-rw-r--r--src/qmldom/qqmldomcomments_p.h4
-rw-r--r--src/qmldom/qqmldomelements_p.h2
-rw-r--r--src/qmldom/qqmldomerrormessage.cpp14
-rw-r--r--src/qmldom/qqmldomexternalitems_p.h6
-rw-r--r--src/qmldom/qqmldomitem.cpp19
-rw-r--r--src/qmldom/qqmldomitem_p.h24
-rw-r--r--src/qmldom/qqmldomlinewriter.cpp12
-rw-r--r--src/qmldom/qqmldomlinewriter_p.h2
-rw-r--r--src/qmldom/qqmldommoduleindex.cpp4
-rw-r--r--src/qmldom/qqmldompath.cpp64
-rw-r--r--src/qmldom/qqmldomreformatter.cpp2
-rw-r--r--src/qmldom/qqmldomstringdumper.cpp8
-rw-r--r--src/qmldom/qqmldomtop.cpp2
-rw-r--r--src/qmldom/qqmldomtop_p.h4
-rw-r--r--src/qmldom/qqmldomtypesreader.cpp2
-rw-r--r--src/qmldom/standalone/private/qtqmlcompilerexports_p.h12
-rw-r--r--src/qmllocalstorage/qqmllocalstorage.cpp10
-rw-r--r--src/qmlmodels/qqmladaptormodel.cpp28
-rw-r--r--src/qmlmodels/qqmldelegatemodel.cpp59
-rw-r--r--src/qmlmodels/qqmlinstantiator.cpp18
-rw-r--r--src/qmlmodels/qqmllistaccessor.cpp8
-rw-r--r--src/qmlmodels/qqmllistmodel.cpp173
-rw-r--r--src/qmlmodels/qqmllistmodel_p_p.h47
-rw-r--r--src/qmlmodels/qqmlobjectmodel.cpp20
-rw-r--r--src/qmlmodels/qqmltableinstancemodel.cpp2
-rw-r--r--src/qmlmodels/qqmltreemodeltotablemodel.cpp133
-rw-r--r--src/qmlmodels/qqmltreemodeltotablemodel_p_p.h1
-rw-r--r--src/qmlmodels/qquickpackage.cpp6
-rw-r--r--src/qmltest/TestCase.qml36
-rw-r--r--src/qmltest/quicktest.cpp14
-rw-r--r--src/qmltest/quicktestevent.cpp6
-rw-r--r--src/qmltyperegistrar/metatypesjsonprocessor.cpp1
-rw-r--r--src/qmlworkerscript/qv4serialize.cpp4
-rw-r--r--src/qmlxmllistmodel/qqmlxmllistmodel.cpp16
-rw-r--r--src/quick/accessible/qaccessiblequickitem.cpp24
-rw-r--r--src/quick/accessible/qaccessiblequickview.cpp6
-rw-r--r--src/quick/designer/qqmldesignermetaobject.cpp6
-rw-r--r--src/quick/designer/qquickdesignersupportitems.cpp2
-rw-r--r--src/quick/doc/images/pointerHandlers/dragReleaseMenu.webpbin0 -> 86252 bytes
-rw-r--r--src/quick/doc/images/pointerHandlers/tapHandlerButtonReleaseWithinBounds.webpbin0 -> 53154 bytes
-rw-r--r--src/quick/doc/images/pointerHandlers/tapHandlerButtonWithinBounds.webpbin0 -> 27426 bytes
-rw-r--r--src/quick/doc/images/pointerHandlers/tapHandlerOverlappingButtons.webpbin0 -> 51008 bytes
-rw-r--r--src/quick/doc/snippets/pointerHandlers/dragReleaseMenu.qml72
-rw-r--r--src/quick/doc/snippets/pointerHandlers/pointHandler.qml5
-rw-r--r--src/quick/doc/snippets/pointerHandlers/pointHandlerAcceptedButtons.qml21
-rw-r--r--src/quick/doc/snippets/pointerHandlers/pointHandlerAcceptedModifiers.qml36
-rw-r--r--src/quick/doc/snippets/pointerHandlers/pointHandlerCanvasDrawing.qml54
-rw-r--r--src/quick/doc/snippets/pointerHandlers/pointHandlerMargin.qml36
-rw-r--r--src/quick/doc/snippets/pointerHandlers/tapHandlerButtonReleaseWithinBounds.qml51
-rw-r--r--src/quick/doc/snippets/pointerHandlers/tapHandlerButtonWithinBounds.qml51
-rw-r--r--src/quick/doc/snippets/pointerHandlers/tapHandlerOverlappingButtons.qml51
-rw-r--r--src/quick/doc/snippets/qml/item/itemGrab.qml39
-rw-r--r--src/quick/doc/snippets/qml/itemGrab.qml50
-rw-r--r--src/quick/doc/src/concepts/inputhandlers/qtquickhandlers-index.qdoc3
-rw-r--r--src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc6
-rw-r--r--src/quick/doc/src/cppextensionpoints.qdoc19
-rw-r--r--src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc27
-rw-r--r--src/quick/doc/src/guidelines/qtquick-tool-qmllint.qdoc4
-rw-r--r--src/quick/doc/src/qmltypereference.qdoc4
-rw-r--r--src/quick/handlers/qquickdraghandler.cpp2
-rw-r--r--src/quick/handlers/qquickhandlerpoint.cpp39
-rw-r--r--src/quick/handlers/qquickhandlerpoint_p.h1
-rw-r--r--src/quick/handlers/qquickhoverhandler.cpp73
-rw-r--r--src/quick/handlers/qquickhoverhandler_p.h4
-rw-r--r--src/quick/handlers/qquickmultipointhandler.cpp12
-rw-r--r--src/quick/handlers/qquickpinchhandler.cpp21
-rw-r--r--src/quick/handlers/qquickpointerdevicehandler.cpp4
-rw-r--r--src/quick/handlers/qquickpointerdevicehandler_p.h7
-rw-r--r--src/quick/handlers/qquickpointerhandler.cpp10
-rw-r--r--src/quick/handlers/qquickpointerhandler_p_p.h4
-rw-r--r--src/quick/handlers/qquickpointhandler.cpp126
-rw-r--r--src/quick/handlers/qquicksinglepointhandler.cpp2
-rw-r--r--src/quick/handlers/qquicktaphandler.cpp132
-rw-r--r--src/quick/handlers/qquickwheelhandler.cpp2
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp4
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h2
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture.cpp6
-rw-r--r--src/quick/items/qquickaccessibleattached.cpp34
-rw-r--r--src/quick/items/qquickcolorgroup.cpp4
-rw-r--r--src/quick/items/qquickdrag.cpp12
-rw-r--r--src/quick/items/qquickdrag_p.h3
-rw-r--r--src/quick/items/qquickdroparea.cpp2
-rw-r--r--src/quick/items/qquickflickable.cpp66
-rw-r--r--src/quick/items/qquickflickable_p_p.h34
-rw-r--r--src/quick/items/qquickflipable.cpp54
-rw-r--r--src/quick/items/qquickgridview.cpp48
-rw-r--r--src/quick/items/qquickimagebase.cpp4
-rw-r--r--src/quick/items/qquickitem.cpp199
-rw-r--r--src/quick/items/qquickitem_p.h7
-rw-r--r--src/quick/items/qquickitemanimation.cpp16
-rw-r--r--src/quick/items/qquickitemgrabresult.cpp14
-rw-r--r--src/quick/items/qquickitemsmodule.cpp134
-rw-r--r--src/quick/items/qquickitemview.cpp61
-rw-r--r--src/quick/items/qquicklistview.cpp113
-rw-r--r--src/quick/items/qquickloader.cpp2
-rw-r--r--src/quick/items/qquickmousearea.cpp74
-rw-r--r--src/quick/items/qquickmousearea_p_p.h1
-rw-r--r--src/quick/items/qquickmultipointtoucharea.cpp24
-rw-r--r--src/quick/items/qquickmultipointtoucharea_p.h2
-rw-r--r--src/quick/items/qquickpainteditem.cpp2
-rw-r--r--src/quick/items/qquickpalette.cpp10
-rw-r--r--src/quick/items/qquickpathview.cpp44
-rw-r--r--src/quick/items/qquickpincharea.cpp30
-rw-r--r--src/quick/items/qquickpositioners.cpp4
-rw-r--r--src/quick/items/qquickrectangle.cpp9
-rw-r--r--src/quick/items/qquickrendercontrol.cpp6
-rw-r--r--src/quick/items/qquickrendertarget.cpp2
-rw-r--r--src/quick/items/qquickrepeater.cpp20
-rw-r--r--src/quick/items/qquickshadereffect.cpp22
-rw-r--r--src/quick/items/qquickshadereffectmesh.cpp2
-rw-r--r--src/quick/items/qquickspriteengine.cpp47
-rw-r--r--src/quick/items/qquickspriteengine_p.h8
-rw-r--r--src/quick/items/qquickspritesequence.cpp2
-rw-r--r--src/quick/items/qquickstateoperations.cpp2
-rw-r--r--src/quick/items/qquicktableview.cpp238
-rw-r--r--src/quick/items/qquicktableview_p.h6
-rw-r--r--src/quick/items/qquicktableview_p_p.h21
-rw-r--r--src/quick/items/qquicktext.cpp98
-rw-r--r--src/quick/items/qquicktext_p_p.h2
-rw-r--r--src/quick/items/qquicktextcontrol.cpp11
-rw-r--r--src/quick/items/qquicktextdocument.cpp2
-rw-r--r--src/quick/items/qquicktextedit.cpp34
-rw-r--r--src/quick/items/qquicktextedit_p.h1
-rw-r--r--src/quick/items/qquicktextedit_p_p.h8
-rw-r--r--src/quick/items/qquicktextinput.cpp148
-rw-r--r--src/quick/items/qquicktextinput_p_p.h10
-rw-r--r--src/quick/items/qquicktextnode.cpp2
-rw-r--r--src/quick/items/qquicktextnodeengine.cpp11
-rw-r--r--src/quick/items/qquicktreeview.cpp33
-rw-r--r--src/quick/items/qquicktreeview_p.h6
-rw-r--r--src/quick/items/qquickwindow.cpp46
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp12
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp14
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp4
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp2
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp28
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.cpp31
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.h1
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialshader.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture.cpp4
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer.cpp14
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer_p.h2
-rw-r--r--src/quick/scenegraph/qsgcontextplugin.cpp4
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp4
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext.cpp15
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext_p.h5
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode.cpp14
-rw-r--r--src/quick/scenegraph/qsgrenderloop.cpp2
-rw-r--r--src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp27
-rw-r--r--src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h3
-rw-r--r--src/quick/scenegraph/qsgrhishadereffectnode.cpp70
-rw-r--r--src/quick/scenegraph/qsgrhishadereffectnode_p.h2
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp2
-rw-r--r--src/quick/scenegraph/qsgrhitextureglyphcache.cpp25
-rw-r--r--src/quick/scenegraph/qsgrhitextureglyphcache_p.h1
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp3
-rw-r--r--src/quick/util/qquickanimation.cpp50
-rw-r--r--src/quick/util/qquickanimatorcontroller.cpp14
-rw-r--r--src/quick/util/qquickanimatorjob.cpp5
-rw-r--r--src/quick/util/qquickapplication.cpp6
-rw-r--r--src/quick/util/qquickdeliveryagent.cpp280
-rw-r--r--src/quick/util/qquickdeliveryagent_p_p.h2
-rw-r--r--src/quick/util/qquickframeanimation.cpp5
-rw-r--r--src/quick/util/qquickglobal.cpp6
-rw-r--r--src/quick/util/qquickimageprovider.cpp2
-rw-r--r--src/quick/util/qquickpath.cpp52
-rw-r--r--src/quick/util/qquickpixmapcache.cpp21
-rw-r--r--src/quick/util/qquickpropertychanges.cpp12
-rw-r--r--src/quick/util/qquickshortcut.cpp4
-rw-r--r--src/quick/util/qquickshortcut_p.h3
-rw-r--r--src/quick/util/qquicksmoothedanimation.cpp2
-rw-r--r--src/quick/util/qquickstate.cpp24
-rw-r--r--src/quick/util/qquickstate_p_p.h2
-rw-r--r--src/quick/util/qquickstategroup.cpp41
-rw-r--r--src/quick/util/qquickstyledtext.cpp107
-rw-r--r--src/quick/util/qquicksvgparser.cpp2
-rw-r--r--src/quick/util/qquicktimeline.cpp4
-rw-r--r--src/quick/util/qquicktransition.cpp8
-rw-r--r--src/quick/util/qquicktransitionmanager.cpp31
-rw-r--r--src/quickcontrols2/basic/HorizontalHeaderView.qml2
-rw-r--r--src/quickcontrols2/basic/TreeViewDelegate.qml8
-rw-r--r--src/quickcontrols2/basic/VerticalHeaderView.qml2
-rw-r--r--src/quickcontrols2/designer/qtquickcontrols2.metainfo40
-rw-r--r--src/quickcontrols2/doc/snippets/qtquickcontrols2-swipedelegate.qml3
-rw-r--r--src/quickcontrols2/doc/src/includes/qquickimaginestyle.qdocinc3
-rw-r--r--src/quickcontrols2/doc/src/includes/qquicktooltip.qdocinc6
-rw-r--r--src/quickcontrols2/doc/src/qtquickcontrols2-customize.qdoc9
-rw-r--r--src/quickcontrols2/doc/src/qtquickcontrols2-delegates.qdoc4
-rw-r--r--src/quickcontrols2/doc/src/qtquickcontrols2-ios.qdoc5
-rw-r--r--src/quickcontrols2/doc/src/qtquickcontrols2-macos.qdoc2
-rw-r--r--src/quickcontrols2/doc/src/qtquickcontrols2-windows.qdoc2
-rw-r--r--src/quickcontrols2/fusion/CMakeLists.txt1
-rw-r--r--src/quickcontrols2/fusion/HorizontalHeaderView.qml10
-rw-r--r--src/quickcontrols2/fusion/TreeViewDelegate.qml62
-rw-r--r--src/quickcontrols2/fusion/VerticalHeaderView.qml10
-rw-r--r--src/quickcontrols2/fusion/qquickfusiontheme.cpp14
-rw-r--r--src/quickcontrols2/fusion/qquickfusiontheme_p.h2
-rw-r--r--src/quickcontrols2/imagine/ComboBox.qml4
-rw-r--r--src/quickcontrols2/imagine/HorizontalHeaderView.qml2
-rw-r--r--src/quickcontrols2/imagine/VerticalHeaderView.qml2
-rw-r--r--src/quickcontrols2/imagine/impl/shaders/OpacityMask.frag3
-rw-r--r--src/quickcontrols2/ios/CMakeLists.txt5
-rw-r--r--src/quickcontrols2/ios/Menu.qml71
-rw-r--r--src/quickcontrols2/ios/MenuItem.qml104
-rw-r--r--src/quickcontrols2/ios/MenuSeparator.qml26
-rw-r--r--src/quickcontrols2/ios/ProgressBar.qml12
-rw-r--r--src/quickcontrols2/ios/TreeViewDelegate.qml9
-rw-r--r--src/quickcontrols2/ios/images/menu-background-dark.9.pngbin0 -> 350 bytes
-rw-r--r--src/quickcontrols2/ios/images/menu-background-dark@2x.9.pngbin0 -> 601 bytes
-rw-r--r--src/quickcontrols2/ios/images/menu-background-dark@3x.9.pngbin0 -> 723 bytes
-rw-r--r--src/quickcontrols2/ios/images/menu-background-light.9.pngbin0 -> 319 bytes
-rw-r--r--src/quickcontrols2/ios/images/menu-background-light@2x.9.pngbin0 -> 564 bytes
-rw-r--r--src/quickcontrols2/ios/images/menu-background-light@3x.9.pngbin0 -> 697 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-dark.9.pngbin0 -> 114 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-dark@2x.9.pngbin0 -> 117 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-dark@3x.9.pngbin0 -> 118 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-dark.9.pngbin0 -> 277 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-dark@2x.9.pngbin0 -> 377 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-dark@3x.9.pngbin0 -> 474 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-light.9.pngbin0 -> 265 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-light@2x.9.pngbin0 -> 381 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-light@3x.9.pngbin0 -> 465 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark.9.pngbin0 -> 253 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark@2x.9.pngbin0 -> 366 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark@3x.9.pngbin0 -> 467 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light.9.pngbin0 -> 253 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light@2x.9.pngbin0 -> 368 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light@3x.9.pngbin0 -> 452 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-light.9.pngbin0 -> 115 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-light@2x.9.pngbin0 -> 122 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-light@3x.9.pngbin0 -> 122 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-pressed-dark.9.pngbin0 -> 113 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-pressed-dark@2x.9.pngbin0 -> 118 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-pressed-dark@3x.9.pngbin0 -> 119 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-pressed-light.9.pngbin0 -> 114 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-pressed-light@2x.9.pngbin0 -> 122 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-pressed-light@3x.9.pngbin0 -> 123 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark.9.pngbin0 -> 322 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark@2x.9.pngbin0 -> 544 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark@3x.9.pngbin0 -> 645 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-single-pressed-light.9.pngbin0 -> 310 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-single-pressed-light@2x.9.pngbin0 -> 525 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuitem-background-single-pressed-light@3x.9.pngbin0 -> 648 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuseparator-separator-dark.9.pngbin0 -> 105 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuseparator-separator-dark@2x.9.pngbin0 -> 108 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuseparator-separator-dark@3x.9.pngbin0 -> 110 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuseparator-separator-light.9.pngbin0 -> 106 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuseparator-separator-light@2x.9.pngbin0 -> 109 bytes
-rw-r--r--src/quickcontrols2/ios/images/menuseparator-separator-light@3x.9.pngbin0 -> 110 bytes
-rw-r--r--src/quickcontrols2/ios/qquickiosstyle.cpp11
-rw-r--r--src/quickcontrols2/ios/qquickiosstyle_p.h3
-rw-r--r--src/quickcontrols2/macos/TreeViewDelegate.qml2
-rw-r--r--src/quickcontrols2/material/CMakeLists.txt1
-rw-r--r--src/quickcontrols2/material/HorizontalHeaderView.qml2
-rw-r--r--src/quickcontrols2/material/TreeViewDelegate.qml62
-rw-r--r--src/quickcontrols2/material/VerticalHeaderView.qml2
-rw-r--r--src/quickcontrols2/material/qt_attribution.json4
-rw-r--r--src/quickcontrols2/universal/HorizontalHeaderView.qml2
-rw-r--r--src/quickcontrols2/universal/VerticalHeaderView.qml2
-rw-r--r--src/quickcontrols2/windows/SpinBox.qml11
-rw-r--r--src/quickcontrols2impl/qquickimageselector.cpp14
-rw-r--r--src/quickcontrols2impl/qquickmnemoniclabel.cpp2
-rw-r--r--src/quickcontrols2impl/qquickninepatchimage.cpp66
-rw-r--r--src/quickcontrolstestutils/CMakeLists.txt8
-rw-r--r--src/quickcontrolstestutils/controlstestutils.cpp33
-rw-r--r--src/quickcontrolstestutils/controlstestutils_p.h12
-rw-r--r--src/quickcontrolstestutils/dialogstestutils.cpp12
-rw-r--r--src/quickcontrolstestutils/qtest_quickcontrols_p.h4
-rw-r--r--src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf2
-rw-r--r--src/quickdialogs2/quickdialogs2/doc/snippets/qtquickdialogs-filedialog.qml34
-rw-r--r--src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp22
-rw-r--r--src/quickdialogs2/quickdialogs2/qquickfolderdialog.cpp8
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/CMakeLists.txt5
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qml/+Fusion/ColorDialog.qml30
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qml/+Fusion/FileDialog.qml38
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qml/+Imagine/ColorDialog.qml29
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qml/+Imagine/FileDialog.qml40
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qml/+Material/ColorDialog.qml28
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qml/+Material/FileDialog.qml49
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qml/+Universal/ColorDialog.qml28
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qml/+Universal/FileDialog.qml35
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qml/ColorDialog.qml28
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qml/ColorInputs.qml434
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qml/FileDialog.qml52
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker.cpp36
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker_p.h2
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker_p_p.h16
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl.cpp105
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl_p.h20
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl_p_p.h13
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogutils.cpp24
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogutils_p.h36
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickcolorinputs.cpp509
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickcolorinputs_p.h171
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl.cpp70
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl_p.h18
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl_p_p.h5
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickfolderbreadcrumbbar.cpp16
-rw-r--r--src/quickdialogs2/quickdialogs2quickimpl/qquickfontdialogimpl.cpp6
-rw-r--r--src/quicklayouts/qquickgridlayoutengine.cpp7
-rw-r--r--src/quicklayouts/qquickgridlayoutengine_p.h3
-rw-r--r--src/quicklayouts/qquicklayout.cpp16
-rw-r--r--src/quicklayouts/qquicklayout_p.h3
-rw-r--r--src/quicklayouts/qquicklinearlayout.cpp3
-rw-r--r--src/quicklayouts/qquicklinearlayout_p.h2
-rw-r--r--src/quicklayouts/qquickstacklayout.cpp41
-rw-r--r--src/quicklayouts/qquickstacklayout_p.h3
-rw-r--r--src/quicknativestyle/controls/DefaultTreeViewDelegate.qml2
-rw-r--r--src/quicknativestyle/qstyle/mac/qquickmacstyle_mac.mm16
-rw-r--r--src/quicknativestyle/qstyle/qquickcommonstyle.cpp7
-rw-r--r--src/quickshapes/qquickshape.cpp12
-rw-r--r--src/quickshapes/qquickshape_p_p.h2
-rw-r--r--src/quickshapes/qquickshapegenericrenderer.cpp44
-rw-r--r--src/quickshapes/qquickshapesoftwarerenderer.cpp12
-rw-r--r--src/quicktemplates2/accessible/qaccessiblequickpage.cpp2
-rw-r--r--src/quicktemplates2/qquickaction.cpp10
-rw-r--r--src/quicktemplates2/qquickactiongroup.cpp6
-rw-r--r--src/quicktemplates2/qquickbuttongroup.cpp8
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp10
-rw-r--r--src/quicktemplates2/qquickcontainer.cpp4
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp30
-rw-r--r--src/quicktemplates2/qquickcontrol_p_p.h1
-rw-r--r--src/quicktemplates2/qquickdialog.cpp2
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox.cpp6
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp16
-rw-r--r--src/quicktemplates2/qquickmenu.cpp8
-rw-r--r--src/quicktemplates2/qquickmenubar.cpp9
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp46
-rw-r--r--src/quicktemplates2/qquickoverlay_p_p.h10
-rw-r--r--src/quicktemplates2/qquickpane.cpp4
-rw-r--r--src/quicktemplates2/qquickpopup.cpp24
-rw-r--r--src/quicktemplates2/qquickpopuppositioner.cpp8
-rw-r--r--src/quicktemplates2/qquickpresshandler.cpp2
-rw-r--r--src/quicktemplates2/qquickscrollbar.cpp17
-rw-r--r--src/quicktemplates2/qquickshortcutcontext.cpp5
-rw-r--r--src/quicktemplates2/qquicksplitview.cpp86
-rw-r--r--src/quicktemplates2/qquickstackelement.cpp10
-rw-r--r--src/quicktemplates2/qquickstackelement_p_p.h1
-rw-r--r--src/quicktemplates2/qquickstackview.cpp30
-rw-r--r--src/quicktemplates2/qquickstackview_p.cpp8
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp10
-rw-r--r--src/quicktemplates2/qquicktabbar.cpp2
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp6
-rw-r--r--src/quicktemplates2/qquicktextfield.cpp15
-rw-r--r--src/quicktemplates2/qquicktooltip.cpp2
-rw-r--r--src/quicktemplates2/qquicktreeviewdelegate.cpp217
-rw-r--r--src/quicktemplates2/qquicktreeviewdelegate_p.h2
-rw-r--r--src/quicktestutils/qml/testhttpserver.cpp10
-rw-r--r--src/quicktestutils/quick/viewtestutils.cpp117
-rw-r--r--src/quicktestutils/quick/viewtestutils_p.h11
-rw-r--r--src/quicktestutils/quick/visualtestutils.cpp4
-rw-r--r--src/quicktestutils/quick/visualtestutils_p.h6
-rw-r--r--src/quickwidgets/qquickwidget.cpp24
-rw-r--r--tests/auto/cmake/CMakeLists.txt1
-rw-r--r--tests/auto/cmake/test_internal_singleton/CMakeLists.txt23
-rw-r--r--tests/auto/cmake/test_internal_singleton/Test.qml4
-rw-r--r--tests/auto/particles/qquickage/tst_qquickage.cpp8
-rw-r--r--tests/auto/particles/qquickangleddirection/tst_qquickangleddirection.cpp2
-rw-r--r--tests/auto/particles/qquickcumulativedirection/tst_qquickcumulativedirection.cpp2
-rw-r--r--tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp4
-rw-r--r--tests/auto/particles/qquickellipseextruder/tst_qquickellipseextruder.cpp4
-rw-r--r--tests/auto/particles/qquickfriction/tst_qquickfriction.cpp6
-rw-r--r--tests/auto/particles/qquickgravity/tst_qquickgravity.cpp2
-rw-r--r--tests/auto/particles/qquickgroupgoal/tst_qquickgroupgoal.cpp2
-rw-r--r--tests/auto/particles/qquickimageparticle/tst_qquickimageparticle.cpp90
-rw-r--r--tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp4
-rw-r--r--tests/auto/particles/qquicklineextruder/tst_qquicklineextruder.cpp4
-rw-r--r--tests/auto/particles/qquickmaskextruder/tst_qquickmaskextruder.cpp2
-rw-r--r--tests/auto/particles/qquickparticlegroup/tst_qquickparticlegroup.cpp2
-rw-r--r--tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp2
-rw-r--r--tests/auto/particles/qquickpointattractor/tst_qquickpointattractor.cpp2
-rw-r--r--tests/auto/particles/qquickpointdirection/tst_qquickpointdirection.cpp2
-rw-r--r--tests/auto/particles/qquickrectangleextruder/tst_qquickrectangleextruder.cpp4
-rw-r--r--tests/auto/particles/qquickspritegoal/tst_qquickspritegoal.cpp2
-rw-r--r--tests/auto/particles/qquicktargetdirection/tst_qquicktargetdirection.cpp2
-rw-r--r--tests/auto/particles/qquicktrailemitter/tst_qquicktrailemitter.cpp4
-rw-r--r--tests/auto/particles/qquickturbulence/tst_qquickturbulence.cpp2
-rw-r--r--tests/auto/particles/qquickwander/tst_qquickwander.cpp2
-rw-r--r--tests/auto/qml/CMakeLists.txt6
-rw-r--r--tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp2
-rw-r--r--tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp2
-rw-r--r--tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp12
-rw-r--r--tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp4
-rw-r--r--tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp10
-rw-r--r--tests/auto/qml/debugger/qqmldebugtranslationservice/tst_qqmldebugtranslationservice.cpp12
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp18
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/data/fetchValueType.qml9
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp90
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp4
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp46
-rw-r--r--tests/auto/qml/debugger/qv4debugger/CMakeLists.txt13
-rw-r--r--tests/auto/qml/debugger/qv4debugger/commontypes.h20
-rw-r--r--tests/auto/qml/debugger/qv4debugger/data/qtbug_107607.qml10
-rw-r--r--tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp77
-rw-r--r--tests/auto/qml/debugger/shared/debugutil.cpp6
-rw-r--r--tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp20
-rw-r--r--tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp54
-rw-r--r--tests/auto/qml/parserstress/tst_parserstress.cpp2
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp63
-rw-r--r--tests/auto/qml/qjsmanagedvalue/tst_qjsmanagedvalue.cpp2
-rw-r--r--tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp40
-rw-r--r--tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt16
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/badSequence.qml1
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/callWithSpread.qml9
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/cppbaseclass.h3
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/dummyobjekt.h29
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enumConversion.qml7
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enumFromBadSingleton.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enumProblems.qml13
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enumProperty.h34
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enumproblems.h53
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/failures.qml4
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/gadgetwithenum.h23
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/nullComparison.qml26
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/signalIndexMismatch.qml48
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/storeElementSideEffects.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/typePropagationLoop.qml9
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/undefinedToDouble.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/versionmismatch.qml10
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp172
-rw-r--r--tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp114
-rw-r--r--tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml13
-rw-r--r--tests/auto/qml/qmlformat/data/dontRemoveComments.qml13
-rw-r--r--tests/auto/qml/qmlformat/tst_qmlformat.cpp5
-rw-r--r--tests/auto/qml/qmllint/data/Foo.qml5
-rw-r--r--tests/auto/qml/qmllint/data/callBase.qml7
-rw-r--r--tests/auto/qml/qmllint/data/enumsOfScrollBar.qml7
-rw-r--r--tests/auto/qml/qmllint/data/inlineComponentNoComponent.qml5
-rw-r--r--tests/auto/qml/qmllint/data/invalidAliasTarget.qml11
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp51
-rw-r--r--tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt5
-rw-r--r--tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias1.qml8
-rw-r--r--tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias2.qml8
-rw-r--r--tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias3.qml5
-rw-r--r--tests/auto/qml/qmltc/QmltcTests/aliases.qml29
-rw-r--r--tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml22
-rw-r--r--tests/auto/qml/qmltc/tst_qmltc.cpp95
-rw-r--r--tests/auto/qml/qmltc/tst_qmltc.h2
-rw-r--r--tests/auto/qml/qmltc_qprocess/data/kebab-case.qml5
-rw-r--r--tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp10
-rw-r--r--tests/auto/qml/qqmlapplicationengine/androidassets/tst_androidassets.cpp4
-rw-r--r--tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp22
-rw-r--r--tests/auto/qml/qqmlbinding/data/bindingWithHandler.qml7
-rw-r--r--tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp22
-rw-r--r--tests/auto/qml/qqmlchangeset/CMakeLists.txt4
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp8
-rw-r--r--tests/auto/qml/qqmlconnections/data/invalidTarget.qml31
-rw-r--r--tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp22
-rw-r--r--tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp2
-rw-r--r--tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp8
-rw-r--r--tests/auto/qml/qqmlecmascript/BLACKLIST2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasPropertyToIC.qml11
-rw-r--r--tests/auto/qml/qqmlecmascript/data/frozenQObject2.qml19
-rw-r--r--tests/auto/qml/qqmlecmascript/data/methodTypeMismatch.qml25
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qmlTypeWrapperArgs.qml8
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qmlTypeWrapperArgs2.qml9
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qpropertyBindingNoQPropertyCapture.qml19
-rw-r--r--tests/auto/qml/qqmlecmascript/data/readOnlyBindable.qml7
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.cpp3
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h45
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp476
-rw-r--r--tests/auto/qml/qqmlfile/tst_qqmlfile.cpp21
-rw-r--r--tests/auto/qml/qqmlfileselector/data/qmldirtest/main.qml13
-rw-r--r--tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/+linux/MyButton.qml7
-rw-r--r--tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/+macos/MyButton.qml7
-rw-r--r--tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/MyButton.qml7
-rw-r--r--tests/auto/qml/qqmlfileselector/data/qmldirtest/qmldir5
-rw-r--r--tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp19
-rw-r--r--tests/auto/qml/qqmlimport/tst_qqmlimport.cpp8
-rw-r--r--tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp10
-rw-r--r--tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp2
-rw-r--r--tests/auto/qml/qqmlinstantiator/stringmodel.h4
-rw-r--r--tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp34
-rw-r--r--tests/auto/qml/qqmlitemmodels/qtestmodel.h12
-rw-r--r--tests/auto/qml/qqmlitemmodels/tst_qqmlitemmodels.cpp6
-rw-r--r--tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp2
-rw-r--r--tests/auto/qml/qqmllanguage/data/ComponentType.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/data/SignalInlineComponentArg.qml21
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.15.qml21
-rw-r--r--tests/auto/qml/qqmllanguage/data/badGroupedProperty.qml10
-rw-r--r--tests/auto/qml/qqmllanguage/data/bindingAliasToComponentUrl.qml10
-rw-r--r--tests/auto/qml/qqmllanguage/data/bindingAliasToComponentUrl2.qml11
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullIsNull.qml28
-rw-r--r--tests/auto/qml/qqmllanguage/data/signalInlineComponentArg1.qml30
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.cpp4
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp70
-rw-r--r--tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp2
-rw-r--r--tests/auto/qml/qqmllistmodel/data/Model.qml9
-rw-r--r--tests/auto/qml/qqmllistmodel/data/enumsInListElement.qml8
-rw-r--r--tests/auto/qml/qqmllistmodel/data/protectQObjectFromGC.qml21
-rw-r--r--tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp62
-rw-r--r--tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp56
-rw-r--r--tests/auto/qml/qqmllocale/data/functions.qml3
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp20
-rw-r--r--tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp6
-rw-r--r--tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp14
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp6
-rw-r--r--tests/auto/qml/qqmlnotifier/BLACKLIST3
-rw-r--r--tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp56
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp6
-rw-r--r--tests/auto/qml/qqmlproperty/data/assignVariantList.qml6
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp47
-rw-r--r--tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp58
-rw-r--r--tests/auto/qml/qqmlqt/tst_qqmlqt.cpp14
-rw-r--r--tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp4
-rw-r--r--tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp192
-rw-r--r--tests/auto/qml/qqmltimer/tst_qqmltimer.cpp18
-rw-r--r--tests/auto/qml/qqmltranslation/CMakeLists.txt1
-rw-r--r--tests/auto/qml/qqmltranslation/data/translatedElements.qml15
-rw-r--r--tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp39
-rw-r--r--tests/auto/qml/qqmltreemodeltotablemodel/testmodel.cpp2
-rw-r--r--tests/auto/qml/qqmltreemodeltotablemodel/tst_qqmltreemodeltotablemodel.cpp4
-rw-r--r--tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp14
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp12
-rw-r--r--tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp44
-rw-r--r--tests/auto/qml/qv4assembler/tst_qv4assembler.cpp2
-rw-r--r--tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp2
-rw-r--r--tests/auto/qmldom/domdata/domitem/test1.qml3
-rw-r--r--tests/auto/qmldom/domdata/reformatter/typeAnnotations.qml12
-rw-r--r--tests/auto/qmldom/domdata/reformatter/typeAnnotationsReformatted.qml12
-rw-r--r--tests/auto/qmldom/domitem/tst_qmldomitem.h27
-rw-r--r--tests/auto/qmldom/path/tst_qmldompath.h4
-rw-r--r--tests/auto/qmldom/reformatter/tst_reformatter.h4
-rw-r--r--tests/auto/qmlls/completions/data/completions/Yyy.qml5
-rw-r--r--tests/auto/qmlls/completions/tst_qmllscompletions.cpp21
-rw-r--r--tests/auto/qmlls/lifecycle/qiopipe.cpp6
-rw-r--r--tests/auto/qmlls/qmlls/tst_qmlls.cpp2
-rw-r--r--tests/auto/qmltest/selftests/tst_createTemporaryObject.qml9
-rw-r--r--tests/auto/quick/examples/tst_examples.cpp13
-rw-r--r--tests/auto/quick/pointerhandlers/flickableinterop/BLACKLIST3
-rw-r--r--tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp28
-rw-r--r--tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp8
-rw-r--r--tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp8
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp64
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/BLACKLIST3
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/data/hoverDeviceCursors.qml49
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/data/nohandler.qml15
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp354
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpinchhandler/data/nullTarget.qml33
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpinchhandler/data/pinchproperties.qml38
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp290
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp146
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp51
-rw-r--r--tests/auto/quick/pointerhandlers/qquickwheelhandler/tst_qquickwheelhandler.cpp14
-rw-r--r--tests/auto/quick/propertyrequirements/tst_propertyrequirements.cpp2
-rw-r--r--tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp4
-rw-r--r--tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp90
-rw-r--r--tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp34
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp72
-rw-r--r--tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp8
-rw-r--r--tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp52
-rw-r--r--tests/auto/quick/qquickboundaryrule/tst_qquickboundaryrule.cpp8
-rw-r--r--tests/auto/quick/qquickcolorgroup/tst_qquickcolorgroup.cpp4
-rw-r--r--tests/auto/quick/qquickdeliveryagent/data/listViewDelegate.qml21
-rw-r--r--tests/auto/quick/qquickdeliveryagent/tst_qquickdeliveryagent.cpp70
-rw-r--r--tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp8
-rw-r--r--tests/auto/quick/qquickdroparea/data/ignoreRetriggerEvent.qml15
-rw-r--r--tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp29
-rw-r--r--tests/auto/quick/qquickflickable/data/contentPosWhileDragging.qml24
-rw-r--r--tests/auto/quick/qquickflickable/data/flickableWithTapHandler.qml24
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp629
-rw-r--r--tests/auto/quick/qquickflipable/data/flip-y-axis-flipable.qml32
-rw-r--r--tests/auto/quick/qquickflipable/tst_qquickflipable.cpp28
-rw-r--r--tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp118
-rw-r--r--tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp16
-rw-r--r--tests/auto/quick/qquickfontmetrics/tst_quickfontmetrics.cpp2
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp271
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp74
-rw-r--r--tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp6
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp14
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp100
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml50
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml115
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml494
-rw-r--r--tests/auto/quick/qquicklistview/data/appendDuringScrollDown.qml3
-rw-r--r--tests/auto/quick/qquicklistview/data/displayMargin.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-itematindex.qml3
-rw-r--r--tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/sectionSnapping.qml3
-rw-r--r--tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml3
-rw-r--r--tests/auto/quick/qquicklistview/data/strictlyenforcerange-resize.qml3
-rw-r--r--tests/auto/quick/qquicklistview/proxytestinnermodel.cpp4
-rw-r--r--tests/auto/quick/qquicklistview/randomsortmodel.cpp8
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp314
-rw-r--r--tests/auto/quick/qquicklistview2/data/maxXExtent.qml29
-rw-r--r--tests/auto/quick/qquicklistview2/data/maxYExtent.qml30
-rw-r--r--tests/auto/quick/qquicklistview2/data/qtbug104679_footer.qml21
-rw-r--r--tests/auto/quick/qquicklistview2/data/qtbug104679_header.qml21
-rw-r--r--tests/auto/quick/qquicklistview2/data/qtbug86744.qml25
-rw-r--r--tests/auto/quick/qquicklistview2/data/qtbug98315.qml98
-rw-r--r--tests/auto/quick/qquicklistview2/data/snapOneItem.qml34
-rw-r--r--tests/auto/quick/qquicklistview2/tst_qquicklistview2.cpp397
-rw-r--r--tests/auto/quick/qquickloader/data/overflow.qml5
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp76
-rw-r--r--tests/auto/quick/qquickmousearea/data/containsMouseAndHoverDisabled.qml15
-rw-r--r--tests/auto/quick/qquickmousearea/data/containsMouseMasked.qml24
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp200
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp28
-rw-r--r--tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp32
-rw-r--r--tests/auto/quick/qquickpalette/tst_qquickpalette.cpp12
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp358
-rw-r--r--tests/auto/quick/qquickpincharea/data/pinchAreaInPathView.qml48
-rw-r--r--tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp203
-rw-r--r--tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp8
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp48
-rw-r--r--tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp24
-rw-r--r--tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp2
-rw-r--r--tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp144
-rw-r--r--tests/auto/quick/qquickscreen/tst_qquickscreen.cpp4
-rw-r--r--tests/auto/quick/qquickshape/tst_qquickshape.cpp18
-rw-r--r--tests/auto/quick/qquickstates/data/jsValueWhen2.qml20
-rw-r--r--tests/auto/quick/qquickstates/data/removeBindingWithTransition.qml23
-rw-r--r--tests/auto/quick/qquickstates/tst_qquickstates.cpp55
-rw-r--r--tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp12
-rw-r--r--tests/auto/quick/qquicktableview/data/columnwidthboundtoviewwidth.qml40
-rw-r--r--tests/auto/quick/qquicktableview/data/syncviewsimple.qml26
-rw-r--r--tests/auto/quick/qquicktableview/data/tableviewinteractive.qml32
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp183
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp155
-rw-r--r--tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml4
-rw-r--r--tests/auto/quick/qquicktextedit/data/threeLines.qml7
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp573
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp526
-rw-r--r--tests/auto/quick/qquicktreeview/testmodel.cpp10
-rw-r--r--tests/auto/quick/qquicktreeview/testmodel.h2
-rw-r--r--tests/auto/quick/qquicktreeview/tst_qquicktreeview.cpp236
-rw-r--r--tests/auto/quick/qquickview/tst_qquickview.cpp6
-rw-r--r--tests/auto/quick/qquickview_extra/tst_qquickview_extra.cpp2
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp116
-rw-r--r--tests/auto/quick/qquickwindow/data/shortcutOverride.qml30
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp80
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp109
-rw-r--r--tests/auto/quickcontrols2/CMakeLists.txt2
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_dialog.qml4
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_popup.qml38
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_scrollview.qml84
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_splitview.qml62
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_stackview.qml52
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml21
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_tooltip.qml8
-rw-r--r--tests/auto/quickcontrols2/cursor/BLACKLIST3
-rw-r--r--tests/auto/quickcontrols2/customization/tst_customization.cpp6
-rw-r--r--tests/auto/quickcontrols2/focus/tst_focus.cpp4
-rw-r--r--tests/auto/quickcontrols2/platform/CMakeLists.txt1
-rw-r--r--tests/auto/quickcontrols2/platform/data/tst_menu.qml71
-rw-r--r--tests/auto/quickcontrols2/platform/tst_platform.cpp28
-rw-r--r--tests/auto/quickcontrols2/pointerhandlers/data/draggableButton.qml11
-rw-r--r--tests/auto/quickcontrols2/pointerhandlers/data/tapHandlerButton.qml12
-rw-r--r--tests/auto/quickcontrols2/pointerhandlers/tst_pointerhandlers.cpp135
-rw-r--r--tests/auto/quickcontrols2/pressandhold/tst_pressandhold.cpp36
-rw-r--r--tests/auto/quickcontrols2/qquickapplicationwindow/tst_qquickapplicationwindow.cpp16
-rw-r--r--tests/auto/quickcontrols2/qquickcontrol/tst_qquickcontrol.cpp6
-rw-r--r--tests/auto/quickcontrols2/qquickdrawer/data/itemPartialOverlayModal.qml13
-rw-r--r--tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp256
-rw-r--r--tests/auto/quickcontrols2/qquickheaderview/tst_qquickheaderview.cpp6
-rw-r--r--tests/auto/quickcontrols2/qquickiconlabel/tst_qquickiconlabel.cpp2
-rw-r--r--tests/auto/quickcontrols2/qquickimaginestyle/data/tst_imagine.qml4
-rw-r--r--tests/auto/quickcontrols2/qquickmaterialstyle/CMakeLists.txt1
-rw-r--r--tests/auto/quickcontrols2/qquickmaterialstyle/data/tst_material.qml127
-rw-r--r--tests/auto/quickcontrols2/qquickmaterialstyle/tst_qquickmaterialstyle.cpp39
-rw-r--r--tests/auto/quickcontrols2/qquickmenu/data/popup.qml2
-rw-r--r--tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp12
-rw-r--r--tests/auto/quickcontrols2/qquickmenubar/tst_qquickmenubar.cpp6
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt6
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/logo.pkmbin0 -> 32784 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/o1_bc1.ktxbin0 -> 2116 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/qt4.astcbin0 -> 12816 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp61
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/data/applicationwindow-wheel.qml9
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/data/mirroredCombobox.qml26
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/data/nested-wheel.qml44
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/data/rotatedCombobox.qml26
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/data/window-wheel.qml9
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp512
-rw-r--r--tests/auto/quickcontrols2/qquicktextarea/CMakeLists.txt46
-rw-r--r--tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_default.qml6
-rw-r--r--tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_old_default.qml6
-rw-r--r--tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_old_overridden.qml7
-rw-r--r--tests/auto/quickcontrols2/qquicktextarea/data/twoInAColumn.qml35
-rw-r--r--tests/auto/quickcontrols2/qquicktextarea/tst_qquicktextarea.cpp166
-rw-r--r--tests/auto/quickcontrols2/qquicktextfield/CMakeLists.txt46
-rw-r--r--tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_default.qml7
-rw-r--r--tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_old_default.qml7
-rw-r--r--tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_old_overridden.qml8
-rw-r--r--tests/auto/quickcontrols2/qquicktextfield/tst_qquicktextfield.cpp101
-rw-r--r--tests/auto/quickcontrols2/qquicktreeviewdelegate/BLACKLIST6
-rw-r--r--tests/auto/quickcontrols2/qquicktreeviewdelegate/data/unmodified.qml6
-rw-r--r--tests/auto/quickcontrols2/qquicktreeviewdelegate/testmodel.cpp4
-rw-r--r--tests/auto/quickcontrols2/qquicktreeviewdelegate/tst_qquicktreeviewdelegate.cpp115
-rw-r--r--tests/auto/quickcontrols2/styleimports/tst_styleimports.cpp8
-rw-r--r--tests/auto/quickcontrols2/translation/tst_translation.cpp2
-rw-r--r--tests/auto/quickdialogs/qquickcolordialogimpl/tst_qquickcolordialogimpl.cpp56
-rw-r--r--tests/auto/quickdialogs/qquickfiledialogimpl/tst_qquickfiledialogimpl.cpp71
-rw-r--r--tests/auto/quickdialogs/qquickfolderdialogimpl/tst_qquickfolderdialogimpl.cpp36
-rw-r--r--tests/auto/quickdialogs/qquickfontdialogimpl/tst_qquickfontdialogimpl.cpp28
-rw-r--r--tests/auto/quickdialogs/qquickmessagedialogimpl/tst_qquickmessagedialogimpl.cpp18
-rw-r--r--tests/auto/quicktest/signalspy/tst_signalspy.cpp2
-rw-r--r--tests/auto/quickwidgets/qquickwidget/CMakeLists.txt1
-rw-r--r--tests/auto/quickwidgets/qquickwidget/data/button.qml27
-rw-r--r--tests/auto/quickwidgets/qquickwidget/data/mouse.qml2
-rw-r--r--tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp106
-rw-r--r--tests/baseline/controls/tst_baseline_controls.cpp6
-rw-r--r--tests/baseline/scenegraph/data/text/text_nativerendering_no_antialiasing.qml25
-rw-r--r--tests/baseline/scenegraph/scenegraph/tst_baseline_scenegraph.cpp6
-rw-r--r--tests/benchmarks/particles/affectors/tst_affectors.cpp4
-rw-r--r--tests/benchmarks/particles/emission/tst_emission.cpp2
-rw-r--r--tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp8
-rw-r--r--tests/benchmarks/qml/qqmlchangeset/CMakeLists.txt4
-rw-r--r--tests/benchmarks/quickcontrols2/creationtime/CMakeLists.txt6
-rw-r--r--tests/benchmarks/quickcontrols2/creationtime/tst_creationtime.cpp6
-rw-r--r--tests/benchmarks/quickcontrols2/objectcount/CMakeLists.txt6
-rw-r--r--tests/benchmarks/quickcontrols2/objectcount/tst_objectcount.cpp9
-rw-r--r--tests/manual/pointer/pinchNullTarget.qml50
-rw-r--r--tests/manual/quickcontrols2/headerview/main.qml20
-rw-r--r--tests/manual/quickcontrols2/testbench/controls/Button.qml35
-rw-r--r--tools/qml/main.cpp10
-rw-r--r--tools/qmlcachegen/qmlcachegen.cpp6
-rw-r--r--tools/qmlcachegen/qtquickcompiler.prf1
-rw-r--r--tools/qmldom/qmldomtool.cpp6
-rw-r--r--tools/qmleasing/splineeditor.cpp30
-rw-r--r--tools/qmlimportscanner/main.cpp8
-rw-r--r--tools/qmljs/qmljs.cpp2
-rw-r--r--tools/qmljsrootgen/main.cpp2
-rw-r--r--tools/qmllint/main.cpp3
-rw-r--r--tools/qmlls/qlanguageserver.cpp2
-rw-r--r--tools/qmlls/qmlcompletionsupport.cpp16
-rw-r--r--tools/qmlls/qmllanguageservertool.cpp44
-rw-r--r--tools/qmlls/qqmlcodemodel.cpp18
-rw-r--r--tools/qmlls/qqmllanguageserver.cpp2
-rw-r--r--tools/qmlls/textdocument.cpp12
-rw-r--r--tools/qmlls/workspace.cpp2
-rw-r--r--tools/qmlplugindump/main.cpp28
-rw-r--r--tools/qmlpreview/qmlpreviewfilesystemwatcher.cpp2
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp4
-rw-r--r--tools/qmlprofiler/qmlprofilerdata.cpp12
-rw-r--r--tools/qmlscene/main.cpp6
-rw-r--r--tools/qmltc/main.cpp21
-rw-r--r--tools/qmltc/qmltccodewriter.cpp28
-rw-r--r--tools/qmltc/qmltccommandlineutils.cpp2
-rw-r--r--tools/qmltc/qmltccompiler.cpp6
-rw-r--r--tools/qmltc/qmltccompilerpieces.h18
-rw-r--r--tools/qmltc/qmltcvisitor.cpp67
-rw-r--r--tools/shared/qqmltoolingsettings.cpp6
1257 files changed, 20912 insertions, 8576 deletions
diff --git a/.cmake.conf b/.cmake.conf
index c4253cfe7b..c6ceb92eef 100644
--- a/.cmake.conf
+++ b/.cmake.conf
@@ -1,4 +1,4 @@
-set(QT_REPO_MODULE_VERSION "6.4.0")
+set(QT_REPO_MODULE_VERSION "6.4.3")
set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_LEAN_HEADERS=1")
diff --git a/cmake/QtDeclarativeSetup.cmake b/cmake/QtDeclarativeSetup.cmake
index fd718c2d62..a33a97b528 100644
--- a/cmake/QtDeclarativeSetup.cmake
+++ b/cmake/QtDeclarativeSetup.cmake
@@ -7,6 +7,8 @@
function(qt_declarative_write_tag_header target_name)
set(out_file "${CMAKE_CURRENT_BINARY_DIR}/qml_compile_hash_p.h")
if(FEATURE_developer_build AND EXISTS "${out_file}")
+ target_sources(${target_name} PRIVATE "${out_file}")
+ set_source_files_properties("${out_file}" PROPERTIES GENERATED TRUE)
return()
endif()
diff --git a/coin/module_config.yaml b/coin/module_config.yaml
index aaf3323822..9acb62722c 100644
--- a/coin/module_config.yaml
+++ b/coin/module_config.yaml
@@ -4,6 +4,12 @@ accept_configuration:
property: features
not_contains_value: Disable
+machine_type:
+ Build:
+ cores: 8
+ Test:
+ cores: 4
+
instructions:
Build:
- !include "{{qt/qtbase}}/coin_module_build_template_v2.yaml"
diff --git a/dependencies.yaml b/dependencies.yaml
index 4c2dc33461..c6b925d3e6 100644
--- a/dependencies.yaml
+++ b/dependencies.yaml
@@ -1,16 +1,16 @@
dependencies:
../qtbase:
- ref: a2334fd51099333a5f86ec3f57498d3f394d105e
+ ref: 4822af4f41a8b39bf631f9f02e1a35f40a76ecc5
required: true
../qtimageformats:
- ref: 1aedb1a8e2eaaff9964422fd1c4a2ee62ff6d556
+ ref: ddab3c4dc260ba9cca4ff593c6ccf1c99f069b6a
required: false
../qtlanguageserver:
- ref: f44590970021ca3a0d92ac53390b3ab0569c0292
+ ref: cf0427ff597bc1ad3dd9ed1f8c1c136e305419cc
required: false
../qtshadertools:
- ref: 2bd5389736dd0ba2e07c9964d3b9d4b0bc04d499
+ ref: ec205234bce2f57f989d0700b2d0e0230a426656
required: false
../qtsvg:
- ref: f507246f38c0f384017850cdc3c0beb6966ac000
+ ref: 4ba7e78b2c9b2c5ee9f97a1638ab54accb938981
required: false
diff --git a/examples/qml/doc/src/qml-extending.qdoc b/examples/qml/doc/src/qml-extending.qdoc
index 03df998823..5d92f0a51c 100644
--- a/examples/qml/doc/src/qml-extending.qdoc
+++ b/examples/qml/doc/src/qml-extending.qdoc
@@ -240,6 +240,12 @@ This example builds on:
\brief Attached Properties.
\ingroup qmlextendingexamples
+This example demonstrates how to create custom
+\l {Attached Properties and Attached Signal Handlers} {attached properties}.
+For a more in-depth description on how one can create attached properties,
+see \l {Providing Attached Properties}.
+
+
This example builds on:
\list
\li \l {Extending QML - Grouped Properties Example}
diff --git a/examples/qml/dynamicscene/dynamicscene.qml b/examples/qml/dynamicscene/dynamicscene.qml
index cec8c803e8..62795703c5 100644
--- a/examples/qml/dynamicscene/dynamicscene.qml
+++ b/examples/qml/dynamicscene/dynamicscene.qml
@@ -210,7 +210,7 @@ Item {
selectByMouse: true
wrapMode: TextEdit.WordWrap
- text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 40 * Math.random() \n source: 'images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}"
+ text: "import QtQuick\nImage {\n id: smile\n x: 360 * Math.random()\n y: 40 * Math.random() \n source: 'images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}"
}
}
}
diff --git a/examples/qml/locale/locale.qml b/examples/qml/locale/locale.qml
index 5ef0c58fc1..35875a3177 100644
--- a/examples/qml/locale/locale.qml
+++ b/examples/qml/locale/locale.qml
@@ -1,13 +1,26 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: root
width: 320
height: 480
color: "lightgray"
+ property list<string> locales: ([
+ "en_US",
+ "en_GB",
+ "fi_FI",
+ "de_DE",
+ "ar_SA",
+ "hi_IN",
+ "zh_CN",
+ "th_TH",
+ "fr_FR",
+ "nb_NO",
+ "sv_SE"
+ ])
component LocaleDelegate: Text {
required property var modelData
@@ -23,7 +36,7 @@ Rectangle {
}
}
- property string locale: (view.currentItem as LocaleDelegate).locale
+ property string locale: view.currentIndex === -1 ? "en_US" : root.locales[view.currentIndex]
Text {
id: title
@@ -43,19 +56,7 @@ Rectangle {
clip: true
focus: true
anchors.fill: parent
- model: [
- "en_US",
- "en_GB",
- "fi_FI",
- "de_DE",
- "ar_SA",
- "hi_IN",
- "zh_CN",
- "th_TH",
- "fr_FR",
- "nb_NO",
- "sv_SE"
- ]
+ model: root.locales
delegate: LocaleDelegate {}
highlight: Rectangle {
diff --git a/examples/qml/networkaccessmanagerfactory/view.qml b/examples/qml/networkaccessmanagerfactory/view.qml
index 6b8593df00..f3c845fabd 100644
--- a/examples/qml/networkaccessmanagerfactory/view.qml
+++ b/examples/qml/networkaccessmanagerfactory/view.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Image {
width: 200
diff --git a/examples/qml/qml-i18n/qml-i18n.qml b/examples/qml/qml-i18n/qml-i18n.qml
index 94de1fb3b3..8d414348dd 100644
--- a/examples/qml/qml-i18n/qml-i18n.qml
+++ b/examples/qml/qml-i18n/qml-i18n.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.12
-import QtQuick.Window 2.12
+import QtQuick
+import QtQuick.Window
Window {
visible: true
diff --git a/examples/qml/qmlextensionplugins/imports/TimeExample/Clock.qml b/examples/qml/qmlextensionplugins/imports/TimeExample/Clock.qml
index e74f99c20c..b071e2e031 100644
--- a/examples/qml/qmlextensionplugins/imports/TimeExample/Clock.qml
+++ b/examples/qml/qmlextensionplugins/imports/TimeExample/Clock.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: clock
diff --git a/examples/qml/qmlextensionplugins/plugins.qml b/examples/qml/qmlextensionplugins/plugins.qml
index 322f9590ed..55e8903400 100644
--- a/examples/qml/qmlextensionplugins/plugins.qml
+++ b/examples/qml/qmlextensionplugins/plugins.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import TimeExample 1.0 // import types from the plugin
+import TimeExample // import types from the plugin
Clock { // this class is defined in QML (imports/TimeExample/Clock.qml)
diff --git a/examples/qml/referenceexamples/adding/example.qml b/examples/qml/referenceexamples/adding/example.qml
index 2e3a40e2ac..068352bc35 100644
--- a/examples/qml/referenceexamples/adding/example.qml
+++ b/examples/qml/referenceexamples/adding/example.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
// ![0]
-import People 1.0
+import People
Person {
name: "Bob Jones"
diff --git a/examples/qml/referenceexamples/attached/example.qml b/examples/qml/referenceexamples/attached/example.qml
index 7b2c2cbf86..a4e675fe51 100644
--- a/examples/qml/referenceexamples/attached/example.qml
+++ b/examples/qml/referenceexamples/attached/example.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import People 1.0
-import QtQuick 2.0 // For QColor
+import People
+import QtQuick // For QColor
//! [begin]
BirthdayParty {
diff --git a/examples/qml/referenceexamples/binding/example.qml b/examples/qml/referenceexamples/binding/example.qml
index 92b5cbbc7a..262d667903 100644
--- a/examples/qml/referenceexamples/binding/example.qml
+++ b/examples/qml/referenceexamples/binding/example.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import People 1.0
-import QtQuick 2.0 // For QColor
+import People
+import QtQuick // For QColor
// ![0]
BirthdayParty {
diff --git a/examples/qml/referenceexamples/coercion/example.qml b/examples/qml/referenceexamples/coercion/example.qml
index fd48ed5bc8..99469bec57 100644
--- a/examples/qml/referenceexamples/coercion/example.qml
+++ b/examples/qml/referenceexamples/coercion/example.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import People 1.0
+import People
// ![0]
BirthdayParty {
diff --git a/examples/qml/referenceexamples/default/example.qml b/examples/qml/referenceexamples/default/example.qml
index 4b23836860..addc74dfb5 100644
--- a/examples/qml/referenceexamples/default/example.qml
+++ b/examples/qml/referenceexamples/default/example.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import People 1.0
+import People
// ![0]
BirthdayParty {
diff --git a/examples/qml/referenceexamples/extended/example.qml b/examples/qml/referenceexamples/extended/example.qml
index 8a628de26a..8a0b3193d8 100644
--- a/examples/qml/referenceexamples/extended/example.qml
+++ b/examples/qml/referenceexamples/extended/example.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import People 1.0
+import People
// ![0]
QLineEdit {
diff --git a/examples/qml/referenceexamples/grouped/example.qml b/examples/qml/referenceexamples/grouped/example.qml
index 95f5bc1ebe..31d122e647 100644
--- a/examples/qml/referenceexamples/grouped/example.qml
+++ b/examples/qml/referenceexamples/grouped/example.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import People 1.0
-import QtQuick 2.0 // For QColor
+import People
+import QtQuick // For QColor
// ![0]
BirthdayParty {
diff --git a/examples/qml/referenceexamples/methods/example.qml b/examples/qml/referenceexamples/methods/example.qml
index 295a14c498..41d053edd2 100644
--- a/examples/qml/referenceexamples/methods/example.qml
+++ b/examples/qml/referenceexamples/methods/example.qml
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
// ![0]
-import QtQuick 2.0
-import People 1.0
+import QtQuick
+import People
BirthdayParty {
host: Person {
diff --git a/examples/qml/referenceexamples/properties/example.qml b/examples/qml/referenceexamples/properties/example.qml
index a4d9a1e532..52fb3344f0 100644
--- a/examples/qml/referenceexamples/properties/example.qml
+++ b/examples/qml/referenceexamples/properties/example.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import People 1.0
+import People
// ![0]
BirthdayParty {
diff --git a/examples/qml/referenceexamples/signal/example.qml b/examples/qml/referenceexamples/signal/example.qml
index feacf5d8bf..c35db2fe46 100644
--- a/examples/qml/referenceexamples/signal/example.qml
+++ b/examples/qml/referenceexamples/signal/example.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import People 1.0
-import QtQuick 2.0 // For QColor
+import People
+import QtQuick // For QColor
BirthdayParty {
// ![0]
diff --git a/examples/qml/referenceexamples/valuesource/example.qml b/examples/qml/referenceexamples/valuesource/example.qml
index 4166cda1f6..b6efe211c1 100644
--- a/examples/qml/referenceexamples/valuesource/example.qml
+++ b/examples/qml/referenceexamples/valuesource/example.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import People 1.0
-import QtQuick 2.0 // For QColor
+import People
+import QtQuick // For QColor
// ![0]
BirthdayParty {
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt
index 4fdc3a749b..a5cc93c6f3 100644
--- a/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter1-basics/CMakeLists.txt
@@ -33,6 +33,7 @@ qt_add_qml_module(chapter1-basics
VERSION 1.0
QML_FILES app.qml
NO_RESOURCE_TARGET_PATH
+ DEPENDENCIES QtQuick
)
#![0]
install(TARGETS chapter1-basics
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/app.qml b/examples/qml/tutorials/extending-qml/chapter1-basics/app.qml
index 2e24522bb5..ed89ce97c4 100644
--- a/examples/qml/tutorials/extending-qml/chapter1-basics/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter1-basics/app.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import Charts 1.0
-import QtQuick 2.0
+import Charts
+import QtQuick
Item {
width: 300; height: 200
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h b/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h
index 6b39295e8d..a438cafbfb 100644
--- a/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h
@@ -10,8 +10,8 @@
class PieChart : public QQuickPaintedItem
{
Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(QString name READ name WRITE setName FINAL)
+ Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
QML_ELEMENT
public:
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt
index f6eee234bc..95f4f19315 100644
--- a/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter2-methods/CMakeLists.txt
@@ -33,6 +33,7 @@ qt_add_qml_module(chapter2-methods
VERSION 1.0
QML_FILES app.qml
NO_RESOURCE_TARGET_PATH
+ DEPENDENCIES QtQuick
)
install(TARGETS chapter2-methods
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/app.qml b/examples/qml/tutorials/extending-qml/chapter2-methods/app.qml
index 2204796772..56597c3f42 100644
--- a/examples/qml/tutorials/extending-qml/chapter2-methods/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter2-methods/app.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import Charts 1.0
-import QtQuick 2.0
+import Charts
+import QtQuick
Item {
width: 300; height: 200
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h b/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h
index 07eb48ceda..d1eb5f1359 100644
--- a/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h
@@ -11,8 +11,8 @@ class PieChart : public QQuickPaintedItem
{
//![0]
Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(QString name READ name WRITE setName FINAL)
+ Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
QML_ELEMENT
//![1]
public:
diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt
index 585821669b..502cc8f3ce 100644
--- a/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/CMakeLists.txt
@@ -33,6 +33,7 @@ qt_add_qml_module(chapter3-bindings
VERSION 1.0
QML_FILES app.qml
NO_RESOURCE_TARGET_PATH
+ DEPENDENCIES QtQuick
)
install(TARGETS chapter3-bindings
diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/app.qml b/examples/qml/tutorials/extending-qml/chapter3-bindings/app.qml
index 2262941170..d29eaf4b9f 100644
--- a/examples/qml/tutorials/extending-qml/chapter3-bindings/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/app.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import Charts 1.0
-import QtQuick 2.0
+import Charts
+import QtQuick
Item {
width: 300; height: 200
diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h b/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h
index a6be1b559c..449d0f80a8 100644
--- a/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h
@@ -11,11 +11,11 @@ class PieChart : public QQuickPaintedItem
{
//![0]
Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString name READ name WRITE setName FINAL)
QML_ELEMENT
//![1]
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
public:
//![1]
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt
index eeddbcfc14..c7263d103b 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/CMakeLists.txt
@@ -34,6 +34,7 @@ qt_add_qml_module(chapter4-customPropertyTypes
VERSION 1.0
QML_FILES app.qml
NO_RESOURCE_TARGET_PATH
+ DEPENDENCIES QtQuick
)
#![1]
install(TARGETS chapter4-customPropertyTypes
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/app.qml b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/app.qml
index 34d8d4196d..2edcda568e 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/app.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import Charts 1.0
-import QtQuick 2.0
+import Charts
+import QtQuick
Item {
width: 300; height: 200
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h
index e684d9c7e8..0c4088435f 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h
@@ -11,9 +11,9 @@ class PieSlice;
class PieChart : public QQuickItem
{
Q_OBJECT
- Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice)
+ Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice FINAL)
//![0]
- Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString name READ name WRITE setName FINAL)
Q_MOC_INCLUDE("pieslice.h")
QML_ELEMENT
//![1]
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h
index d291272eaf..74c6149e85 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h
@@ -10,7 +10,7 @@
class PieSlice : public QQuickPaintedItem
{
Q_OBJECT
- Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
QML_ELEMENT
public:
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt
index e5a843efb4..210d33115b 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/CMakeLists.txt
@@ -34,6 +34,7 @@ qt_add_qml_module(chapter5-listproperties
VERSION 1.0
QML_FILES app.qml
NO_RESOURCE_TARGET_PATH
+ DEPENDENCIES QtQuick
)
install(TARGETS chapter5-listproperties
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/app.qml b/examples/qml/tutorials/extending-qml/chapter5-listproperties/app.qml
index cd9b7918fc..9e200a9b60 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/app.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import Charts 1.0
-import QtQuick 2.0
+import Charts
+import QtQuick
Item {
width: 300; height: 200
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h b/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h
index 749c12d622..05f0f1ddad 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h
@@ -11,9 +11,9 @@ class PieSlice;
class PieChart : public QQuickItem
{
Q_OBJECT
- Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices FINAL)
//![0]
- Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString name READ name WRITE setName FINAL)
QML_ELEMENT
//![1]
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h b/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h
index 318234f92b..14efaffcc8 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h
@@ -10,9 +10,9 @@
class PieSlice : public QQuickPaintedItem
{
Q_OBJECT
- Q_PROPERTY(QColor color READ color WRITE setColor)
- Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
- Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+ Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
+ Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle FINAL)
+ Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan FINAL)
QML_ELEMENT
//![0]
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
index f76011e2f8..da4c649864 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/CMakeLists.txt
@@ -2,6 +2,7 @@ qt6_add_qml_module(chartsplugin
VERSION 1.0
URI "Charts"
PLUGIN_TARGET chartsplugin
+ DEPENDENCIES QtQuick
)
target_sources(chartsplugin PRIVATE
@@ -45,3 +46,5 @@ install(TARGETS chartsplugin
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
+ DESTINATION "${INSTALL_EXAMPLEDIR}")
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.h
index 2c50be16cf..6c771e9814 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/piechart.h
@@ -10,8 +10,8 @@ class PieSlice;
class PieChart : public QQuickItem
{
Q_OBJECT
- Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
- Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices FINAL)
+ Q_PROPERTY(QString name READ name WRITE setName FINAL)
QML_ELEMENT
public:
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.h
index a8987f00fc..b07773c29f 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.h
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/Charts/pieslice.h
@@ -9,9 +9,9 @@
class PieSlice : public QQuickPaintedItem
{
Q_OBJECT
- Q_PROPERTY(QColor color READ color WRITE setColor)
- Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
- Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+ Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
+ Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle FINAL)
+ Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan FINAL)
QML_ELEMENT
public:
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.qml b/examples/qml/tutorials/extending-qml/chapter6-plugins/app.qml
index fe1d2e2199..1d1cb74176 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.qml
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/app.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import Charts 1.0
+import QtQuick
+import Charts
Item {
width: 300; height: 200
diff --git a/examples/qmltest/qmltest/tst_basic.qml b/examples/qmltest/qmltest/tst_basic.qml
index 7ea69b1f76..e3ce172beb 100644
--- a/examples/qmltest/qmltest/tst_basic.qml
+++ b/examples/qmltest/qmltest/tst_basic.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.4
-import QtTest 1.1
+import QtQuick
+import QtTest
TestCase {
name: "BasicTests"
diff --git a/examples/qmltest/qmltest/tst_item.qml b/examples/qmltest/qmltest/tst_item.qml
index fbe2a28f49..047bd254dd 100644
--- a/examples/qmltest/qmltest/tst_item.qml
+++ b/examples/qmltest/qmltest/tst_item.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.4
-import QtTest 1.1
+import QtQuick
+import QtTest
Rectangle {
id: foo
diff --git a/examples/quick/animation/animation.qml b/examples/quick/animation/animation.qml
index 1c21445d08..75e6b86b29 100644
--- a/examples/quick/animation/animation.qml
+++ b/examples/quick/animation/animation.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import shared as Examples
Item {
diff --git a/examples/quick/animation/basics/animators.qml b/examples/quick/animation/basics/animators.qml
index 9927acf9c5..80765d21d4 100644
--- a/examples/quick/animation/basics/animators.qml
+++ b/examples/quick/animation/basics/animators.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.2
+import QtQuick
Item {
id: window
diff --git a/examples/quick/animation/basics/color-animation.qml b/examples/quick/animation/basics/color-animation.qml
index 80c627b02f..6427e06ad2 100644
--- a/examples/quick/animation/basics/color-animation.qml
+++ b/examples/quick/animation/basics/color-animation.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
Item {
id: window
diff --git a/examples/quick/animation/basics/property-animation.qml b/examples/quick/animation/basics/property-animation.qml
index 0e2f3980ef..cd9b8277f5 100644
--- a/examples/quick/animation/basics/property-animation.qml
+++ b/examples/quick/animation/basics/property-animation.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQml 2.0
-import QtQuick 2.0
+import QtQml
+import QtQuick
Item {
id: window
diff --git a/examples/quick/animation/behaviors/FocusRect.qml b/examples/quick/animation/behaviors/FocusRect.qml
index acd16b6219..9841162e57 100644
--- a/examples/quick/animation/behaviors/FocusRect.qml
+++ b/examples/quick/animation/behaviors/FocusRect.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: focusRect
diff --git a/examples/quick/animation/behaviors/SideRect.qml b/examples/quick/animation/behaviors/SideRect.qml
index d961fe149e..5230e5a406 100644
--- a/examples/quick/animation/behaviors/SideRect.qml
+++ b/examples/quick/animation/behaviors/SideRect.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: myRect
diff --git a/examples/quick/animation/behaviors/behavior-example.qml b/examples/quick/animation/behaviors/behavior-example.qml
index a92212350d..c994ec18d9 100644
--- a/examples/quick/animation/behaviors/behavior-example.qml
+++ b/examples/quick/animation/behaviors/behavior-example.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
width: 320; height: 480
diff --git a/examples/quick/animation/behaviors/tvtennis.qml b/examples/quick/animation/behaviors/tvtennis.qml
index 9774b26d17..0b8ba15ad7 100644
--- a/examples/quick/animation/behaviors/tvtennis.qml
+++ b/examples/quick/animation/behaviors/tvtennis.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: page
diff --git a/examples/quick/animation/behaviors/wigglytext.qml b/examples/quick/animation/behaviors/wigglytext.qml
index c03cedafee..712078866d 100644
--- a/examples/quick/animation/behaviors/wigglytext.qml
+++ b/examples/quick/animation/behaviors/wigglytext.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQml 2.0
-import QtQuick 2.0
+import QtQml
+import QtQuick
Rectangle {
id: container
diff --git a/examples/quick/animation/easing/easing.qml b/examples/quick/animation/easing/easing.qml
index ad735c77b7..26272f3c0f 100644
--- a/examples/quick/animation/easing/easing.qml
+++ b/examples/quick/animation/easing/easing.qml
@@ -1,9 +1,9 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQml 2.15
-import QtQml.Models 2.15
-import QtQuick 2.0
+import QtQml
+import QtQml.Models
+import QtQuick
Rectangle {
id: window
diff --git a/examples/quick/animation/pathanimation/pathanimation.qml b/examples/quick/animation/pathanimation/pathanimation.qml
index 96202fc04e..1f3577a47c 100644
--- a/examples/quick/animation/pathanimation/pathanimation.qml
+++ b/examples/quick/animation/pathanimation/pathanimation.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQml 2.0
-import QtQuick 2.0
+import QtQml
+import QtQuick
Rectangle {
id: window
diff --git a/examples/quick/animation/pathinterpolator/pathinterpolator.qml b/examples/quick/animation/pathinterpolator/pathinterpolator.qml
index 3051f06728..a035e9ba0c 100644
--- a/examples/quick/animation/pathinterpolator/pathinterpolator.qml
+++ b/examples/quick/animation/pathinterpolator/pathinterpolator.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQml 2.0
-import QtQuick 2.0
+import QtQml
+import QtQuick
Rectangle {
id: window
diff --git a/examples/quick/animation/states/states.qml b/examples/quick/animation/states/states.qml
index 7145c9ed0b..78a8c0668b 100644
--- a/examples/quick/animation/states/states.qml
+++ b/examples/quick/animation/states/states.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQml 2.0
-import QtQuick 2.0
+import QtQml
+import QtQuick
Rectangle {
id: page
diff --git a/examples/quick/animation/states/transitions.qml b/examples/quick/animation/states/transitions.qml
index b8031cf0e0..a318bc82b0 100644
--- a/examples/quick/animation/states/transitions.qml
+++ b/examples/quick/animation/states/transitions.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
/*
This is exactly the same as states.qml, except that we have appended
diff --git a/examples/quick/customitems/dialcontrol/Dial.qml b/examples/quick/customitems/dialcontrol/Dial.qml
index f69b93ce97..7e3b8cbd87 100644
--- a/examples/quick/customitems/dialcontrol/Dial.qml
+++ b/examples/quick/customitems/dialcontrol/Dial.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Item {
id: root
diff --git a/examples/quick/customitems/dialcontrol/QuitButton.qml b/examples/quick/customitems/dialcontrol/QuitButton.qml
index fd6d7899e2..af362b6ddf 100644
--- a/examples/quick/customitems/dialcontrol/QuitButton.qml
+++ b/examples/quick/customitems/dialcontrol/QuitButton.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Image {
source: "quit.png"
scale: quitMouse.pressed ? 0.8 : 1.0
diff --git a/examples/quick/customitems/dialcontrol/dialcontrol.qml b/examples/quick/customitems/dialcontrol/dialcontrol.qml
index ec9fe0ee5c..d30f66fa2c 100644
--- a/examples/quick/customitems/dialcontrol/dialcontrol.qml
+++ b/examples/quick/customitems/dialcontrol/dialcontrol.qml
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [imports]
-import QtQuick 2.2
-import QtQuick.Window 2.1
+import QtQuick
+import QtQuick.Window
//! [imports]
//! [0]
diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.qml b/examples/quick/customitems/maskedmousearea/maskedmousearea.qml
index 521da6c723..df8de3dcb8 100644
--- a/examples/quick/customitems/maskedmousearea/maskedmousearea.qml
+++ b/examples/quick/customitems/maskedmousearea/maskedmousearea.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import Example 1.0
+import QtQuick
+import Example
Rectangle {
height: 480
diff --git a/examples/quick/customitems/painteditem/textballoons.qml b/examples/quick/customitems/painteditem/textballoons.qml
index 156e63c015..d363093d95 100644
--- a/examples/quick/customitems/painteditem/textballoons.qml
+++ b/examples/quick/customitems/painteditem/textballoons.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import TextBalloon 1.0
+import QtQuick
+import TextBalloon
Item {
height: 480
diff --git a/examples/quick/customitems/progressbar/content/ProgressBar.qml b/examples/quick/customitems/progressbar/content/ProgressBar.qml
index f1a343fb45..f97ab90709 100644
--- a/examples/quick/customitems/progressbar/content/ProgressBar.qml
+++ b/examples/quick/customitems/progressbar/content/ProgressBar.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Item {
id: progressbar
diff --git a/examples/quick/customitems/progressbar/main.qml b/examples/quick/customitems/progressbar/main.qml
index 441d82bc45..7b281aeb90 100644
--- a/examples/quick/customitems/progressbar/main.qml
+++ b/examples/quick/customitems/progressbar/main.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import "content"
Rectangle {
diff --git a/examples/quick/customitems/scrollbar/ScrollBar.qml b/examples/quick/customitems/scrollbar/ScrollBar.qml
index b3cba5b6d8..1df14ddba8 100644
--- a/examples/quick/customitems/scrollbar/ScrollBar.qml
+++ b/examples/quick/customitems/scrollbar/ScrollBar.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Item {
id: scrollBar
diff --git a/examples/quick/customitems/scrollbar/main.qml b/examples/quick/customitems/scrollbar/main.qml
index 4a4378ff42..61b6453c03 100644
--- a/examples/quick/customitems/scrollbar/main.qml
+++ b/examples/quick/customitems/scrollbar/main.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
width: 640
diff --git a/examples/quick/customitems/searchbox/SearchBox.qml b/examples/quick/customitems/searchbox/SearchBox.qml
index 2d47d80ea2..205e691508 100644
--- a/examples/quick/customitems/searchbox/SearchBox.qml
+++ b/examples/quick/customitems/searchbox/SearchBox.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
FocusScope {
id: focusScope
diff --git a/examples/quick/customitems/searchbox/main.qml b/examples/quick/customitems/searchbox/main.qml
index f5b7634c90..f250c4067d 100644
--- a/examples/quick/customitems/searchbox/main.qml
+++ b/examples/quick/customitems/searchbox/main.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: page
diff --git a/examples/quick/customitems/slideswitch/content/Switch.qml b/examples/quick/customitems/slideswitch/content/Switch.qml
index 9736d37b3f..38beefb8c4 100644
--- a/examples/quick/customitems/slideswitch/content/Switch.qml
+++ b/examples/quick/customitems/slideswitch/content/Switch.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.0
+import QtQuick
Item {
id: toggleswitch
diff --git a/examples/quick/customitems/slideswitch/slideswitch.qml b/examples/quick/customitems/slideswitch/slideswitch.qml
index 75cc3c3aa9..430c46c6dd 100644
--- a/examples/quick/customitems/slideswitch/slideswitch.qml
+++ b/examples/quick/customitems/slideswitch/slideswitch.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import "content"
Rectangle {
diff --git a/examples/quick/customitems/spinner/content/Spinner.qml b/examples/quick/customitems/spinner/content/Spinner.qml
index f698078774..c5f2a2b4ed 100644
--- a/examples/quick/customitems/spinner/content/Spinner.qml
+++ b/examples/quick/customitems/spinner/content/Spinner.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Image {
property alias model: view.model
diff --git a/examples/quick/customitems/spinner/main.qml b/examples/quick/customitems/spinner/main.qml
index 8da8db749c..e6b674fc53 100644
--- a/examples/quick/customitems/spinner/main.qml
+++ b/examples/quick/customitems/spinner/main.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import "content"
Rectangle {
diff --git a/examples/quick/customitems/tabwidget/TabWidget.qml b/examples/quick/customitems/tabwidget/TabWidget.qml
index 6810a4e200..f031cd8beb 100644
--- a/examples/quick/customitems/tabwidget/TabWidget.qml
+++ b/examples/quick/customitems/tabwidget/TabWidget.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Item {
id: tabWidget
diff --git a/examples/quick/customitems/tabwidget/main.qml b/examples/quick/customitems/tabwidget/main.qml
index 9158e44da9..ef73847f66 100644
--- a/examples/quick/customitems/tabwidget/main.qml
+++ b/examples/quick/customitems/tabwidget/main.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
TabWidget {
id: tabs
diff --git a/examples/quick/delegatechooser/delegatechooser.qml b/examples/quick/delegatechooser/delegatechooser.qml
index cf45e3e1c9..9e7eff9fdc 100644
--- a/examples/quick/delegatechooser/delegatechooser.qml
+++ b/examples/quick/delegatechooser/delegatechooser.qml
@@ -1,10 +1,10 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.12
-import QtQml.Models 2.12
-import QtQuick.Layouts 1.12
-import Qt.labs.qmlmodels 1.0
+import QtQuick
+import QtQml.Models
+import QtQuick.Layouts
+import Qt.labs.qmlmodels
import shared
Rectangle {
diff --git a/examples/quick/draganddrop/tiles/DragTile.qml b/examples/quick/draganddrop/tiles/DragTile.qml
index 41813ecc19..c4d81a7662 100644
--- a/examples/quick/draganddrop/tiles/DragTile.qml
+++ b/examples/quick/draganddrop/tiles/DragTile.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
//! [0]
Item {
diff --git a/examples/quick/draganddrop/tiles/DropTile.qml b/examples/quick/draganddrop/tiles/DropTile.qml
index 0746992ce9..86fdbd86b3 100644
--- a/examples/quick/draganddrop/tiles/DropTile.qml
+++ b/examples/quick/draganddrop/tiles/DropTile.qml
@@ -1,14 +1,13 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
//! [0]
DropArea {
id: dragTarget
property string colorKey
- property alias dropProxy: dragTarget
width: 64; height: 64
keys: [ colorKey ]
@@ -17,16 +16,7 @@ DropArea {
id: dropRectangle
anchors.fill: parent
- color: dragTarget.colorKey
-
- states: [
- State {
- when: dragTarget.containsDrag
- PropertyChanges {
- dropRectangle.color: "grey"
- }
- }
- ]
+ color: dragTarget.containsDrag ? "grey" : dragTarget.colorKey
}
}
//! [0]
diff --git a/examples/quick/draganddrop/tiles/tiles.qml b/examples/quick/draganddrop/tiles/tiles.qml
index 542a2800af..62fb802972 100644
--- a/examples/quick/draganddrop/tiles/tiles.qml
+++ b/examples/quick/draganddrop/tiles/tiles.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: root
diff --git a/examples/quick/draganddrop/views/Icon.qml b/examples/quick/draganddrop/views/Icon.qml
index dcd5cb338d..ed5c6e51e5 100644
--- a/examples/quick/draganddrop/views/Icon.qml
+++ b/examples/quick/draganddrop/views/Icon.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.14
+import QtQuick
Rectangle {
id: icon
diff --git a/examples/quick/imageprovider/imageprovider-example.qml b/examples/quick/imageprovider/imageprovider-example.qml
index bd3bb0f47e..5bd092bc2d 100644
--- a/examples/quick/imageprovider/imageprovider-example.qml
+++ b/examples/quick/imageprovider/imageprovider-example.qml
@@ -1,6 +1,6 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import "ImageProviderCore" // import the plugin that registers the color image provider
//![0]
diff --git a/examples/quick/imageresponseprovider/imageresponseprovider-example.qml b/examples/quick/imageresponseprovider/imageresponseprovider-example.qml
index 2767dbff1d..980e25fb5b 100644
--- a/examples/quick/imageresponseprovider/imageresponseprovider-example.qml
+++ b/examples/quick/imageresponseprovider/imageresponseprovider-example.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2015 Canonical Limited and/or its subsidiary(-ies)
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import "ImageResponseProviderCore"
Column {
diff --git a/examples/quick/models/stringlistmodel/view.qml b/examples/quick/models/stringlistmodel/view.qml
index 134062cc9c..c94987a356 100644
--- a/examples/quick/models/stringlistmodel/view.qml
+++ b/examples/quick/models/stringlistmodel/view.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
//![0]
ListView {
diff --git a/examples/quick/particles/affectors/GreyButton.qml b/examples/quick/particles/affectors/GreyButton.qml
index 300d6981de..0d29246c2b 100644
--- a/examples/quick/particles/affectors/GreyButton.qml
+++ b/examples/quick/particles/affectors/GreyButton.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Item {
id: container
diff --git a/examples/quick/particles/affectors/move.qml b/examples/quick/particles/affectors/move.qml
index b9901ef3c9..447f5b0d32 100644
--- a/examples/quick/particles/affectors/move.qml
+++ b/examples/quick/particles/affectors/move.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
Rectangle {
width: 360
diff --git a/examples/quick/particles/emitters/burstandpulse.qml b/examples/quick/particles/emitters/burstandpulse.qml
index 8b2e637c70..ffc620e41b 100644
--- a/examples/quick/particles/emitters/burstandpulse.qml
+++ b/examples/quick/particles/emitters/burstandpulse.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
Rectangle {
id: root
diff --git a/examples/quick/particles/emitters/customemitter.qml b/examples/quick/particles/emitters/customemitter.qml
index d7cd220f4a..5aba7d1b9f 100644
--- a/examples/quick/particles/emitters/customemitter.qml
+++ b/examples/quick/particles/emitters/customemitter.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
ParticleSystem {
id: sys
diff --git a/examples/quick/particles/emitters/emitmask.qml b/examples/quick/particles/emitters/emitmask.qml
index 55ad34fd27..8a3e97f1d9 100644
--- a/examples/quick/particles/emitters/emitmask.qml
+++ b/examples/quick/particles/emitters/emitmask.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
Rectangle {
color: "goldenrod"
diff --git a/examples/quick/particles/emitters/maximumemitted.qml b/examples/quick/particles/emitters/maximumemitted.qml
index 2bbd8a7c47..c5d33a9541 100644
--- a/examples/quick/particles/emitters/maximumemitted.qml
+++ b/examples/quick/particles/emitters/maximumemitted.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
Rectangle {
color: "black"
diff --git a/examples/quick/particles/emitters/shapeanddirection.qml b/examples/quick/particles/emitters/shapeanddirection.qml
index 5ddd96a5de..190eb9cb60 100644
--- a/examples/quick/particles/emitters/shapeanddirection.qml
+++ b/examples/quick/particles/emitters/shapeanddirection.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
Rectangle {
id: root
diff --git a/examples/quick/particles/emitters/trailemitter.qml b/examples/quick/particles/emitters/trailemitter.qml
index 893690061a..eb8f03ab3c 100644
--- a/examples/quick/particles/emitters/trailemitter.qml
+++ b/examples/quick/particles/emitters/trailemitter.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
Rectangle {
id: root
diff --git a/examples/quick/particles/emitters/velocityfrommotion.qml b/examples/quick/particles/emitters/velocityfrommotion.qml
index 7fc908eb42..df8070e768 100644
--- a/examples/quick/particles/emitters/velocityfrommotion.qml
+++ b/examples/quick/particles/emitters/velocityfrommotion.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
Rectangle {
diff --git a/examples/quick/pointerhandlers/components/FlashAnimation.qml b/examples/quick/pointerhandlers/components/FlashAnimation.qml
index e369282470..bdbcaecdfa 100644
--- a/examples/quick/pointerhandlers/components/FlashAnimation.qml
+++ b/examples/quick/pointerhandlers/components/FlashAnimation.qml
@@ -6,15 +6,9 @@ import QtQuick
SequentialAnimation {
id: tapFlash
running: false
+ loops: 3
PropertyAction { value: false }
PauseAnimation { duration: 100 }
PropertyAction { value: true }
PauseAnimation { duration: 100 }
- PropertyAction { value: false }
- PauseAnimation { duration: 100 }
- PropertyAction { value: true }
- PauseAnimation { duration: 100 }
- PropertyAction { value: false }
- PauseAnimation { duration: 100 }
- PropertyAction { value: true }
}
diff --git a/examples/quick/pointerhandlers/map.qml b/examples/quick/pointerhandlers/map.qml
index 155aba6f42..082d9d26c3 100644
--- a/examples/quick/pointerhandlers/map.qml
+++ b/examples/quick/pointerhandlers/map.qml
@@ -73,8 +73,6 @@ Item {
target: map
minimumScale: 0.1
maximumScale: 10
- xAxis.enabled: false
- yAxis.enabled: false
onActiveChanged: if (!active) reRenderIfNecessary()
grabPermissions: PinchHandler.TakeOverForbidden // don't allow takeover if pinch has started
}
diff --git a/examples/quick/pointerhandlers/pinchHandler.qml b/examples/quick/pointerhandlers/pinchHandler.qml
index 41643fbaea..f8febc47ee 100644
--- a/examples/quick/pointerhandlers/pinchHandler.qml
+++ b/examples/quick/pointerhandlers/pinchHandler.qml
@@ -133,7 +133,7 @@ Rectangle {
onGrabChanged: function (transition, point) {
if (transition === 0x10) { // GrabExclusive
console.log(point.id, "grabbed @", point.position)
- Qt.createQmlObject("import QtQuick 2.0; Rectangle { opacity: 0.5; border.color: 'red'; radius: 8; width: radius * 2; height: radius * 2; " +
+ Qt.createQmlObject("import QtQuick; Rectangle { opacity: 0.5; border.color: 'red'; radius: 8; width: radius * 2; height: radius * 2; " +
"x: " + (point.position.x - 8) + "; y: " + (point.position.y - 8) + "}",
rect3, "touchpoint" + point.id);
}
diff --git a/examples/quick/pointerhandlers/sidebar.qml b/examples/quick/pointerhandlers/sidebar.qml
index 187e535d92..55857cf733 100644
--- a/examples/quick/pointerhandlers/sidebar.qml
+++ b/examples/quick/pointerhandlers/sidebar.qml
@@ -10,69 +10,66 @@ Rectangle {
height: 480
color: rootHover.hovered ? "#555" : "#444"
- Component {
- id: buttonsAndStuff
- Column {
- anchors.fill: parent
- anchors.margins: 8
- spacing: 8
+ component ButtonsAndStuff: Column {
+ anchors.fill: parent
+ anchors.margins: 8
+ spacing: 8
+
+ CheckBox {
+ id: hoverBlockingCB
+ text: "Button hover is blocking"
+ }
+
+ Rectangle {
+ objectName: "buttonWithMA"
+ width: parent.width
+ height: 30
+ color: buttonMA.pressed ? "lightsteelblue" : "#999"
+ border.color: buttonMA.containsMouse ? "cyan" : "transparent"
+
+ MouseArea {
+ id: buttonMA
+ objectName: "buttonMA"
+ hoverEnabled: true
+ cursorShape: Qt.UpArrowCursor
+ anchors.fill: parent
+ onClicked: console.log("clicked MA")
+ }
+
+ Text {
+ anchors.centerIn: parent
+ text: "MouseArea"
+ }
+ }
+
+ Rectangle {
+ objectName: "buttonWithHH"
+ width: parent.width
+ height: 30
+ color: flash ? "#999" : "white"
+ border.color: buttonHH.hovered ? "cyan" : "transparent"
+ property bool flash: true
+
+ HoverHandler {
+ id: buttonHH
+ objectName: "buttonHH"
+ acceptedDevices: PointerDevice.AllDevices
+ blocking: hoverBlockingCB.checked
+ cursorShape: tapHandler.pressed ? Qt.BusyCursor : Qt.PointingHandCursor
+ }
- CheckBox {
- id: hoverBlockingCB
- text: "Button hover is blocking"
+ TapHandler {
+ id: tapHandler
+ onTapped: tapFlash.start()
}
- Rectangle {
- objectName: "buttonWithMA"
- width: parent.width
- height: 30
- color: buttonMA.pressed ? "lightsteelblue" : "#999"
- border.color: buttonMA.containsMouse ? "cyan" : "transparent"
-
- MouseArea {
- id: buttonMA
- objectName: "buttonMA"
- hoverEnabled: true
- cursorShape: Qt.UpArrowCursor
- anchors.fill: parent
- onClicked: console.log("clicked MA")
- }
-
- Text {
- anchors.centerIn: parent
- text: "MouseArea"
- }
+ Text {
+ anchors.centerIn: parent
+ text: "HoverHandler"
}
- Rectangle {
- objectName: "buttonWithHH"
- width: parent.width
- height: 30
- color: flash ? "#999" : "white"
- border.color: buttonHH.hovered ? "cyan" : "transparent"
- property bool flash: true
-
- HoverHandler {
- id: buttonHH
- objectName: "buttonHH"
- acceptedDevices: PointerDevice.AllDevices
- blocking: hoverBlockingCB.checked
- cursorShape: tapHandler.pressed ? Qt.BusyCursor : Qt.PointingHandCursor
- }
-
- TapHandler {
- id: tapHandler
- onTapped: tapFlash.start()
- }
-
- Text {
- anchors.centerIn: parent
- text: "HoverHandler"
- }
-
- FlashAnimation on flash {
- id: tapFlash
- }
+ FlashAnimation on flash {
+ id: tapFlash
}
}
}
@@ -135,9 +132,7 @@ Rectangle {
cursorShape: Qt.OpenHandCursor
}
- Loader {
- objectName: "topSidebarLoader"
- sourceComponent: buttonsAndStuff
+ ButtonsAndStuff {
anchors.fill: parent
}
@@ -166,9 +161,7 @@ Rectangle {
cursorShape: Qt.ClosedHandCursor
anchors.fill: parent
- Loader {
- objectName: "bottomSidebarLoader"
- sourceComponent: buttonsAndStuff
+ ButtonsAndStuff {
anchors.fill: parent
}
}
diff --git a/examples/quick/quick-accessibility/Button.qml b/examples/quick/quick-accessibility/Button.qml
index 84debed4d0..bd23307e97 100644
--- a/examples/quick/quick-accessibility/Button.qml
+++ b/examples/quick/quick-accessibility/Button.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: button
diff --git a/examples/quick/quick-accessibility/Checkbox.qml b/examples/quick/quick-accessibility/Checkbox.qml
index eea1bf152e..a3a0f286f1 100644
--- a/examples/quick/quick-accessibility/Checkbox.qml
+++ b/examples/quick/quick-accessibility/Checkbox.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
FocusScope {
id: checkbox
diff --git a/examples/quick/quick-accessibility/Slider.qml b/examples/quick/quick-accessibility/Slider.qml
index 23e2a882ea..5dedec4915 100644
--- a/examples/quick/quick-accessibility/Slider.qml
+++ b/examples/quick/quick-accessibility/Slider.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
// Minimal slider implementation
Rectangle {
diff --git a/examples/quick/quickwidgets/qquickwidgetversuswindow_opengl/test.qml b/examples/quick/quickwidgets/qquickwidgetversuswindow_opengl/test.qml
index b658f9b01d..a7e30e8917 100644
--- a/examples/quick/quickwidgets/qquickwidgetversuswindow_opengl/test.qml
+++ b/examples/quick/quickwidgets/qquickwidgetversuswindow_opengl/test.qml
@@ -1,9 +1,9 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.2
-import QtQuick.Particles 2.0
-import fbitem 1.0
+import QtQuick
+import QtQuick.Particles
+import fbitem
Rectangle {
id: root
diff --git a/examples/quick/quickwidgets/quickwidget/rotatingsquare.qml b/examples/quick/quickwidgets/quickwidget/rotatingsquare.qml
index 27e3644020..355c02f0cd 100644
--- a/examples/quick/quickwidgets/quickwidget/rotatingsquare.qml
+++ b/examples/quick/quickwidgets/quickwidget/rotatingsquare.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.8
+import QtQuick
Rectangle {
id: root
diff --git a/examples/quick/scenegraph/customgeometry/main.qml b/examples/quick/scenegraph/customgeometry/main.qml
index e094b78081..2f440b441e 100644
--- a/examples/quick/scenegraph/customgeometry/main.qml
+++ b/examples/quick/scenegraph/customgeometry/main.qml
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [1]
-import QtQuick 2.0
-import CustomGeometry 1.0
+import QtQuick
+import CustomGeometry
//! [1] //! [2]
Item {
width: 300
diff --git a/examples/quick/scenegraph/custommaterial/main.qml b/examples/quick/scenegraph/custommaterial/main.qml
index ed7de5df0a..9626711d38 100644
--- a/examples/quick/scenegraph/custommaterial/main.qml
+++ b/examples/quick/scenegraph/custommaterial/main.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.2
-import ExampleCustomMaterial 1.0
+import QtQuick
+import ExampleCustomMaterial
Item {
id: root
diff --git a/examples/quick/scenegraph/d3d11underqml/main.qml b/examples/quick/scenegraph/d3d11underqml/main.qml
index 1ac3e1094a..939f42cd26 100644
--- a/examples/quick/scenegraph/d3d11underqml/main.qml
+++ b/examples/quick/scenegraph/d3d11underqml/main.qml
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [1]
-import QtQuick 2.0
-import D3D11UnderQML 1.0
+import QtQuick
+import D3D11UnderQML
Item {
diff --git a/examples/quick/scenegraph/fboitem/main.qml b/examples/quick/scenegraph/fboitem/main.qml
index 32fb88d2c7..78f0f27e74 100644
--- a/examples/quick/scenegraph/fboitem/main.qml
+++ b/examples/quick/scenegraph/fboitem/main.qml
@@ -1,9 +1,9 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
-import SceneGraphRendering 1.0
+import SceneGraphRendering
Item {
width: 400
diff --git a/examples/quick/scenegraph/graph/main.qml b/examples/quick/scenegraph/graph/main.qml
index 614f9b6eae..e9b684c3ba 100644
--- a/examples/quick/scenegraph/graph/main.qml
+++ b/examples/quick/scenegraph/graph/main.qml
@@ -1,9 +1,9 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
-import Graph 1.0
+import Graph
Item {
width: 800
diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp
index e62fb2182e..8f5d93dc35 100644
--- a/examples/quick/scenegraph/graph/noisynode.cpp
+++ b/examples/quick/scenegraph/graph/noisynode.cpp
@@ -102,6 +102,7 @@ void NoisyShader::updateSampledImage(RenderState &state, int binding, QSGTexture
Q_UNUSED(binding);
NoisyMaterial *mat = static_cast<NoisyMaterial *>(newMaterial);
+ mat->state.texture->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
*texture = mat->state.texture;
}
diff --git a/examples/quick/scenegraph/metaltextureimport/main.qml b/examples/quick/scenegraph/metaltextureimport/main.qml
index f541696f38..dfc6252910 100644
--- a/examples/quick/scenegraph/metaltextureimport/main.qml
+++ b/examples/quick/scenegraph/metaltextureimport/main.qml
@@ -1,9 +1,9 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
//! [1]
-import MetalTextureImport 1.0
+import MetalTextureImport
//! [1]
Rectangle {
diff --git a/examples/quick/scenegraph/metalunderqml/main.qml b/examples/quick/scenegraph/metalunderqml/main.qml
index 2417bb1644..3329822eb1 100644
--- a/examples/quick/scenegraph/metalunderqml/main.qml
+++ b/examples/quick/scenegraph/metalunderqml/main.qml
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [1]
-import QtQuick 2.0
-import MetalUnderQML 1.0
+import QtQuick
+import MetalUnderQML
Item {
diff --git a/examples/quick/scenegraph/openglunderqml/main.qml b/examples/quick/scenegraph/openglunderqml/main.qml
index e0a09b754d..46cbef18eb 100644
--- a/examples/quick/scenegraph/openglunderqml/main.qml
+++ b/examples/quick/scenegraph/openglunderqml/main.qml
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [1]
-import QtQuick 2.0
-import OpenGLUnderQML 1.0
+import QtQuick
+import OpenGLUnderQML
Item {
diff --git a/examples/quick/scenegraph/threadedanimation/main.qml b/examples/quick/scenegraph/threadedanimation/main.qml
index f1220c3321..33e72af1f1 100644
--- a/examples/quick/scenegraph/threadedanimation/main.qml
+++ b/examples/quick/scenegraph/threadedanimation/main.qml
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [1]
-import QtQuick 2.0
-import Spinner 1.0
+import QtQuick
+import Spinner
Rectangle {
diff --git a/examples/quick/scenegraph/twotextureproviders/main.qml b/examples/quick/scenegraph/twotextureproviders/main.qml
index e52eafa5df..e28f6347a8 100644
--- a/examples/quick/scenegraph/twotextureproviders/main.qml
+++ b/examples/quick/scenegraph/twotextureproviders/main.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2014 Gunnar Sletta <gunnar@sletta.org>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.2
-import SceneGraphRendering 1.0
+import QtQuick
+import SceneGraphRendering
Item {
id: root
diff --git a/examples/quick/scenegraph/vulkantextureimport/main.qml b/examples/quick/scenegraph/vulkantextureimport/main.qml
index 3d2699ace8..081a496bca 100644
--- a/examples/quick/scenegraph/vulkantextureimport/main.qml
+++ b/examples/quick/scenegraph/vulkantextureimport/main.qml
@@ -1,9 +1,9 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
//! [1]
-import VulkanTextureImport 1.0
+import VulkanTextureImport
//! [1]
Rectangle {
diff --git a/examples/quick/scenegraph/vulkanunderqml/main.qml b/examples/quick/scenegraph/vulkanunderqml/main.qml
index 4dfac2c724..bae014b328 100644
--- a/examples/quick/scenegraph/vulkanunderqml/main.qml
+++ b/examples/quick/scenegraph/vulkanunderqml/main.qml
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [1]
-import QtQuick 2.0
-import VulkanUnderQML 1.0
+import QtQuick
+import VulkanUnderQML
Item {
diff --git a/examples/quick/shared/Button.qml b/examples/quick/shared/Button.qml
index bee0ae28e1..31e88fe541 100644
--- a/examples/quick/shared/Button.qml
+++ b/examples/quick/shared/Button.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.12
-import QtQuick.Window 2.1
+import QtQuick
+import QtQuick.Window
Item {
id: container
diff --git a/examples/quick/shared/CheckBox.qml b/examples/quick/shared/CheckBox.qml
index ed93d708da..45c4f4e674 100644
--- a/examples/quick/shared/CheckBox.qml
+++ b/examples/quick/shared/CheckBox.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.12
+import QtQuick
Item {
id: root
diff --git a/examples/quick/shared/FlickrRssModel.qml b/examples/quick/shared/FlickrRssModel.qml
index 66f53b8ef5..e78d1ffa21 100644
--- a/examples/quick/shared/FlickrRssModel.qml
+++ b/examples/quick/shared/FlickrRssModel.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.12
+import QtQuick
ListModel {
id: flickrImages
diff --git a/examples/quick/shared/Label.qml b/examples/quick/shared/Label.qml
index 77ec53f5c2..5393336cab 100644
--- a/examples/quick/shared/Label.qml
+++ b/examples/quick/shared/Label.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Text {
SystemPalette { id: palette }
diff --git a/examples/quick/shared/LauncherList.qml b/examples/quick/shared/LauncherList.qml
index 323ed529fe..ee8fc3984e 100644
--- a/examples/quick/shared/LauncherList.qml
+++ b/examples/quick/shared/LauncherList.qml
@@ -2,9 +2,9 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQml 2.12
-import QtQml.Models 2.12
-import QtQuick 2.12
+import QtQml
+import QtQml.Models
+import QtQuick
Rectangle {
id: root
diff --git a/examples/quick/shared/SimpleLauncherDelegate.qml b/examples/quick/shared/SimpleLauncherDelegate.qml
index 68860edbc2..c6ca9802d2 100644
--- a/examples/quick/shared/SimpleLauncherDelegate.qml
+++ b/examples/quick/shared/SimpleLauncherDelegate.qml
@@ -1,6 +1,6 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.12
+import QtQuick
Rectangle {
id: container
diff --git a/examples/quick/shared/Slider.qml b/examples/quick/shared/Slider.qml
index 7b331ab1c6..b8bb6ed30c 100644
--- a/examples/quick/shared/Slider.qml
+++ b/examples/quick/shared/Slider.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.12
+import QtQuick
Item {
id: slider
diff --git a/examples/quick/shared/TabSet.qml b/examples/quick/shared/TabSet.qml
index 633521af8e..d9ae7d7b6d 100644
--- a/examples/quick/shared/TabSet.qml
+++ b/examples/quick/shared/TabSet.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.12
-import QtQuick.Window 2.1
+import QtQuick
+import QtQuick.Window
Item {
id: tabWidget
diff --git a/examples/quick/shared/TextField.qml b/examples/quick/shared/TextField.qml
index 01addb2e97..66854c89bf 100644
--- a/examples/quick/shared/TextField.qml
+++ b/examples/quick/shared/TextField.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.1
+import QtQuick
Item {
id: root
diff --git a/examples/quick/tableview/gameoflife/main.qml b/examples/quick/tableview/gameoflife/main.qml
index 41c5f9dcfb..9e9f9e6905 100644
--- a/examples/quick/tableview/gameoflife/main.qml
+++ b/examples/quick/tableview/gameoflife/main.qml
@@ -1,12 +1,12 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQml 2.12
-import QtQuick 2.12
-import QtQuick.Window 2.3
-import QtQuick.Controls 2.2
-import QtQuick.Layouts 1.3
-import GameOfLifeModel 1.0
+import QtQml
+import QtQuick
+import QtQuick.Window
+import QtQuick.Controls
+import QtQuick.Layouts
+import GameOfLifeModel
ApplicationWindow {
id: root
diff --git a/examples/quick/tableview/pixelator/main.qml b/examples/quick/tableview/pixelator/main.qml
index 05a9d1ebde..67a4ff5a36 100644
--- a/examples/quick/tableview/pixelator/main.qml
+++ b/examples/quick/tableview/pixelator/main.qml
@@ -1,11 +1,11 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.12
+import QtQuick
-import QtQuick.Window 2.12
+import QtQuick.Window
-import ImageModel 1.0
+import ImageModel
Window {
visible: true
diff --git a/examples/quick/text/fonts/availableFonts.qml b/examples/quick/text/fonts/availableFonts.qml
index 7cfeae3465..2564bb6447 100644
--- a/examples/quick/text/fonts/availableFonts.qml
+++ b/examples/quick/text/fonts/availableFonts.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
width: 320; height: 480; color: "steelblue"
diff --git a/examples/quick/text/fonts/banner.qml b/examples/quick/text/fonts/banner.qml
index 3902bd18cb..2c0742018a 100644
--- a/examples/quick/text/fonts/banner.qml
+++ b/examples/quick/text/fonts/banner.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: screen
diff --git a/examples/quick/text/fonts/fonts.qml b/examples/quick/text/fonts/fonts.qml
index e904a5664c..8e0f906493 100644
--- a/examples/quick/text/fonts/fonts.qml
+++ b/examples/quick/text/fonts/fonts.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: root
diff --git a/examples/quick/text/fonts/hello.qml b/examples/quick/text/fonts/hello.qml
index 6874544d0e..e0cdc26ea6 100644
--- a/examples/quick/text/fonts/hello.qml
+++ b/examples/quick/text/fonts/hello.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: screen
diff --git a/examples/quick/text/imgtag/TextWithImage.qml b/examples/quick/text/imgtag/TextWithImage.qml
index be6f65a32c..0fdd208368 100644
--- a/examples/quick/text/imgtag/TextWithImage.qml
+++ b/examples/quick/text/imgtag/TextWithImage.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Text {
width: parent.width
diff --git a/examples/quick/text/imgtag/imgtag.qml b/examples/quick/text/imgtag/imgtag.qml
index 45fd5b6196..689d07aabb 100644
--- a/examples/quick/text/imgtag/imgtag.qml
+++ b/examples/quick/text/imgtag/imgtag.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: main
diff --git a/examples/quick/text/styledtext-layout.qml b/examples/quick/text/styledtext-layout.qml
index 5a4c97e35e..4f63d3ea90 100644
--- a/examples/quick/text/styledtext-layout.qml
+++ b/examples/quick/text/styledtext-layout.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: main
diff --git a/examples/quick/text/text.qml b/examples/quick/text/text.qml
index a2e3072e04..8f1c24ebc2 100644
--- a/examples/quick/text/text.qml
+++ b/examples/quick/text/text.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import shared
Item {
diff --git a/examples/quick/text/textselection/textselection.qml b/examples/quick/text/textselection/textselection.qml
index 68d74146e4..d4224ee14c 100644
--- a/examples/quick/text/textselection/textselection.qml
+++ b/examples/quick/text/textselection/textselection.qml
@@ -1,6 +1,6 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: editor
diff --git a/examples/quick/threading/threadedlistmodel/timedisplay.qml b/examples/quick/threading/threadedlistmodel/timedisplay.qml
index d8781b70be..9c14fb1d11 100644
--- a/examples/quick/threading/threadedlistmodel/timedisplay.qml
+++ b/examples/quick/threading/threadedlistmodel/timedisplay.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
color: "white"
diff --git a/examples/quick/threading/threading.qml b/examples/quick/threading/threading.qml
index 843e56faf7..55a61ee155 100644
--- a/examples/quick/threading/threading.qml
+++ b/examples/quick/threading/threading.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import shared as Examples
Item {
diff --git a/examples/quick/threading/workerscript/Spinner.qml b/examples/quick/threading/workerscript/Spinner.qml
index 3a937339b4..c21433961e 100644
--- a/examples/quick/threading/workerscript/Spinner.qml
+++ b/examples/quick/threading/workerscript/Spinner.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
width: 64
diff --git a/examples/quick/threading/workerscript/workerscript.qml b/examples/quick/threading/workerscript/workerscript.qml
index 931b0d2247..3d01f90968 100644
--- a/examples/quick/threading/workerscript/workerscript.qml
+++ b/examples/quick/threading/workerscript/workerscript.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
width: 320; height: 480
diff --git a/examples/quick/touchinteraction/flickable/Panel.qml b/examples/quick/touchinteraction/flickable/Panel.qml
index 217178f803..25c864799e 100644
--- a/examples/quick/touchinteraction/flickable/Panel.qml
+++ b/examples/quick/touchinteraction/flickable/Panel.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Item {
required property string name
diff --git a/examples/quick/touchinteraction/flickable/basic-flickable.qml b/examples/quick/touchinteraction/flickable/basic-flickable.qml
index a96aa42962..d529f0bec2 100644
--- a/examples/quick/touchinteraction/flickable/basic-flickable.qml
+++ b/examples/quick/touchinteraction/flickable/basic-flickable.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
//![0]
Rectangle {
diff --git a/examples/quick/touchinteraction/flickable/corkboards.qml b/examples/quick/touchinteraction/flickable/corkboards.qml
index 0956b6a04c..a8b9032dfd 100644
--- a/examples/quick/touchinteraction/flickable/corkboards.qml
+++ b/examples/quick/touchinteraction/flickable/corkboards.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
width: 320; height: 480
diff --git a/examples/quick/touchinteraction/multipointtouch/AugmentedTouchPoint.qml b/examples/quick/touchinteraction/multipointtouch/AugmentedTouchPoint.qml
index ab44f9a56d..b1d162bbd3 100644
--- a/examples/quick/touchinteraction/multipointtouch/AugmentedTouchPoint.qml
+++ b/examples/quick/touchinteraction/multipointtouch/AugmentedTouchPoint.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
//! [0]
TouchPoint {
diff --git a/examples/quick/touchinteraction/multipointtouch/BearWhackParticleSystem.qml b/examples/quick/touchinteraction/multipointtouch/BearWhackParticleSystem.qml
index 1621490c3d..6537f37087 100644
--- a/examples/quick/touchinteraction/multipointtouch/BearWhackParticleSystem.qml
+++ b/examples/quick/touchinteraction/multipointtouch/BearWhackParticleSystem.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
ParticleSystem {
id: particleSystem
diff --git a/examples/quick/touchinteraction/multipointtouch/ParticleFlame.qml b/examples/quick/touchinteraction/multipointtouch/ParticleFlame.qml
index d357ceb81d..66907b1f0d 100644
--- a/examples/quick/touchinteraction/multipointtouch/ParticleFlame.qml
+++ b/examples/quick/touchinteraction/multipointtouch/ParticleFlame.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
ParticleSystem {
anchors.fill: parent
diff --git a/examples/quick/touchinteraction/multipointtouch/bearwhack.qml b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml
index 73ce2452c6..c5f7dc585c 100644
--- a/examples/quick/touchinteraction/multipointtouch/bearwhack.qml
+++ b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
Item {
id: root
diff --git a/examples/quick/touchinteraction/multipointtouch/multiflame.qml b/examples/quick/touchinteraction/multipointtouch/multiflame.qml
index cdb882c607..3e03bf2815 100644
--- a/examples/quick/touchinteraction/multipointtouch/multiflame.qml
+++ b/examples/quick/touchinteraction/multipointtouch/multiflame.qml
@@ -1,6 +1,6 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
width: 360
diff --git a/examples/quick/touchinteraction/pincharea/flickresize.qml b/examples/quick/touchinteraction/pincharea/flickresize.qml
index a8bd67a306..16108be1a7 100644
--- a/examples/quick/touchinteraction/pincharea/flickresize.qml
+++ b/examples/quick/touchinteraction/pincharea/flickresize.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
width: 640
diff --git a/examples/quick/touchinteraction/touchinteraction.qml b/examples/quick/touchinteraction/touchinteraction.qml
index 5e3fb6b3c5..6961e48fd4 100644
--- a/examples/quick/touchinteraction/touchinteraction.qml
+++ b/examples/quick/touchinteraction/touchinteraction.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import shared
Item {
diff --git a/examples/quick/tutorials/dynamicview/dynamicview1/PetsModel.qml b/examples/quick/tutorials/dynamicview/dynamicview1/PetsModel.qml
index d201b3e6f4..45c43909e4 100644
--- a/examples/quick/tutorials/dynamicview/dynamicview1/PetsModel.qml
+++ b/examples/quick/tutorials/dynamicview/dynamicview1/PetsModel.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.0
+import QtQuick
ListModel {
ListElement {
diff --git a/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview.qml
index cab7fa9a6e..ec776d4153 100644
--- a/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview.qml
+++ b/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview.qml
@@ -1,8 +1,9 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
//![0]
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: root
@@ -16,7 +17,12 @@ Rectangle {
Rectangle {
id: content
- anchors { left: parent.left; right: parent.right }
+ required property string name
+ required property string type
+ required property string size
+ required property int age
+
+ width: view.width
height: column.implicitHeight + 4
border.width: 1
diff --git a/examples/quick/tutorials/dynamicview/dynamicview2/PetsModel.qml b/examples/quick/tutorials/dynamicview/dynamicview2/PetsModel.qml
index 2faae2a10b..acdab53c20 100644
--- a/examples/quick/tutorials/dynamicview/dynamicview2/PetsModel.qml
+++ b/examples/quick/tutorials/dynamicview/dynamicview2/PetsModel.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
ListModel {
ListElement {
diff --git a/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview.qml
index ab1f1c0b08..99b1bbdaa1 100644
--- a/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview.qml
+++ b/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: root
diff --git a/examples/quick/tutorials/dynamicview/dynamicview3/PetsModel.qml b/examples/quick/tutorials/dynamicview/dynamicview3/PetsModel.qml
index 2faae2a10b..acdab53c20 100644
--- a/examples/quick/tutorials/dynamicview/dynamicview3/PetsModel.qml
+++ b/examples/quick/tutorials/dynamicview/dynamicview3/PetsModel.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
ListModel {
ListElement {
diff --git a/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml
index 92b2586dd0..ea88da4e53 100644
--- a/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml
+++ b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQml.Models 2.1
+import QtQuick
+import QtQml.Models
//![0]
Rectangle {
id: root
diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/ListSelector.qml b/examples/quick/tutorials/dynamicview/dynamicview4/ListSelector.qml
index 2ea80e2d8d..42a200a936 100644
--- a/examples/quick/tutorials/dynamicview/dynamicview4/ListSelector.qml
+++ b/examples/quick/tutorials/dynamicview/dynamicview4/ListSelector.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Item {
id: selector
diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/PetsModel.qml b/examples/quick/tutorials/dynamicview/dynamicview4/PetsModel.qml
index 2faae2a10b..acdab53c20 100644
--- a/examples/quick/tutorials/dynamicview/dynamicview4/PetsModel.qml
+++ b/examples/quick/tutorials/dynamicview/dynamicview4/PetsModel.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
ListModel {
ListElement {
diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml
index 36f1ecdf4b..cb454c0d46 100644
--- a/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml
+++ b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQml.Models 2.1
+import QtQuick
+import QtQml.Models
Rectangle {
id: root
diff --git a/examples/quick/tutorials/helloworld/Cell.qml b/examples/quick/tutorials/helloworld/Cell.qml
index 1910453869..d88b63cdfa 100644
--- a/examples/quick/tutorials/helloworld/Cell.qml
+++ b/examples/quick/tutorials/helloworld/Cell.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.0
+import QtQuick
//![1]
Item {
diff --git a/examples/quick/tutorials/helloworld/tutorial1.qml b/examples/quick/tutorials/helloworld/tutorial1.qml
index fe64925d27..c67bc75562 100644
--- a/examples/quick/tutorials/helloworld/tutorial1.qml
+++ b/examples/quick/tutorials/helloworld/tutorial1.qml
@@ -3,7 +3,7 @@
//![0]
//![3]
-import QtQuick 2.0
+import QtQuick
//![3]
//![1]
diff --git a/examples/quick/tutorials/helloworld/tutorial2.qml b/examples/quick/tutorials/helloworld/tutorial2.qml
index 917bee047e..8b1c632b99 100644
--- a/examples/quick/tutorials/helloworld/tutorial2.qml
+++ b/examples/quick/tutorials/helloworld/tutorial2.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: page
diff --git a/examples/quick/tutorials/helloworld/tutorial3.qml b/examples/quick/tutorials/helloworld/tutorial3.qml
index e2d280494f..73833d2a67 100644
--- a/examples/quick/tutorials/helloworld/tutorial3.qml
+++ b/examples/quick/tutorials/helloworld/tutorial3.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: page
diff --git a/examples/quick/tutorials/samegame/samegame1/Block.qml b/examples/quick/tutorials/samegame/samegame1/Block.qml
index d5fd8add3e..c10f0c4825 100644
--- a/examples/quick/tutorials/samegame/samegame1/Block.qml
+++ b/examples/quick/tutorials/samegame/samegame1/Block.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.0
+import QtQuick
Item {
id: block
diff --git a/examples/quick/tutorials/samegame/samegame1/Button.qml b/examples/quick/tutorials/samegame/samegame1/Button.qml
index b2d62b3c18..cc87465e3c 100644
--- a/examples/quick/tutorials/samegame/samegame1/Button.qml
+++ b/examples/quick/tutorials/samegame/samegame1/Button.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: container
diff --git a/examples/quick/tutorials/samegame/samegame1/samegame.qml b/examples/quick/tutorials/samegame/samegame1/samegame.qml
index dafe6abaf6..fe21acae99 100644
--- a/examples/quick/tutorials/samegame/samegame1/samegame.qml
+++ b/examples/quick/tutorials/samegame/samegame1/samegame.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: screen
diff --git a/examples/quick/tutorials/samegame/samegame2/Block.qml b/examples/quick/tutorials/samegame/samegame2/Block.qml
index 79ac9392bf..b0416f0e15 100644
--- a/examples/quick/tutorials/samegame/samegame2/Block.qml
+++ b/examples/quick/tutorials/samegame/samegame2/Block.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Item {
id: block
diff --git a/examples/quick/tutorials/samegame/samegame2/Button.qml b/examples/quick/tutorials/samegame/samegame2/Button.qml
index 45b370d1f2..1a365e6dd9 100644
--- a/examples/quick/tutorials/samegame/samegame2/Button.qml
+++ b/examples/quick/tutorials/samegame/samegame2/Button.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: container
diff --git a/examples/quick/tutorials/samegame/samegame2/samegame.qml b/examples/quick/tutorials/samegame/samegame2/samegame.qml
index ebc67793ed..642a474ebd 100644
--- a/examples/quick/tutorials/samegame/samegame2/samegame.qml
+++ b/examples/quick/tutorials/samegame/samegame2/samegame.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
//![2]
import "samegame.js" as SameGame
//![2]
diff --git a/examples/quick/tutorials/samegame/samegame3/Block.qml b/examples/quick/tutorials/samegame/samegame3/Block.qml
index 7fa2bf7b79..71d25c19db 100644
--- a/examples/quick/tutorials/samegame/samegame3/Block.qml
+++ b/examples/quick/tutorials/samegame/samegame3/Block.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.0
+import QtQuick
Item {
id: block
diff --git a/examples/quick/tutorials/samegame/samegame3/Button.qml b/examples/quick/tutorials/samegame/samegame3/Button.qml
index 45b370d1f2..1a365e6dd9 100644
--- a/examples/quick/tutorials/samegame/samegame3/Button.qml
+++ b/examples/quick/tutorials/samegame/samegame3/Button.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: container
diff --git a/examples/quick/tutorials/samegame/samegame3/Dialog.qml b/examples/quick/tutorials/samegame/samegame3/Dialog.qml
index ea546c7738..3620da5799 100644
--- a/examples/quick/tutorials/samegame/samegame3/Dialog.qml
+++ b/examples/quick/tutorials/samegame/samegame3/Dialog.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: container
diff --git a/examples/quick/tutorials/samegame/samegame3/samegame.qml b/examples/quick/tutorials/samegame/samegame3/samegame.qml
index 30ff19c96b..dadd089e24 100644
--- a/examples/quick/tutorials/samegame/samegame3/samegame.qml
+++ b/examples/quick/tutorials/samegame/samegame3/samegame.qml
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.0
+import QtQuick
import "samegame.js" as SameGame
Rectangle {
diff --git a/examples/quick/tutorials/samegame/samegame4/BoomBlock.qml b/examples/quick/tutorials/samegame/samegame4/BoomBlock.qml
index 7a10fb6b22..fa6b1d45a1 100644
--- a/examples/quick/tutorials/samegame/samegame4/BoomBlock.qml
+++ b/examples/quick/tutorials/samegame/samegame4/BoomBlock.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+import QtQuick
+import QtQuick.Particles
Item {
id: block
diff --git a/examples/quick/tutorials/samegame/samegame4/Button.qml b/examples/quick/tutorials/samegame/samegame4/Button.qml
index 45b370d1f2..1a365e6dd9 100644
--- a/examples/quick/tutorials/samegame/samegame4/Button.qml
+++ b/examples/quick/tutorials/samegame/samegame4/Button.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: container
diff --git a/examples/quick/tutorials/samegame/samegame4/Dialog.qml b/examples/quick/tutorials/samegame/samegame4/Dialog.qml
index 05c847dc90..3d3a04b66b 100644
--- a/examples/quick/tutorials/samegame/samegame4/Dialog.qml
+++ b/examples/quick/tutorials/samegame/samegame4/Dialog.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
//![0]
Rectangle {
diff --git a/examples/quick/tutorials/samegame/samegame4/samegame.qml b/examples/quick/tutorials/samegame/samegame4/samegame.qml
index bd4edbde69..b253e966f5 100644
--- a/examples/quick/tutorials/samegame/samegame4/samegame.qml
+++ b/examples/quick/tutorials/samegame/samegame4/samegame.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import "samegame.js" as SameGame
Rectangle {
diff --git a/examples/quick/views/delegatemodel/dragselection.qml b/examples/quick/views/delegatemodel/dragselection.qml
index bc45c5c93a..1a66264e1d 100644
--- a/examples/quick/views/delegatemodel/dragselection.qml
+++ b/examples/quick/views/delegatemodel/dragselection.qml
@@ -1,9 +1,9 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQml 2.0
-import QtQuick 2.0
-import QtQml.Models 2.1
+import QtQml
+import QtQuick
+import QtQml.Models
Item {
id: root
diff --git a/examples/quick/views/delegatemodel/slideshow.qml b/examples/quick/views/delegatemodel/slideshow.qml
index 695f0374d9..c11a72147f 100644
--- a/examples/quick/views/delegatemodel/slideshow.qml
+++ b/examples/quick/views/delegatemodel/slideshow.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.12
-import QtQml.Models 2.12
+import QtQuick
+import QtQml.Models
import shared as Shared
Rectangle {
diff --git a/examples/quick/views/gridview/gridview-example.qml b/examples/quick/views/gridview/gridview-example.qml
index d85606f1c7..3f849565ca 100644
--- a/examples/quick/views/gridview/gridview-example.qml
+++ b/examples/quick/views/gridview/gridview-example.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
width: 300; height: 400
diff --git a/examples/quick/views/listview/content/PetsModel.qml b/examples/quick/views/listview/content/PetsModel.qml
index 2faae2a10b..acdab53c20 100644
--- a/examples/quick/views/listview/content/PetsModel.qml
+++ b/examples/quick/views/listview/content/PetsModel.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
ListModel {
ListElement {
diff --git a/examples/quick/views/listview/content/PressAndHoldButton.qml b/examples/quick/views/listview/content/PressAndHoldButton.qml
index 0fa9b97d08..cdd2fb963d 100644
--- a/examples/quick/views/listview/content/PressAndHoldButton.qml
+++ b/examples/quick/views/listview/content/PressAndHoldButton.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Image {
id: container
diff --git a/examples/quick/views/listview/content/RecipesModel.qml b/examples/quick/views/listview/content/RecipesModel.qml
index 91a9cb2554..14b374a4c7 100644
--- a/examples/quick/views/listview/content/RecipesModel.qml
+++ b/examples/quick/views/listview/content/RecipesModel.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
ListModel {
ListElement {
diff --git a/examples/quick/views/listview/content/SmallText.qml b/examples/quick/views/listview/content/SmallText.qml
index 0c7a2674be..a808e3a27d 100644
--- a/examples/quick/views/listview/content/SmallText.qml
+++ b/examples/quick/views/listview/content/SmallText.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Text {
font.pixelSize: 12
diff --git a/examples/quick/views/listview/content/TextButton.qml b/examples/quick/views/listview/content/TextButton.qml
index b4d13bc67c..aef7aa79e0 100644
--- a/examples/quick/views/listview/content/TextButton.qml
+++ b/examples/quick/views/listview/content/TextButton.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: container
diff --git a/examples/quick/views/listview/content/ToggleButton.qml b/examples/quick/views/listview/content/ToggleButton.qml
index 0b196f5df6..19e2589f74 100644
--- a/examples/quick/views/listview/content/ToggleButton.qml
+++ b/examples/quick/views/listview/content/ToggleButton.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: root
diff --git a/examples/quick/views/listview/displaymargin.qml b/examples/quick/views/listview/displaymargin.qml
index 92d8c3a36a..c4c32bdd64 100644
--- a/examples/quick/views/listview/displaymargin.qml
+++ b/examples/quick/views/listview/displaymargin.qml
@@ -1,6 +1,6 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.3
+import QtQuick
Item {
width: 480; height: 320
diff --git a/examples/quick/views/listview/dynamiclist.qml b/examples/quick/views/listview/dynamiclist.qml
index f57267dfa9..fe32ce23d7 100644
--- a/examples/quick/views/listview/dynamiclist.qml
+++ b/examples/quick/views/listview/dynamiclist.qml
@@ -1,6 +1,6 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import "content"
// This example shows how items can be dynamically added to and removed from
diff --git a/examples/quick/views/listview/expandingdelegates.qml b/examples/quick/views/listview/expandingdelegates.qml
index c215c9ab16..26f2288922 100644
--- a/examples/quick/views/listview/expandingdelegates.qml
+++ b/examples/quick/views/listview/expandingdelegates.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import "content"
// This example illustrates expanding a list item to show a more detailed view.
diff --git a/examples/quick/views/listview/highlight.qml b/examples/quick/views/listview/highlight.qml
index b3af7de204..137347203a 100644
--- a/examples/quick/views/listview/highlight.qml
+++ b/examples/quick/views/listview/highlight.qml
@@ -5,7 +5,7 @@
// that uses a SpringAnimation to provide custom movement when the
// highlight bar is moved between items.
-import QtQuick 2.0
+import QtQuick
import "content"
Rectangle {
diff --git a/examples/quick/views/listview/highlightranges.qml b/examples/quick/views/listview/highlightranges.qml
index 470223728a..78f8b197d3 100644
--- a/examples/quick/views/listview/highlightranges.qml
+++ b/examples/quick/views/listview/highlightranges.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
import "content"
//! [0]
diff --git a/examples/quick/views/listview/sections.qml b/examples/quick/views/listview/sections.qml
index c0e51dc518..5b2dfc67cc 100644
--- a/examples/quick/views/listview/sections.qml
+++ b/examples/quick/views/listview/sections.qml
@@ -4,7 +4,7 @@
// This example shows how a ListView can be separated into sections using
// the ListView.section attached property.
-import QtQuick 2.0
+import QtQuick
import "content"
Rectangle {
diff --git a/examples/quick/views/objectmodel/objectmodel.qml b/examples/quick/views/objectmodel/objectmodel.qml
index d6ae007669..898ef7f9e2 100644
--- a/examples/quick/views/objectmodel/objectmodel.qml
+++ b/examples/quick/views/objectmodel/objectmodel.qml
@@ -4,8 +4,8 @@
// This example demonstrates placing items in a view using
// an ObjectModel
-import QtQuick 2.0
-import QtQml.Models 2.1
+import QtQuick
+import QtQml.Models
Rectangle {
id: root
diff --git a/examples/quick/views/package/Delegate.qml b/examples/quick/views/package/Delegate.qml
index 9595d664c1..2e810aebec 100644
--- a/examples/quick/views/package/Delegate.qml
+++ b/examples/quick/views/package/Delegate.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
//! [0]
Package {
diff --git a/examples/quick/views/package/view.qml b/examples/quick/views/package/view.qml
index 7ae6085f5c..696557ed7c 100644
--- a/examples/quick/views/package/view.qml
+++ b/examples/quick/views/package/view.qml
@@ -1,8 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtQml.Models 2.1
+import QtQuick
+import QtQml.Models
Rectangle {
id: root
diff --git a/examples/quick/views/pathview/pathview-example.qml b/examples/quick/views/pathview/pathview-example.qml
index 0b524feb10..19fd470c04 100644
--- a/examples/quick/views/pathview/pathview-example.qml
+++ b/examples/quick/views/pathview/pathview-example.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
width: 400; height: 240
diff --git a/examples/quickcontrols2/chattutorial/chapter1/chapter1.pro b/examples/quickcontrols2/chattutorial/chapter1/chapter1.pro
index 221bb855f5..6b50809f20 100644
--- a/examples/quickcontrols2/chattutorial/chapter1/chapter1.pro
+++ b/examples/quickcontrols2/chattutorial/chapter1/chapter1.pro
@@ -5,8 +5,9 @@ CONFIG += c++11
SOURCES += main.cpp
-RESOURCES += \
- main.qml \
+resources.files = main.qml
+resources.prefix = chapter1/
+RESOURCES += resources \
qtquickcontrols2.conf
target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter1
diff --git a/examples/quickcontrols2/chattutorial/chapter2/chapter2.pro b/examples/quickcontrols2/chattutorial/chapter2/chapter2.pro
index e217934b7e..15429b7c89 100644
--- a/examples/quickcontrols2/chattutorial/chapter2/chapter2.pro
+++ b/examples/quickcontrols2/chattutorial/chapter2/chapter2.pro
@@ -5,7 +5,7 @@ CONFIG += c++11
SOURCES += main.cpp
-RESOURCES += \
+resources.files = \
images/Albert_Einstein.png \
images/Albert_Einstein@2x.png \
images/Albert_Einstein@3x.png \
@@ -18,7 +18,9 @@ RESOURCES += \
images/Hans_Gude@2x.png \
images/Hans_Gude@3x.png \
images/Hans_Gude@4x.png \
- main.qml \
+ main.qml
+resources.prefix = chapter2/
+RESOURCES += resources \
qtquickcontrols2.conf
target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter2
diff --git a/examples/quickcontrols2/chattutorial/chapter3/chapter3.pro b/examples/quickcontrols2/chattutorial/chapter3/chapter3.pro
index a5e500d9db..42adc69fe9 100644
--- a/examples/quickcontrols2/chattutorial/chapter3/chapter3.pro
+++ b/examples/quickcontrols2/chattutorial/chapter3/chapter3.pro
@@ -5,7 +5,7 @@ CONFIG += c++11
SOURCES += main.cpp
-RESOURCES += \
+resources.files = \
ContactPage.qml \
ConversationPage.qml \
images/Albert_Einstein.png \
@@ -20,7 +20,9 @@ RESOURCES += \
images/Hans_Gude@2x.png \
images/Hans_Gude@3x.png \
images/Hans_Gude@4x.png \
- main.qml \
+ main.qml
+resources.prefix = chapter3/
+RESOURCES += resources \
qtquickcontrols2.conf
target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter3
diff --git a/examples/quickcontrols2/chattutorial/chapter4/chapter4.pro b/examples/quickcontrols2/chattutorial/chapter4/chapter4.pro
index dd2241355b..ae8141f7f1 100644
--- a/examples/quickcontrols2/chattutorial/chapter4/chapter4.pro
+++ b/examples/quickcontrols2/chattutorial/chapter4/chapter4.pro
@@ -10,7 +10,7 @@ SOURCES += main.cpp \
sqlcontactmodel.cpp \
sqlconversationmodel.cpp
-RESOURCES += \
+resources.files = \
ContactPage.qml \
ConversationPage.qml \
images/Albert_Einstein.png \
@@ -25,7 +25,9 @@ RESOURCES += \
images/Hans_Gude@2x.png \
images/Hans_Gude@3x.png \
images/Hans_Gude@4x.png \
- main.qml \
+ main.qml
+resources.prefix = chapter4/
+RESOURCES += resources \
qtquickcontrols2.conf
target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter4
diff --git a/examples/quickcontrols2/chattutorial/chapter5/chapter5.pro b/examples/quickcontrols2/chattutorial/chapter5/chapter5.pro
index 1ca8998427..625642d7b5 100644
--- a/examples/quickcontrols2/chattutorial/chapter5/chapter5.pro
+++ b/examples/quickcontrols2/chattutorial/chapter5/chapter5.pro
@@ -10,7 +10,7 @@ SOURCES += main.cpp \
sqlcontactmodel.cpp \
sqlconversationmodel.cpp
-RESOURCES += \
+resources.files = \
+Material/ChatToolBar.qml \
ChatToolBar.qml \
ContactPage.qml \
@@ -27,7 +27,9 @@ RESOURCES += \
images/Hans_Gude@2x.png \
images/Hans_Gude@3x.png \
images/Hans_Gude@4x.png \
- main.qml \
+ main.qml
+resources.prefix = chapter5/
+RESOURCES += resources \
qtquickcontrols2.conf
target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter5
diff --git a/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc b/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc
index 31c25bfe1a..52228b900d 100644
--- a/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc
+++ b/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc
@@ -179,7 +179,7 @@ project.
The \c SOURCES variable lists all of the source files that should be compiled.
A similar variable, \c HEADERS, is available for header files.
-\printline RESOURCES
+\printuntil qtquickcontrols2
The next line tells \c qmake that we have a collection of
\l {The Qt Resource System}{resources} that should be built into the
diff --git a/examples/quickcontrols2/contactlist/CMakeLists.txt b/examples/quickcontrols2/contactlist/CMakeLists.txt
index 58e6299263..3bf15f7c4d 100644
--- a/examples/quickcontrols2/contactlist/CMakeLists.txt
+++ b/examples/quickcontrols2/contactlist/CMakeLists.txt
@@ -11,41 +11,32 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/contactlist")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick)
-qt_add_executable(contactlist
+qt_add_executable(contactlistexample WIN32 MACOSX_BUNDLE
contactmodel.cpp contactmodel.h
main.cpp
)
-set_target_properties(contactlist PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
+qt_add_qml_module(contactlistexample
+ URI contactlist
+ VERSION 1.0
+ NO_RESOURCE_TARGET_PATH
+ QML_FILES
+ "ContactDelegate.ui.qml"
+ "ContactDialog.qml"
+ "ContactForm.ui.qml"
+ "ContactView.ui.qml"
+ "SectionDelegate.ui.qml"
+ "contactlist.qml"
+ "designer/Backend/ContactModel.qml"
)
-target_link_libraries(contactlist PUBLIC
+target_link_libraries(contactlistexample PUBLIC
Qt::Core
Qt::Gui
Qt::Quick
)
-# Resources:
-set(qmake_immediate_resource_files
- "ContactDelegate.ui.qml"
- "ContactDialog.qml"
- "ContactForm.ui.qml"
- "ContactView.ui.qml"
- "SectionDelegate.ui.qml"
- "contactlist.qml"
- "designer/Backend/ContactModel.qml"
-)
-
-qt6_add_resources(contactlist "qmake_immediate"
- PREFIX
- "/"
- FILES
- ${qmake_immediate_resource_files}
-)
-
-install(TARGETS contactlist
+install(TARGETS contactlistexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quickcontrols2/contactlist/contactlist.qml b/examples/quickcontrols2/contactlist/contactlist.qml
index aa8ab08e65..28f887f2db 100644
--- a/examples/quickcontrols2/contactlist/contactlist.qml
+++ b/examples/quickcontrols2/contactlist/contactlist.qml
@@ -16,7 +16,7 @@ ApplicationWindow {
ContactDialog {
id: contactDialog
- onFinished: {
+ onFinished: function(fullName, address, city, number) {
if (currentContact === -1)
contactView.model.append(fullName, address, city, number)
else
diff --git a/examples/quickcontrols2/eventcalendar/doc/src/qtquickcontrols2-eventcalendar.qdoc b/examples/quickcontrols2/eventcalendar/doc/src/qtquickcontrols2-eventcalendar.qdoc
index af0bc07c57..cc0b031b51 100644
--- a/examples/quickcontrols2/eventcalendar/doc/src/qtquickcontrols2-eventcalendar.qdoc
+++ b/examples/quickcontrols2/eventcalendar/doc/src/qtquickcontrols2-eventcalendar.qdoc
@@ -8,7 +8,7 @@
\ingroup qtquickcontrols2-examples
\brief A simple event calendar.
- \image qtquickcontrols2-gallery-menu.png
+ \image qtquickcalendar-eventcalendar.png
The Event Calendar example is a simple application that shows how to use
\l DayOfWeekRow, \l WeekNumberColumn, and \l MonthGrid to create a calendar.
diff --git a/examples/quickcontrols2/flatstyle/CMakeLists.txt b/examples/quickcontrols2/flatstyle/CMakeLists.txt
index bc61738186..69b216864f 100644
--- a/examples/quickcontrols2/flatstyle/CMakeLists.txt
+++ b/examples/quickcontrols2/flatstyle/CMakeLists.txt
@@ -11,16 +11,28 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/flatstyle")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick QuickControls2 Widgets)
-qt_add_executable(flatstyle
+qt_add_executable(flatstyleexample WIN32 MACOSX_BUNDLE
main.cpp
)
-set_target_properties(flatstyle PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
+qt_add_qml_module(flatstyleexample
+ URI flatstyle
+ VERSION 1.0
+ NO_RESOURCE_TARGET_PATH
+ QML_FILES
+ "MainForm.ui.qml"
+ "flatstyle.qml"
+ "imports/Flat/Button.qml"
+ "imports/Flat/CheckBox.qml"
+ "imports/Flat/Switch.qml"
+ "imports/Theme/Theme.qml"
+ RESOURCES
+ "imports/Flat/qmldir"
+ "imports/Theme/qmldir"
+ "qtquickcontrols2.conf"
)
-target_link_libraries(flatstyle PUBLIC
+target_link_libraries(flatstyleexample PUBLIC
Qt::Core
Qt::Gui
Qt::Quick
@@ -28,27 +40,7 @@ target_link_libraries(flatstyle PUBLIC
Qt::Widgets
)
-# Resources:
-set(qmake_immediate_resource_files
- "MainForm.ui.qml"
- "flatstyle.qml"
- "imports/Flat/Button.qml"
- "imports/Flat/CheckBox.qml"
- "imports/Flat/Switch.qml"
- "imports/Flat/qmldir"
- "imports/Theme/Theme.qml"
- "imports/Theme/qmldir"
- "qtquickcontrols2.conf"
-)
-
-qt6_add_resources(flatstyle "qmake_immediate"
- PREFIX
- "/"
- FILES
- ${qmake_immediate_resource_files}
-)
-
-install(TARGETS flatstyle
+install(TARGETS flatstyleexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quickcontrols2/gallery/CMakeLists.txt b/examples/quickcontrols2/gallery/CMakeLists.txt
index 3d689fe6b1..fff4253b4b 100644
--- a/examples/quickcontrols2/gallery/CMakeLists.txt
+++ b/examples/quickcontrols2/gallery/CMakeLists.txt
@@ -11,16 +11,76 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/gallery")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick QuickControls2)
-qt_add_executable(gallery_controls2
+qt_add_executable(galleryexample WIN32 MACOSX_BUNDLE
gallery.cpp
)
-set_target_properties(gallery_controls2 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
+qt_add_qml_module(galleryexample
+ URI gallery
+ VERSION 1.0
+ NO_RESOURCE_TARGET_PATH
+ QML_FILES
+ "+Material/ToolBar.qml"
+ "ToolBar.qml"
+ "gallery.qml"
+ "pages/BusyIndicatorPage.qml"
+ "pages/ButtonPage.qml"
+ "pages/CheckBoxPage.qml"
+ "pages/ComboBoxPage.qml"
+ "pages/DelayButtonPage.qml"
+ "pages/DelegatePage.qml"
+ "pages/DialPage.qml"
+ "pages/DialogPage.qml"
+ "pages/FramePage.qml"
+ "pages/GroupBoxPage.qml"
+ "pages/PageIndicatorPage.qml"
+ "pages/ProgressBarPage.qml"
+ "pages/RadioButtonPage.qml"
+ "pages/RangeSliderPage.qml"
+ "pages/ScrollBarPage.qml"
+ "pages/ScrollIndicatorPage.qml"
+ "pages/ScrollablePage.qml"
+ "pages/SliderPage.qml"
+ "pages/SpinBoxPage.qml"
+ "pages/StackViewPage.qml"
+ "pages/SwipeViewPage.qml"
+ "pages/SwitchPage.qml"
+ "pages/TabBarPage.qml"
+ "pages/TextAreaPage.qml"
+ "pages/TextFieldPage.qml"
+ "pages/ToolTipPage.qml"
+ "pages/TumblerPage.qml"
+ RESOURCES
+ "icons/gallery/20x20/back.png"
+ "icons/gallery/20x20/drawer.png"
+ "icons/gallery/20x20/menu.png"
+ "icons/gallery/20x20@2/back.png"
+ "icons/gallery/20x20@2/drawer.png"
+ "icons/gallery/20x20@2/menu.png"
+ "icons/gallery/20x20@3/back.png"
+ "icons/gallery/20x20@3/drawer.png"
+ "icons/gallery/20x20@3/menu.png"
+ "icons/gallery/20x20@4/back.png"
+ "icons/gallery/20x20@4/drawer.png"
+ "icons/gallery/20x20@4/menu.png"
+ "icons/gallery/index.theme"
+ "images/arrow.png"
+ "images/arrow@2x.png"
+ "images/arrow@3x.png"
+ "images/arrow@4x.png"
+ "images/arrows.png"
+ "images/arrows@2x.png"
+ "images/arrows@3x.png"
+ "images/arrows@4x.png"
+ "images/qt-logo.png"
+ "images/qt-logo@2x.png"
+ "images/qt-logo@3x.png"
+ "images/qt-logo@4x.png"
+ "qmldir"
+ "qtquickcontrols2.conf"
)
-target_link_libraries(gallery_controls2 PUBLIC
+target_link_libraries(galleryexample PUBLIC
Qt::Core
Qt::Gui
Qt::Quick
@@ -31,78 +91,10 @@ if(UNIX AND NOT APPLE AND CMAKE_CROSSCOMPILING)
find_package(Qt6 REQUIRED COMPONENTS QuickTemplates2)
# Work around QTBUG-86533
- target_link_libraries(gallery_controls2 PRIVATE Qt::QuickTemplates2)
+ target_link_libraries(galleryexample PRIVATE Qt::QuickTemplates2)
endif()
-# Resources:
-set(qmake_immediate_resource_files
- "+Material/ToolBar.qml"
- "ToolBar.qml"
- "gallery.qml"
- "icons/gallery/20x20/back.png"
- "icons/gallery/20x20/drawer.png"
- "icons/gallery/20x20/menu.png"
- "icons/gallery/20x20@2/back.png"
- "icons/gallery/20x20@2/drawer.png"
- "icons/gallery/20x20@2/menu.png"
- "icons/gallery/20x20@3/back.png"
- "icons/gallery/20x20@3/drawer.png"
- "icons/gallery/20x20@3/menu.png"
- "icons/gallery/20x20@4/back.png"
- "icons/gallery/20x20@4/drawer.png"
- "icons/gallery/20x20@4/menu.png"
- "icons/gallery/index.theme"
- "images/arrow.png"
- "images/arrow@2x.png"
- "images/arrow@3x.png"
- "images/arrow@4x.png"
- "images/arrows.png"
- "images/arrows@2x.png"
- "images/arrows@3x.png"
- "images/arrows@4x.png"
- "images/qt-logo.png"
- "images/qt-logo@2x.png"
- "images/qt-logo@3x.png"
- "images/qt-logo@4x.png"
- "pages/BusyIndicatorPage.qml"
- "pages/ButtonPage.qml"
- "pages/CheckBoxPage.qml"
- "pages/ComboBoxPage.qml"
- "pages/DelayButtonPage.qml"
- "pages/DelegatePage.qml"
- "pages/DialPage.qml"
- "pages/DialogPage.qml"
- "pages/FramePage.qml"
- "pages/GroupBoxPage.qml"
- "pages/PageIndicatorPage.qml"
- "pages/ProgressBarPage.qml"
- "pages/RadioButtonPage.qml"
- "pages/RangeSliderPage.qml"
- "pages/ScrollBarPage.qml"
- "pages/ScrollIndicatorPage.qml"
- "pages/ScrollablePage.qml"
- "pages/SliderPage.qml"
- "pages/SpinBoxPage.qml"
- "pages/StackViewPage.qml"
- "pages/SwipeViewPage.qml"
- "pages/SwitchPage.qml"
- "pages/TabBarPage.qml"
- "pages/TextAreaPage.qml"
- "pages/TextFieldPage.qml"
- "pages/ToolTipPage.qml"
- "pages/TumblerPage.qml"
- "qmldir"
- "qtquickcontrols2.conf"
-)
-
-qt6_add_resources(gallery_controls2 "qmake_immediate"
- PREFIX
- "/"
- FILES
- ${qmake_immediate_resource_files}
-)
-
-install(TARGETS gallery_controls2
+install(TARGETS galleryexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quickcontrols2/imagine/automotive/CMakeLists.txt b/examples/quickcontrols2/imagine/automotive/CMakeLists.txt
index 6316a61616..98b0af0668 100644
--- a/examples/quickcontrols2/imagine/automotive/CMakeLists.txt
+++ b/examples/quickcontrols2/imagine/automotive/CMakeLists.txt
@@ -11,175 +11,132 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/imagine/automotive
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick QuickControls2)
-qt_add_executable(automotive
+qt_add_executable(automotiveexample WIN32 MACOSX_BUNDLE
automotive.cpp
)
-set_target_properties(automotive PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
+qt_add_qml_module(automotiveexample
+ URI automotive
+ VERSION 1.0
+ NO_RESOURCE_TARGET_PATH
+ QML_FILES
+ "qml/FeatureButton.qml"
+ "qml/LargeLabel.qml"
+ "qml/automotive.qml"
+
+ RESOURCES
+ "icons/automotive/44x44/air-con.png"
+ "icons/automotive/44x44/command.png"
+ "icons/automotive/44x44/message.png"
+ "icons/automotive/44x44/music.png"
+ "icons/automotive/44x44/seats.png"
+ "icons/automotive/44x44/settings.png"
+ "icons/automotive/44x44/statistics.png"
+ "icons/automotive/44x44/windows.png"
+ "icons/automotive/44x44@2/air-con.png"
+ "icons/automotive/44x44@2/command.png"
+ "icons/automotive/44x44@2/message.png"
+ "icons/automotive/44x44@2/music.png"
+ "icons/automotive/44x44@2/navigation.png"
+ "icons/automotive/44x44@2/seats.png"
+ "icons/automotive/44x44@2/settings.png"
+ "icons/automotive/44x44@2/statistics.png"
+ "icons/automotive/44x44@2/windows.png"
+ "icons/automotive/icons.svg"
+ "icons/automotive/index.theme"
+ "icons/car.png"
+ "icons/car@2x.png"
+ "icons/warning.png"
+ "icons/warning@2x.png"
+ "icons/weather.png"
+ "icons/weather@2x.png"
+ "imagine-assets/applicationwindow-background.png"
+ "imagine-assets/applicationwindow-background@2x.png"
+ "imagine-assets/button-background-checked-hovered.9.png"
+ "imagine-assets/button-background-checked-hovered@2x.9.png"
+ "imagine-assets/button-background-checked.9.png"
+ "imagine-assets/button-background-checked@2x.9.png"
+ "imagine-assets/button-background-hovered.9.png"
+ "imagine-assets/button-background-hovered@2x.9.png"
+ "imagine-assets/button-background-pressed.9.png"
+ "imagine-assets/button-background-pressed@2x.9.png"
+ "imagine-assets/button-background.9.png"
+ "imagine-assets/button-background@2x.9.png"
+ "imagine-assets/dial-background-hovered.png"
+ "imagine-assets/dial-background-hovered@2x.png"
+ "imagine-assets/dial-background-pressed.png"
+ "imagine-assets/dial-background-pressed@2x.png"
+ "imagine-assets/dial-background.png"
+ "imagine-assets/dial-background@2x.png"
+ "imagine-assets/dial-handle-pressed.png"
+ "imagine-assets/dial-handle-pressed@2x.png"
+ "imagine-assets/dial-handle.png"
+ "imagine-assets/dial-handle@2x.png"
+ "imagine-assets/frame-background.9.png"
+ "imagine-assets/frame-background@2x.9.png"
+ "imagine-assets/itemdelegate-background-checked.9.png"
+ "imagine-assets/itemdelegate-background-checked@2x.9.png"
+ "imagine-assets/itemdelegate-background-hovered.9.png"
+ "imagine-assets/itemdelegate-background-hovered@2x.9.png"
+ "imagine-assets/itemdelegate-background-pressed.9.png"
+ "imagine-assets/itemdelegate-background-pressed@2x.9.png"
+ "imagine-assets/itemdelegate-background.9.png"
+ "imagine-assets/itemdelegate-background@2x.9.png"
+ "imagine-assets/radiobutton-indicator-checked-hovered.png"
+ "imagine-assets/radiobutton-indicator-checked-hovered@2x.png"
+ "imagine-assets/radiobutton-indicator-checked-pressed.png"
+ "imagine-assets/radiobutton-indicator-checked-pressed@2x.png"
+ "imagine-assets/radiobutton-indicator-checked.png"
+ "imagine-assets/radiobutton-indicator-checked@2x.png"
+ "imagine-assets/radiobutton-indicator-hovered.png"
+ "imagine-assets/radiobutton-indicator-hovered@2x.png"
+ "imagine-assets/radiobutton-indicator-pressed.png"
+ "imagine-assets/radiobutton-indicator-pressed@2x.png"
+ "imagine-assets/radiobutton-indicator.png"
+ "imagine-assets/radiobutton-indicator@2x.png"
+ "imagine-assets/scrollindicator-handle.png"
+ "imagine-assets/scrollindicator-handle@2x.png"
+ "imagine-assets/slider-background-horizontal.9.png"
+ "imagine-assets/slider-background-horizontal@2x.9.png"
+ "imagine-assets/slider-handle-hovered.png"
+ "imagine-assets/slider-handle-hovered@2x.png"
+ "imagine-assets/slider-handle-pressed.png"
+ "imagine-assets/slider-handle-pressed@2x.png"
+ "imagine-assets/slider-handle.png"
+ "imagine-assets/slider-handle@2x.png"
+ "imagine-assets/slider-progress-horizontal-pressed.9.png"
+ "imagine-assets/slider-progress-horizontal-pressed@2x.9.png"
+ "imagine-assets/slider-progress-horizontal.9.png"
+ "imagine-assets/slider-progress-horizontal@2x.9.png"
+ "imagine-assets/switchdelegate-background.9.png"
+ "imagine-assets/switchdelegate-background@2x.9.png"
+ "imagine-assets/switchdelegate-handle-checked-hovered.png"
+ "imagine-assets/switchdelegate-handle-checked-hovered@2x.png"
+ "imagine-assets/switchdelegate-handle-checked.png"
+ "imagine-assets/switchdelegate-handle-checked@2x.png"
+ "imagine-assets/switchdelegate-handle-hovered.png"
+ "imagine-assets/switchdelegate-handle-hovered@2x.png"
+ "imagine-assets/switchdelegate-handle-pressed.png"
+ "imagine-assets/switchdelegate-handle-pressed@2x.png"
+ "imagine-assets/switchdelegate-handle.png"
+ "imagine-assets/switchdelegate-handle@2x.png"
+ "imagine-assets/switchdelegate-indicator-pressed.png"
+ "imagine-assets/switchdelegate-indicator-pressed@2x.png"
+ "imagine-assets/switchdelegate-indicator.png"
+ "imagine-assets/switchdelegate-indicator@2x.png"
+ "imagine-assets/toolseparator-separator-vertical.9.png"
+ "imagine-assets/toolseparator-separator-vertical@2x.9.png"
+ "qtquickcontrols2.conf"
)
-target_link_libraries(automotive PUBLIC
+target_link_libraries(automotiveexample PUBLIC
Qt::Core
Qt::Gui
Qt::Quick
Qt::QuickControls2
)
-# Resources:
-set(icons_resource_files
- "icons/automotive/44x44/air-con.png"
- "icons/automotive/44x44/command.png"
- "icons/automotive/44x44/message.png"
- "icons/automotive/44x44/music.png"
- "icons/automotive/44x44/seats.png"
- "icons/automotive/44x44/settings.png"
- "icons/automotive/44x44/statistics.png"
- "icons/automotive/44x44/windows.png"
- "icons/automotive/44x44@2/air-con.png"
- "icons/automotive/44x44@2/command.png"
- "icons/automotive/44x44@2/message.png"
- "icons/automotive/44x44@2/music.png"
- "icons/automotive/44x44@2/navigation.png"
- "icons/automotive/44x44@2/seats.png"
- "icons/automotive/44x44@2/settings.png"
- "icons/automotive/44x44@2/statistics.png"
- "icons/automotive/44x44@2/windows.png"
- "icons/automotive/icons.svg"
- "icons/automotive/index.theme"
- "icons/car.png"
- "icons/car@2x.png"
- "icons/warning.png"
- "icons/warning@2x.png"
- "icons/weather.png"
- "icons/weather@2x.png"
-)
-
-qt6_add_resources(automotive "icons"
- PREFIX
- "/icons"
- BASE
- "icons"
- FILES
- ${icons_resource_files}
-)
-
-set(imagine-assets_resource_files
- "imagine-assets/applicationwindow-background.png"
- "imagine-assets/applicationwindow-background@2x.png"
- "imagine-assets/button-background-checked-hovered.9.png"
- "imagine-assets/button-background-checked-hovered@2x.9.png"
- "imagine-assets/button-background-checked.9.png"
- "imagine-assets/button-background-checked@2x.9.png"
- "imagine-assets/button-background-hovered.9.png"
- "imagine-assets/button-background-hovered@2x.9.png"
- "imagine-assets/button-background-pressed.9.png"
- "imagine-assets/button-background-pressed@2x.9.png"
- "imagine-assets/button-background.9.png"
- "imagine-assets/button-background@2x.9.png"
- "imagine-assets/dial-background-hovered.png"
- "imagine-assets/dial-background-hovered@2x.png"
- "imagine-assets/dial-background-pressed.png"
- "imagine-assets/dial-background-pressed@2x.png"
- "imagine-assets/dial-background.png"
- "imagine-assets/dial-background@2x.png"
- "imagine-assets/dial-handle-pressed.png"
- "imagine-assets/dial-handle-pressed@2x.png"
- "imagine-assets/dial-handle.png"
- "imagine-assets/dial-handle@2x.png"
- "imagine-assets/frame-background.9.png"
- "imagine-assets/frame-background@2x.9.png"
- "imagine-assets/itemdelegate-background-checked.9.png"
- "imagine-assets/itemdelegate-background-checked@2x.9.png"
- "imagine-assets/itemdelegate-background-hovered.9.png"
- "imagine-assets/itemdelegate-background-hovered@2x.9.png"
- "imagine-assets/itemdelegate-background-pressed.9.png"
- "imagine-assets/itemdelegate-background-pressed@2x.9.png"
- "imagine-assets/itemdelegate-background.9.png"
- "imagine-assets/itemdelegate-background@2x.9.png"
- "imagine-assets/radiobutton-indicator-checked-hovered.png"
- "imagine-assets/radiobutton-indicator-checked-hovered@2x.png"
- "imagine-assets/radiobutton-indicator-checked-pressed.png"
- "imagine-assets/radiobutton-indicator-checked-pressed@2x.png"
- "imagine-assets/radiobutton-indicator-checked.png"
- "imagine-assets/radiobutton-indicator-checked@2x.png"
- "imagine-assets/radiobutton-indicator-hovered.png"
- "imagine-assets/radiobutton-indicator-hovered@2x.png"
- "imagine-assets/radiobutton-indicator-pressed.png"
- "imagine-assets/radiobutton-indicator-pressed@2x.png"
- "imagine-assets/radiobutton-indicator.png"
- "imagine-assets/radiobutton-indicator@2x.png"
- "imagine-assets/scrollindicator-handle.png"
- "imagine-assets/scrollindicator-handle@2x.png"
- "imagine-assets/slider-background-horizontal.9.png"
- "imagine-assets/slider-background-horizontal@2x.9.png"
- "imagine-assets/slider-handle-hovered.png"
- "imagine-assets/slider-handle-hovered@2x.png"
- "imagine-assets/slider-handle-pressed.png"
- "imagine-assets/slider-handle-pressed@2x.png"
- "imagine-assets/slider-handle.png"
- "imagine-assets/slider-handle@2x.png"
- "imagine-assets/slider-progress-horizontal-pressed.9.png"
- "imagine-assets/slider-progress-horizontal-pressed@2x.9.png"
- "imagine-assets/slider-progress-horizontal.9.png"
- "imagine-assets/slider-progress-horizontal@2x.9.png"
- "imagine-assets/switchdelegate-background.9.png"
- "imagine-assets/switchdelegate-background@2x.9.png"
- "imagine-assets/switchdelegate-handle-checked-hovered.png"
- "imagine-assets/switchdelegate-handle-checked-hovered@2x.png"
- "imagine-assets/switchdelegate-handle-checked.png"
- "imagine-assets/switchdelegate-handle-checked@2x.png"
- "imagine-assets/switchdelegate-handle-hovered.png"
- "imagine-assets/switchdelegate-handle-hovered@2x.png"
- "imagine-assets/switchdelegate-handle-pressed.png"
- "imagine-assets/switchdelegate-handle-pressed@2x.png"
- "imagine-assets/switchdelegate-handle.png"
- "imagine-assets/switchdelegate-handle@2x.png"
- "imagine-assets/switchdelegate-indicator-pressed.png"
- "imagine-assets/switchdelegate-indicator-pressed@2x.png"
- "imagine-assets/switchdelegate-indicator.png"
- "imagine-assets/switchdelegate-indicator@2x.png"
- "imagine-assets/toolseparator-separator-vertical.9.png"
- "imagine-assets/toolseparator-separator-vertical@2x.9.png"
-)
-
-qt6_add_resources(automotive "imagine-assets"
- PREFIX
- "/imagine-assets"
- BASE
- "imagine-assets"
- FILES
- ${imagine-assets_resource_files}
-)
-
-set(qml_resource_files
- "qml/FeatureButton.qml"
- "qml/LargeLabel.qml"
- "qml/automotive.qml"
-)
-
-qt6_add_resources(automotive "qml"
- PREFIX
- "/qml"
- BASE
- "qml"
- FILES
- ${qml_resource_files}
-)
-
-set(qmake_immediate_resource_files
- "qtquickcontrols2.conf"
-)
-
-qt6_add_resources(automotive "qmake_immediate"
- PREFIX
- "/"
- FILES
- ${qmake_immediate_resource_files}
-)
-
-install(TARGETS automotive
+install(TARGETS automotiveexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quickcontrols2/imagine/musicplayer/CMakeLists.txt b/examples/quickcontrols2/imagine/musicplayer/CMakeLists.txt
index 845f35c942..78e436e952 100644
--- a/examples/quickcontrols2/imagine/musicplayer/CMakeLists.txt
+++ b/examples/quickcontrols2/imagine/musicplayer/CMakeLists.txt
@@ -11,206 +11,174 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/imagine/musicplaye
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick QuickControls2)
-qt_add_executable(musicplayer
+qt_add_executable(musicplayerexample WIN32 MACOSX_BUNDLE
musicplayer.cpp
)
-set_target_properties(musicplayer PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
+qt_add_qml_module(musicplayerexample
+ URI musicplayer
+ VERSION 1.0
+ NO_RESOURCE_TARGET_PATH
+ QML_FILES
+ "musicplayer.qml"
+ RESOURCES
+ "icons/musicplayer/32x32/bluetooth.png"
+ "icons/musicplayer/32x32/cart.png"
+ "icons/musicplayer/32x32/cloud.png"
+ "icons/musicplayer/32x32/favorite.png"
+ "icons/musicplayer/32x32/filter.png"
+ "icons/musicplayer/32x32/folder.png"
+ "icons/musicplayer/32x32/message.png"
+ "icons/musicplayer/32x32/music.png"
+ "icons/musicplayer/32x32/next.png"
+ "icons/musicplayer/32x32/pause.png"
+ "icons/musicplayer/32x32/power.png"
+ "icons/musicplayer/32x32/previous.png"
+ "icons/musicplayer/32x32/repeat.png"
+ "icons/musicplayer/32x32/save.png"
+ "icons/musicplayer/32x32/settings.png"
+ "icons/musicplayer/32x32/shuffle.png"
+ "icons/musicplayer/32x32/stop.png"
+ "icons/musicplayer/32x32@2/bluetooth.png"
+ "icons/musicplayer/32x32@2/cart.png"
+ "icons/musicplayer/32x32@2/cloud.png"
+ "icons/musicplayer/32x32@2/favorite.png"
+ "icons/musicplayer/32x32@2/filter.png"
+ "icons/musicplayer/32x32@2/folder.png"
+ "icons/musicplayer/32x32@2/grid.png"
+ "icons/musicplayer/32x32@2/message.png"
+ "icons/musicplayer/32x32@2/music.png"
+ "icons/musicplayer/32x32@2/next.png"
+ "icons/musicplayer/32x32@2/pause.png"
+ "icons/musicplayer/32x32@2/power.png"
+ "icons/musicplayer/32x32@2/previous.png"
+ "icons/musicplayer/32x32@2/repeat.png"
+ "icons/musicplayer/32x32@2/save.png"
+ "icons/musicplayer/32x32@2/settings.png"
+ "icons/musicplayer/32x32@2/shuffle.png"
+ "icons/musicplayer/32x32@2/stop.png"
+ "icons/musicplayer/index.theme"
+ "images/album-cover.jpg"
+ "imagine-assets/applicationwindow-background.png"
+ "imagine-assets/button-background-checked-hovered.9.png"
+ "imagine-assets/button-background-checked-hovered@2x.9.png"
+ "imagine-assets/button-background-checked.9.png"
+ "imagine-assets/button-background-checked@2x.9.png"
+ "imagine-assets/button-background-disabled.9.png"
+ "imagine-assets/button-background-disabled@2x.9.png"
+ "imagine-assets/button-background-hovered.9.png"
+ "imagine-assets/button-background-hovered@2x.9.png"
+ "imagine-assets/button-background-pressed.9.png"
+ "imagine-assets/button-background-pressed@2x.9.png"
+ "imagine-assets/button-background.9.png"
+ "imagine-assets/button-background@2x.9.png"
+ "imagine-assets/combobox-background-hovered.9.png"
+ "imagine-assets/combobox-background-hovered@2x.9.png"
+ "imagine-assets/combobox-background-open.9.png"
+ "imagine-assets/combobox-background-open@2x.9.png"
+ "imagine-assets/combobox-background-pressed.9.png"
+ "imagine-assets/combobox-background-pressed@2x.9.png"
+ "imagine-assets/combobox-background.9.png"
+ "imagine-assets/combobox-background@2x.9.png"
+ "imagine-assets/combobox-indicator-hovered.png"
+ "imagine-assets/combobox-indicator-hovered@2x.png"
+ "imagine-assets/combobox-indicator-open.png"
+ "imagine-assets/combobox-indicator-open@2x.png"
+ "imagine-assets/combobox-indicator-pressed.png"
+ "imagine-assets/combobox-indicator-pressed@2x.png"
+ "imagine-assets/combobox-indicator.png"
+ "imagine-assets/combobox-indicator@2x.png"
+ "imagine-assets/combobox-popup.9.png"
+ "imagine-assets/combobox-popup@2x.9.png"
+ "imagine-assets/dial-background-hovered.png"
+ "imagine-assets/dial-background-hovered@2x.png"
+ "imagine-assets/dial-background-pressed.png"
+ "imagine-assets/dial-background-pressed@2x.png"
+ "imagine-assets/dial-background.png"
+ "imagine-assets/dial-background@2x.png"
+ "imagine-assets/dial-handle-pressed.png"
+ "imagine-assets/dial-handle-pressed@2x.png"
+ "imagine-assets/dial-handle.png"
+ "imagine-assets/dial-handle@2x.png"
+ "imagine-assets/frame-background.9.png"
+ "imagine-assets/frame-background@2x.9.png"
+ "imagine-assets/itemdelegate-background-checked.9.png"
+ "imagine-assets/itemdelegate-background-checked@2x.9.png"
+ "imagine-assets/itemdelegate-background-disabled.9.png"
+ "imagine-assets/itemdelegate-background-disabled@2x.9.png"
+ "imagine-assets/itemdelegate-background-hovered.9.png"
+ "imagine-assets/itemdelegate-background-hovered@2x.9.png"
+ "imagine-assets/itemdelegate-background-pressed.9.png"
+ "imagine-assets/itemdelegate-background-pressed@2x.9.png"
+ "imagine-assets/itemdelegate-background.9.png"
+ "imagine-assets/itemdelegate-background@2x.9.png"
+ "imagine-assets/roundbutton-background-checked-hovered.png"
+ "imagine-assets/roundbutton-background-checked-hovered@2x.png"
+ "imagine-assets/roundbutton-background-checked.png"
+ "imagine-assets/roundbutton-background-checked@2x.png"
+ "imagine-assets/roundbutton-background-disabled.png"
+ "imagine-assets/roundbutton-background-disabled@2x.png"
+ "imagine-assets/roundbutton-background-hovered.png"
+ "imagine-assets/roundbutton-background-hovered@2x.png"
+ "imagine-assets/roundbutton-background-pressed.png"
+ "imagine-assets/roundbutton-background-pressed@2x.png"
+ "imagine-assets/roundbutton-background.png"
+ "imagine-assets/roundbutton-background@2x.png"
+ "imagine-assets/scrollbar-handle-interactive-hovered.png"
+ "imagine-assets/scrollbar-handle-interactive-hovered@2x.png"
+ "imagine-assets/scrollbar-handle-interactive-pressed.png"
+ "imagine-assets/scrollbar-handle-interactive-pressed@2x.png"
+ "imagine-assets/scrollbar-handle-interactive.png"
+ "imagine-assets/scrollbar-handle-interactive@2x.png"
+ "imagine-assets/slider-background-horizontal-disabled.9.png"
+ "imagine-assets/slider-background-horizontal-disabled@2x.9.png"
+ "imagine-assets/slider-background-horizontal.9.png"
+ "imagine-assets/slider-background-horizontal@2x.9.png"
+ "imagine-assets/slider-background-vertical-disabled.9.png"
+ "imagine-assets/slider-background-vertical-disabled@2x.9.png"
+ "imagine-assets/slider-background-vertical.9.png"
+ "imagine-assets/slider-background-vertical@2x.9.png"
+ "imagine-assets/slider-handle-disabled.png"
+ "imagine-assets/slider-handle-disabled@2x.png"
+ "imagine-assets/slider-handle-hovered.png"
+ "imagine-assets/slider-handle-hovered@2x.png"
+ "imagine-assets/slider-handle.png"
+ "imagine-assets/slider-handle@2x.png"
+ "imagine-assets/slider-progress-horizontal.9.png"
+ "imagine-assets/slider-progress-horizontal@2x.9.png"
+ "imagine-assets/slider-progress-vertical-disabled.9.png"
+ "imagine-assets/slider-progress-vertical-disabled@2x.9.png"
+ "imagine-assets/slider-progress-vertical.9.png"
+ "imagine-assets/slider-progress-vertical@2x.9.png"
+ "imagine-assets/textfield-background-disabled.9.png"
+ "imagine-assets/textfield-background-disabled@2x.9.png"
+ "imagine-assets/textfield-background.9.png"
+ "imagine-assets/textfield-background@2x.9.png"
+ "imagine-assets/toolbar-background.9.png"
+ "imagine-assets/toolbar-background@2x.9.png"
+ "imagine-assets/toolbutton-background-checked-hovered.9.png"
+ "imagine-assets/toolbutton-background-checked-hovered@2x.9.png"
+ "imagine-assets/toolbutton-background-checked.9.png"
+ "imagine-assets/toolbutton-background-checked@2x.9.png"
+ "imagine-assets/toolbutton-background-hovered.9.png"
+ "imagine-assets/toolbutton-background-hovered@2x.9.png"
+ "imagine-assets/toolbutton-background-pressed.9.png"
+ "imagine-assets/toolbutton-background-pressed@2x.9.png"
+ "imagine-assets/toolbutton-background.9.png"
+ "imagine-assets/toolbutton-background@2x.9.png"
+ "imagine-assets/tooltip-background.9.png"
+ "imagine-assets/tooltip-background@2x.9.png"
+ "qtquickcontrols2.conf"
)
-target_link_libraries(musicplayer PUBLIC
+target_link_libraries(musicplayerexample PUBLIC
Qt::Core
Qt::Gui
Qt::Quick
Qt::QuickControls2
)
-# Resources:
-set(icons_resource_files
- "icons/musicplayer/32x32/bluetooth.png"
- "icons/musicplayer/32x32/cart.png"
- "icons/musicplayer/32x32/cloud.png"
- "icons/musicplayer/32x32/favorite.png"
- "icons/musicplayer/32x32/filter.png"
- "icons/musicplayer/32x32/folder.png"
- "icons/musicplayer/32x32/message.png"
- "icons/musicplayer/32x32/music.png"
- "icons/musicplayer/32x32/next.png"
- "icons/musicplayer/32x32/pause.png"
- "icons/musicplayer/32x32/power.png"
- "icons/musicplayer/32x32/previous.png"
- "icons/musicplayer/32x32/repeat.png"
- "icons/musicplayer/32x32/save.png"
- "icons/musicplayer/32x32/settings.png"
- "icons/musicplayer/32x32/shuffle.png"
- "icons/musicplayer/32x32/stop.png"
- "icons/musicplayer/32x32@2/bluetooth.png"
- "icons/musicplayer/32x32@2/cart.png"
- "icons/musicplayer/32x32@2/cloud.png"
- "icons/musicplayer/32x32@2/favorite.png"
- "icons/musicplayer/32x32@2/filter.png"
- "icons/musicplayer/32x32@2/folder.png"
- "icons/musicplayer/32x32@2/grid.png"
- "icons/musicplayer/32x32@2/message.png"
- "icons/musicplayer/32x32@2/music.png"
- "icons/musicplayer/32x32@2/next.png"
- "icons/musicplayer/32x32@2/pause.png"
- "icons/musicplayer/32x32@2/power.png"
- "icons/musicplayer/32x32@2/previous.png"
- "icons/musicplayer/32x32@2/repeat.png"
- "icons/musicplayer/32x32@2/save.png"
- "icons/musicplayer/32x32@2/settings.png"
- "icons/musicplayer/32x32@2/shuffle.png"
- "icons/musicplayer/32x32@2/stop.png"
- "icons/musicplayer/index.theme"
-)
-
-qt6_add_resources(musicplayer "icons"
- PREFIX
- "/icons"
- BASE
- "icons"
- FILES
- ${icons_resource_files}
-)
-
-set(imagine-assets_resource_files
- "imagine-assets/applicationwindow-background.png"
- "imagine-assets/button-background-checked-hovered.9.png"
- "imagine-assets/button-background-checked-hovered@2x.9.png"
- "imagine-assets/button-background-checked.9.png"
- "imagine-assets/button-background-checked@2x.9.png"
- "imagine-assets/button-background-disabled.9.png"
- "imagine-assets/button-background-disabled@2x.9.png"
- "imagine-assets/button-background-hovered.9.png"
- "imagine-assets/button-background-hovered@2x.9.png"
- "imagine-assets/button-background-pressed.9.png"
- "imagine-assets/button-background-pressed@2x.9.png"
- "imagine-assets/button-background.9.png"
- "imagine-assets/button-background@2x.9.png"
- "imagine-assets/combobox-background-hovered.9.png"
- "imagine-assets/combobox-background-hovered@2x.9.png"
- "imagine-assets/combobox-background-open.9.png"
- "imagine-assets/combobox-background-open@2x.9.png"
- "imagine-assets/combobox-background-pressed.9.png"
- "imagine-assets/combobox-background-pressed@2x.9.png"
- "imagine-assets/combobox-background.9.png"
- "imagine-assets/combobox-background@2x.9.png"
- "imagine-assets/combobox-indicator-hovered.png"
- "imagine-assets/combobox-indicator-hovered@2x.png"
- "imagine-assets/combobox-indicator-open.png"
- "imagine-assets/combobox-indicator-open@2x.png"
- "imagine-assets/combobox-indicator-pressed.png"
- "imagine-assets/combobox-indicator-pressed@2x.png"
- "imagine-assets/combobox-indicator.png"
- "imagine-assets/combobox-indicator@2x.png"
- "imagine-assets/combobox-popup.9.png"
- "imagine-assets/combobox-popup@2x.9.png"
- "imagine-assets/dial-background-hovered.png"
- "imagine-assets/dial-background-hovered@2x.png"
- "imagine-assets/dial-background-pressed.png"
- "imagine-assets/dial-background-pressed@2x.png"
- "imagine-assets/dial-background.png"
- "imagine-assets/dial-background@2x.png"
- "imagine-assets/dial-handle-pressed.png"
- "imagine-assets/dial-handle-pressed@2x.png"
- "imagine-assets/dial-handle.png"
- "imagine-assets/dial-handle@2x.png"
- "imagine-assets/frame-background.9.png"
- "imagine-assets/frame-background@2x.9.png"
- "imagine-assets/itemdelegate-background-checked.9.png"
- "imagine-assets/itemdelegate-background-checked@2x.9.png"
- "imagine-assets/itemdelegate-background-disabled.9.png"
- "imagine-assets/itemdelegate-background-disabled@2x.9.png"
- "imagine-assets/itemdelegate-background-hovered.9.png"
- "imagine-assets/itemdelegate-background-hovered@2x.9.png"
- "imagine-assets/itemdelegate-background-pressed.9.png"
- "imagine-assets/itemdelegate-background-pressed@2x.9.png"
- "imagine-assets/itemdelegate-background.9.png"
- "imagine-assets/itemdelegate-background@2x.9.png"
- "imagine-assets/roundbutton-background-checked-hovered.png"
- "imagine-assets/roundbutton-background-checked-hovered@2x.png"
- "imagine-assets/roundbutton-background-checked.png"
- "imagine-assets/roundbutton-background-checked@2x.png"
- "imagine-assets/roundbutton-background-disabled.png"
- "imagine-assets/roundbutton-background-disabled@2x.png"
- "imagine-assets/roundbutton-background-hovered.png"
- "imagine-assets/roundbutton-background-hovered@2x.png"
- "imagine-assets/roundbutton-background-pressed.png"
- "imagine-assets/roundbutton-background-pressed@2x.png"
- "imagine-assets/roundbutton-background.png"
- "imagine-assets/roundbutton-background@2x.png"
- "imagine-assets/scrollbar-handle-interactive-hovered.png"
- "imagine-assets/scrollbar-handle-interactive-hovered@2x.png"
- "imagine-assets/scrollbar-handle-interactive-pressed.png"
- "imagine-assets/scrollbar-handle-interactive-pressed@2x.png"
- "imagine-assets/scrollbar-handle-interactive.png"
- "imagine-assets/scrollbar-handle-interactive@2x.png"
- "imagine-assets/slider-background-horizontal-disabled.9.png"
- "imagine-assets/slider-background-horizontal-disabled@2x.9.png"
- "imagine-assets/slider-background-horizontal.9.png"
- "imagine-assets/slider-background-horizontal@2x.9.png"
- "imagine-assets/slider-background-vertical-disabled.9.png"
- "imagine-assets/slider-background-vertical-disabled@2x.9.png"
- "imagine-assets/slider-background-vertical.9.png"
- "imagine-assets/slider-background-vertical@2x.9.png"
- "imagine-assets/slider-handle-disabled.png"
- "imagine-assets/slider-handle-disabled@2x.png"
- "imagine-assets/slider-handle-hovered.png"
- "imagine-assets/slider-handle-hovered@2x.png"
- "imagine-assets/slider-handle.png"
- "imagine-assets/slider-handle@2x.png"
- "imagine-assets/slider-progress-horizontal.9.png"
- "imagine-assets/slider-progress-horizontal@2x.9.png"
- "imagine-assets/slider-progress-vertical-disabled.9.png"
- "imagine-assets/slider-progress-vertical-disabled@2x.9.png"
- "imagine-assets/slider-progress-vertical.9.png"
- "imagine-assets/slider-progress-vertical@2x.9.png"
- "imagine-assets/textfield-background-disabled.9.png"
- "imagine-assets/textfield-background-disabled@2x.9.png"
- "imagine-assets/textfield-background.9.png"
- "imagine-assets/textfield-background@2x.9.png"
- "imagine-assets/toolbar-background.9.png"
- "imagine-assets/toolbar-background@2x.9.png"
- "imagine-assets/toolbutton-background-checked-hovered.9.png"
- "imagine-assets/toolbutton-background-checked-hovered@2x.9.png"
- "imagine-assets/toolbutton-background-checked.9.png"
- "imagine-assets/toolbutton-background-checked@2x.9.png"
- "imagine-assets/toolbutton-background-hovered.9.png"
- "imagine-assets/toolbutton-background-hovered@2x.9.png"
- "imagine-assets/toolbutton-background-pressed.9.png"
- "imagine-assets/toolbutton-background-pressed@2x.9.png"
- "imagine-assets/toolbutton-background.9.png"
- "imagine-assets/toolbutton-background@2x.9.png"
- "imagine-assets/tooltip-background.9.png"
- "imagine-assets/tooltip-background@2x.9.png"
-)
-
-qt6_add_resources(musicplayer "imagine-assets"
- PREFIX
- "/imagine-assets"
- BASE
- "imagine-assets"
- FILES
- ${imagine-assets_resource_files}
-)
-
-set(qmake_immediate_resource_files
- "images/album-cover.jpg"
- "musicplayer.qml"
- "qtquickcontrols2.conf"
-)
-
-qt6_add_resources(musicplayer "qmake_immediate"
- PREFIX
- "/"
- FILES
- ${qmake_immediate_resource_files}
-)
-
-install(TARGETS musicplayer
+install(TARGETS musicplayerexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quickcontrols2/ios/todolist/AppSettings.qml b/examples/quickcontrols2/ios/todolist/AppSettings.qml
new file mode 100644
index 0000000000..c732b9fbc8
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/AppSettings.qml
@@ -0,0 +1,14 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+pragma Singleton
+
+import Qt.labs.settings
+
+Settings {
+ // The properties here are given default values to account for the first run of the application.
+ // After the application has run once, future values will come from the stored settings.
+ property bool showDoneTasks: true
+ property int maxTasks: 30
+ property int fontSize: 18
+}
diff --git a/examples/quickcontrols2/ios/todolist/CMakeLists.txt b/examples/quickcontrols2/ios/todolist/CMakeLists.txt
new file mode 100644
index 0000000000..413ea6ad97
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/CMakeLists.txt
@@ -0,0 +1,84 @@
+cmake_minimum_required(VERSION 3.18)
+project(todolist LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/todolist")
+
+find_package(Qt6 COMPONENTS Gui Qml Quick QuickControls2)
+
+qt_add_executable(todolist
+ src/main.cpp
+)
+
+set_target_properties(todolist PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(todolist PUBLIC
+ Qt${QT_VERSION_MAJOR}::Core
+ Qt${QT_VERSION_MAJOR}::Gui
+ Qt${QT_VERSION_MAJOR}::Qml
+ Qt${QT_VERSION_MAJOR}::Quick
+ Qt${QT_VERSION_MAJOR}::QuickControls2
+)
+
+set_source_files_properties(AppSettings.qml PROPERTIES
+ QT_QML_SINGLETON_TYPE TRUE
+)
+
+set_source_files_properties(Database.qml PROPERTIES
+ QT_QML_SINGLETON_TYPE TRUE
+)
+
+qt_add_qml_module(todolist
+ URI App
+ VERSION 1.0
+ QML_FILES
+ AppSettings.qml
+ Database.qml
+ FontSizePage.qml
+ HomePage.qml
+ MaxTasksPage.qml
+ NavBar.qml
+ ProjectPage.qml
+ SettingsPage.qml
+ ToggleCompletedTasksPage.qml
+ main.qml
+ RESOURCES
+ images/back.png
+ images/back@2x.png
+ images/back@3x.png
+ images/back-white.png
+ images/back-white@2x.png
+ images/back-white@3x.png
+ images/close.png
+ images/close@2x.png
+ images/close@3x.png
+ images/close-white.png
+ images/close-white@2x.png
+ images/close-white@3x.png
+ images/plus-math.png
+ images/plus-math@2x.png
+ images/plus-math@3x.png
+ images/settings.png
+ images/settings@2x.png
+ images/settings@3x.png
+ images/add-new.png
+ images/add-new@2x.png
+ images/add-new@3x.png
+ NO_RESOURCE_TARGET_PATH
+)
+
+set_property(GLOBAL PROPERTY XCODE_EMIT_EFFECTIVE_PLATFORM_NAME ON)
+
+install(TARGETS todolist
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/quickcontrols2/ios/todolist/Database.qml b/examples/quickcontrols2/ios/todolist/Database.qml
new file mode 100644
index 0000000000..31bbd8c1e7
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/Database.qml
@@ -0,0 +1,161 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+pragma Singleton
+
+import QtQml
+import QtQuick.LocalStorage
+
+QtObject {
+ id: root
+
+ property var _db
+
+ function _database() {
+ if (_db)
+ return _db
+
+ try {
+ let db = LocalStorage.openDatabaseSync("ToDoList", "1.0", "ToDoList application database")
+
+ db.transaction(function (tx) {
+ tx.executeSql(`CREATE TABLE IF NOT EXISTS projects (
+ project_id INTEGER PRIMARY KEY AUTOINCREMENT,
+ project_name TEXT NOT NULL CHECK(project_name != ''),
+ project_note TEXT
+ )`);
+ })
+
+ db.transaction(function (tx) {
+ tx.executeSql(`CREATE TABLE IF NOT EXISTS tasks (
+ task_id INTEGER PRIMARY KEY AUTOINCREMENT,
+ task_name TEXT CHECK(task_name != ''),
+ done INTEGER,
+ project_id,
+ FOREIGN KEY(project_id) REFERENCES projects(project_id)
+ )`);
+ })
+
+ _db = db
+ } catch (error) {
+ console.log("Error opening database: " + error)
+ };
+
+ return _db
+ }
+
+ function getProjects() {
+ let projects = []
+ root._database().transaction(function (tx) {
+ let results = tx.executeSql('SELECT * FROM projects')
+ for (let i = 0; i < results.rows.length; i++) {
+ let projectRow = results.rows.item(i)
+ let projectId = projectRow.project_id
+ let completedTasks = Math.max(countDoneTasksByProject(projectId).rows.length, 0)
+ let totalTasks = Math.max(countTaskByProject(projectId).rows.length, 0)
+ projects.push({
+ "projectName": projectRow.project_name,
+ "projectId": projectId,
+ "projectNote": projectRow.project_note ?? "",
+ "completedTasks": completedTasks,
+ "totalTasks": totalTasks
+ })
+ }
+ })
+ return projects
+ }
+
+ function newProject(projectName) {
+ let results
+ root._database().transaction(function (tx) {
+ results = tx.executeSql("INSERT INTO projects (project_name) VALUES(?)", [projectName])
+ })
+ return results
+ }
+
+ function updateProjectNote(projectId, projectNote) {
+ root._database().transaction(function (tx) {
+ tx.executeSql("UPDATE projects set project_note=? WHERE project_id=?", [projectNote, projectId])
+ })
+ }
+
+ function updateProjectName(projectId, projectName) {
+ root._database().transaction(function (tx) {
+ tx.executeSql("UPDATE projects set project_name=? WHERE project_id=?", [projectName, projectId])
+ })
+ }
+
+ function deleteProject(projectId) {
+ root._database().transaction(function (tx) {
+ deleteAllTasks(projectId)
+ tx.executeSql("DELETE FROM projects WHERE project_id = ?", [projectId])
+ })
+ }
+
+ function getTaskByProject(projectId) {
+ if (!projectId)
+ return
+
+ let tasks = []
+ root._database().transaction(function (tx) {
+ let results = tx.executeSql("SELECT * FROM tasks WHERE project_id = " + [projectId] + " ORDER BY done")
+ for (let i = 0; i < results.rows.length; i++) {
+ let row = results.rows.item(i)
+ tasks.push({
+ "taskId": row.task_id,
+ "taskName": row.task_name,
+ "done": row.done === 1 ? true : false
+ })
+ }
+ })
+ return tasks
+ }
+
+ function countTaskByProject(projectId) {
+ let results
+ root._database().transaction(function (tx) {
+ results = tx.executeSql('SELECT task_id FROM tasks WHERE project_id =' + [projectId])
+ })
+ return results
+ }
+
+ function countDoneTasksByProject(projectId) {
+ let results
+ root._database().transaction(function (tx) {
+ results = tx.executeSql("SELECT task_id FROM tasks WHERE project_id =" + [projectId] + " AND done = 1")
+ })
+ return results
+ }
+
+ function newTask(projectId, taskName) {
+ let results
+ root._database().transaction(function (tx) {
+ results = tx.executeSql("INSERT INTO tasks (task_name, done, project_id) VALUES(?, 0, ?)", [taskName, projectId])
+ })
+ return results
+ }
+
+ function updateTaskName(taskId, taskName) {
+ root._database().transaction(function (tx) {
+ tx.executeSql("UPDATE tasks set task_name=? WHERE task_id=?", [taskName, taskId])
+ })
+ }
+
+ function updateDoneState(taskId, doneState) {
+ root._database().transaction(function (tx) {
+ tx.executeSql("UPDATE tasks set done=? WHERE task_id=?", [doneState, taskId])
+ })
+ }
+
+ function deleteAllTasks(projectId) {
+ root._database().transaction(function (tx) {
+ tx.executeSql("DELETE FROM tasks WHERE project_id =" + projectId)
+ })
+ }
+
+ function deleteTask(taskId) {
+ root._database().transaction(function (tx) {
+ tx.executeSql("DELETE FROM tasks WHERE task_id = ?", [taskId])
+ })
+ }
+}
diff --git a/examples/quickcontrols2/ios/todolist/FontSizePage.qml b/examples/quickcontrols2/ios/todolist/FontSizePage.qml
new file mode 100644
index 0000000000..2b0e5b16db
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/FontSizePage.qml
@@ -0,0 +1,44 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+Page {
+ Frame {
+ width: parent.width - 60
+ anchors.centerIn: parent
+ topPadding: 12
+ bottomPadding: 12
+
+ RowLayout {
+ anchors.fill: parent
+ spacing: 12
+
+ Label {
+ text: qsTr("A")
+ font.pointSize: 15
+ font.weight: 400
+ }
+
+ Slider {
+ snapMode: Slider.SnapAlways
+ stepSize: 1
+ from: 15
+ value: AppSettings.fontSize
+ to: 21
+
+ Layout.fillWidth: true
+
+ onMoved: AppSettings.fontSize = value
+ }
+
+ Label {
+ text: qsTr("A")
+ font.pointSize: 21
+ font.weight: 400
+ }
+ }
+ }
+}
diff --git a/examples/quickcontrols2/ios/todolist/HomePage.qml b/examples/quickcontrols2/ios/todolist/HomePage.qml
new file mode 100644
index 0000000000..3d1b29d1d7
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/HomePage.qml
@@ -0,0 +1,173 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtQuick.LocalStorage
+import QtQuick.Controls.iOS
+
+Page {
+ id: root
+
+ header: Label {
+ text: qsTr("Projects")
+ font.pointSize: AppSettings.fontSize + 20
+ font.styleName: "Semibold"
+ leftPadding: 30
+ topPadding: 20
+ bottomPadding: 20
+ }
+
+ ListView {
+ id: projectListView
+ anchors.fill: parent
+ clip: true
+
+ model: ListModel {
+ id: projectsModel
+
+ Component.onCompleted: {
+ let projects = Database.getProjects()
+ for (let project of projects)
+ append(project)
+ }
+ }
+
+ delegate: SwipeDelegate {
+ id: projectDelegate
+ width: ListView.view.width
+ height: projectContent.implicitHeight
+
+ required property int index
+ required property int projectId
+ required property string projectName
+ required property int completedTasks
+ required property int totalTasks
+
+ swipe.right: Rectangle {
+ width: 50
+ height: parent.height
+ color: "red"
+ anchors.right: parent.right
+
+ SwipeDelegate.onClicked: {
+ Database.deleteProject(projectDelegate.projectId)
+ projectsModel.remove(projectDelegate.index, 1)
+ }
+
+ Image {
+ source: IOS.theme === IOS.Dark ? "images/close-white.png"
+ : "images/close.png"
+ width: 20
+ height: 20
+ anchors.centerIn: parent
+ }
+ }
+
+ Column {
+ id: projectContent
+ topPadding: 8
+ bottomPadding: 10
+ leftPadding: 30
+
+ Label {
+ text: completedTasks + " / " + totalTasks
+ font.pointSize: AppSettings.fontSize
+ }
+
+ Label {
+ id: project
+ text: projectName
+ font.pointSize: AppSettings.fontSize
+ font.styleName: "Semibold"
+ }
+ }
+
+ Connections {
+ target: projectDelegate
+ function onClicked() {
+ let project = projectsModel.get(index)
+ root.StackView.view.push("ProjectPage.qml", {
+ "projectsModel": projectsModel,
+ "projectId": project.projectId,
+ "projectName": project.projectName,
+ "projectIndex": index,
+ "projectNote": project.projectNote,
+ "completedTasks": project.completedTasks,
+ "totalTasks": project.totalTasks
+ })
+ }
+ }
+ }
+ }
+
+ Popup {
+ id: newProjectPopup
+ anchors.centerIn: parent
+ height: 200
+ modal: true
+
+ ColumnLayout {
+ anchors.fill: parent
+
+ Label {
+ text: qsTr("Project Name")
+ font.pointSize: AppSettings.fontSize + 2.0
+ font.bold: true
+
+ Layout.alignment: Qt.AlignHCenter
+ }
+
+ TextField {
+ id: newProjectTextField
+ placeholderText: qsTr("Enter project name")
+ font.pointSize: AppSettings.fontSize
+
+ Layout.fillWidth: true
+ Layout.leftMargin: 10
+ Layout.rightMargin: 10
+
+ Keys.onReturnPressed: {
+ if (createProjectButton.enabled)
+ createProjectButton.clicked()
+ }
+ }
+
+ Button {
+ id: createProjectButton
+ text: qsTr("Create project")
+ flat: true
+ font.pointSize: AppSettings.fontSize
+ enabled: newProjectTextField.length > 0
+
+ Layout.alignment: Qt.AlignHCenter
+
+ onClicked: {
+ let results = Database.newProject(newProjectTextField.text)
+ projectsModel.append({
+ projectId: parseInt(results.insertId),
+ projectName: newProjectTextField.text,
+ totalTasks: 0,
+ completedTasks: 0,
+ projectNote: ""
+ })
+ newProjectTextField.text = ""
+ newProjectPopup.close()
+ }
+ }
+ }
+ }
+
+ footer: ToolBar {
+ ToolButton {
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ text: qsTr("New project")
+ font.pointSize: AppSettings.fontSize - 2
+ icon.source: "images/add-new.png"
+
+ onClicked: newProjectPopup.open()
+ }
+ }
+}
diff --git a/examples/quickcontrols2/ios/todolist/MaxTasksPage.qml b/examples/quickcontrols2/ios/todolist/MaxTasksPage.qml
new file mode 100644
index 0000000000..509a460357
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/MaxTasksPage.qml
@@ -0,0 +1,36 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+Page {
+ ColumnLayout {
+ width: parent.width
+ anchors.verticalCenter: parent.verticalCenter
+
+ Label {
+ id: maxTasksText
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: Text.Wrap
+ text: qsTr("Choose the maximum amount of tasks each project can have.")
+ font.pointSize: AppSettings.fontSize
+
+ Layout.fillWidth: true
+ }
+
+ SpinBox {
+ id: maxTasksSpinbox
+ editable: true
+ from: 5
+ value: AppSettings.maxTasks
+ to: 30
+
+ Layout.alignment: Qt.AlignHCenter
+ Layout.topMargin: 10
+
+ onValueModified: AppSettings.maxTasks = maxTasksSpinbox.value
+ }
+ }
+}
diff --git a/examples/quickcontrols2/ios/todolist/NavBar.qml b/examples/quickcontrols2/ios/todolist/NavBar.qml
new file mode 100644
index 0000000000..4f57353dca
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/NavBar.qml
@@ -0,0 +1,44 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+
+ToolBar {
+ id: root
+ width: parent.width
+
+ required property StackView stackView
+
+ ToolButton {
+ enabled: root.stackView.depth >= 2
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ visible: root.stackView.depth >= 2
+ anchors.verticalCenter: parent.verticalCenter
+ display: AbstractButton.TextBesideIcon
+ text: root.stackView.depth > 2 ? qsTr("Back") : qsTr("Home")
+ font.pointSize: AppSettings.fontSize
+ icon.source: "images/back.png"
+ icon.height: 20
+ icon.width: 20
+
+ onClicked: root.stackView.pop()
+ }
+
+ ToolButton {
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ icon.source: "images/settings.png"
+ icon.height: 20
+ icon.width: 20
+ visible: {
+ // Force the binding to re-evaluate so that the title check is run each time the page changes.
+ root.stackView.currentItem
+ !root.stackView.find((item, index) => { return item.title === "settingsPage" })
+ }
+
+ onClicked: root.stackView.push("SettingsPage.qml")
+ }
+}
+
diff --git a/examples/quickcontrols2/ios/todolist/ProjectPage.qml b/examples/quickcontrols2/ios/todolist/ProjectPage.qml
new file mode 100644
index 0000000000..fd33e73980
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/ProjectPage.qml
@@ -0,0 +1,256 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtQuick.Controls.iOS
+
+Page {
+ id: root
+
+ required property int projectIndex
+ required property int projectId
+ required property string projectName
+ required property string projectNote
+
+ required property int completedTasks
+ required property int totalTasks
+
+ required property ListModel projectsModel
+
+ header: ColumnLayout {
+ id: titleRow
+ spacing: 4
+
+ TextField {
+ id: projectNameLabel
+ Layout.fillWidth: true
+ text: root.projectName
+ font.pointSize: AppSettings.fontSize + 10
+ font.styleName: "Bold"
+ padding: 0
+ background: null
+ wrapMode: TextField.Wrap
+
+ Layout.topMargin: 10
+ Layout.leftMargin: 20
+ Layout.rightMargin: 20
+
+ onEditingFinished: {
+ Database.updateProjectName(root.projectId, text)
+ projectsModel.setProperty(projectIndex, "projectName", projectNameLabel.text)
+ }
+ }
+
+ Label {
+ text: root.completedTasks + " / " + root.totalTasks
+ Layout.leftMargin: 20
+ }
+
+ ProgressBar {
+ id: progressBar
+ from: 0
+ value: root.completedTasks
+ to: root.totalTasks
+ Layout.leftMargin: 20
+ }
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+
+ TextArea {
+ id: textArea
+ leftPadding: 15
+ rightPadding: doneButton.width
+ bottomPadding: 10
+ topPadding: 10
+ font.pointSize: AppSettings.fontSize
+ placeholderText: qsTr("Write a note...")
+ text: root.projectNote
+ wrapMode: TextArea.Wrap
+ clip: true
+
+ Layout.fillWidth: true
+ Layout.preferredHeight: 80
+ Layout.topMargin: 20
+
+ onEditingFinished: {
+ Database.updateProjectNote(root.projectId, text)
+ projectsModel.setProperty(projectIndex, "projectNote", textArea.text)
+ }
+
+ Button {
+ id: doneButton
+ text: qsTr("Done")
+ flat: true
+ visible: textArea.focus
+ onClicked: textArea.editingFinished()
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ }
+ }
+
+ ListView {
+ id: taskListView
+ model: taskModel
+ clip: true
+
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.topMargin: 20
+
+ ListModel {
+ id: taskModel
+
+ Component.onCompleted: {
+ let tasks = Database.getTaskByProject(projectId)
+ for (let task of tasks)
+ append(task)
+ }
+ }
+
+ delegate: CheckDelegate {
+ id: taskList
+ width: taskListView.width
+ height: visible ? 40 : 0
+ checked: done
+ visible: !done || (done && AppSettings.showDoneTasks)
+
+ required property bool done
+ required property int taskId
+ required property string taskName
+ required property int index
+
+ onClicked: {
+ Database.updateDoneState(taskId, checked ? 1 : 0)
+ taskModel.setProperty(index, "done", checked)
+ root.completedTasks = Math.max(Database.countDoneTasksByProject(root.projectId).rows.length, 0)
+ root.totalTasks = Math.max(Database.countTaskByProject(root.projectId).rows.length, 0)
+ root.projectsModel.setProperty(projectIndex, "completedTasks", root.completedTasks)
+ }
+
+ TextField {
+ id: taskNameLabel
+ text: taskList.taskName
+ anchors.left: deleteTaskButton.right
+ anchors.leftMargin: 10
+ padding: 0
+ font.pointSize: AppSettings.fontSize
+ anchors.verticalCenter: parent.verticalCenter
+ background: null
+
+ onEditingFinished: {
+ Database.updateTaskName(taskList.taskId, taskNameLabel.text)
+ taskModel.setProperty(index, "taskName", taskNameLabel.text)
+ }
+ }
+
+ Button {
+ id: deleteTaskButton
+ anchors.left: parent.left
+ width: 15
+ height: 15
+ flat: true
+ topPadding: 0
+ bottomPadding: 0
+ rightPadding: 0
+ leftPadding: 0
+ anchors.leftMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ icon.source: "images/close.png"
+ icon.color: IOS.theme === IOS.Dark ? "white" : "black"
+
+ onClicked: {
+ Database.deleteTask(taskList.taskId)
+ taskModel.remove(index, 1)
+ root.totalTasks--
+ if (taskList.done)
+ root.completedTasks--
+ }
+ }
+ }
+ }
+
+ Popup {
+ id: addTaskPopup
+ parent: root
+ anchors.centerIn: parent
+ height: 200
+ modal: true
+ focus: true
+
+ ColumnLayout {
+ anchors.fill: parent
+
+ Label {
+ text: qsTr("Add New Task")
+ font.pointSize: AppSettings.fontSize + 2.0
+ font.bold: true
+
+ Layout.alignment: Qt.AlignHCenter
+ }
+
+ TextField {
+ id: newTaskNameTextField
+ placeholderText: qsTr("Enter task name")
+ font.pointSize: AppSettings.fontSize
+
+ Keys.onReturnPressed: {
+ if (addTaskButton.enabled)
+ addTaskButton.clicked()
+ }
+
+ Layout.fillWidth: true
+ Layout.leftMargin: 10
+ Layout.rightMargin: 10
+ Layout.alignment: Qt.AlignHCenter
+ }
+
+ Button {
+ id: addTaskButton
+ text: qsTr("Add task")
+ flat: true
+ font.pointSize: AppSettings.fontSize
+ enabled: newTaskNameTextField.length > 0
+
+ Layout.alignment: Qt.AlignHCenter
+
+ onClicked: {
+ const result = Database.newTask(root.projectId, newTaskNameTextField.text)
+ taskModel.append({
+ "taskId": parseInt(result.insertId),
+ "taskName": newTaskNameTextField.text, "done": false
+ })
+ root.projectsModel.setProperty(projectIndex, "totalTasks", taskListView.count)
+ newTaskNameTextField.text = ""
+ root.totalTasks++
+ addTaskPopup.close()
+ }
+ }
+ }
+ }
+
+ Label {
+ text: qsTr("Task limit reached.")
+ Layout.alignment: Qt.AlignHCenter
+ Layout.bottomMargin: 20
+ font.pointSize: AppSettings.fontSize
+ visible: taskListView.count >= AppSettings.maxTasks
+ }
+ }
+
+ footer: ToolBar {
+ ToolButton {
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ text: qsTr("New task")
+ font.pointSize: AppSettings.fontSize - 2
+ icon.source: "images/add-new.png"
+ enabled: taskListView.count < AppSettings.maxTasks
+
+ onClicked: addTaskPopup.open()
+ }
+ }
+}
diff --git a/examples/quickcontrols2/ios/todolist/SettingsPage.qml b/examples/quickcontrols2/ios/todolist/SettingsPage.qml
new file mode 100644
index 0000000000..85e8ed2125
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/SettingsPage.qml
@@ -0,0 +1,68 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Controls.iOS
+
+Page {
+ title: "settingsPage"
+
+ property bool showDoneTasks: true
+
+ header: Label {
+ text: qsTr("Settings")
+ font.pointSize: AppSettings.fontSize + 20
+ font.styleName: "Semibold"
+ leftPadding: 20
+ topPadding: 20
+ }
+
+ ListView {
+ anchors.fill: parent
+ topMargin: 20
+ model: listModel
+ clip: true
+
+ ListModel {
+ id: listModel
+ ListElement {
+ setting: qsTr("Font size")
+ page: "FontSize"
+ }
+
+ ListElement {
+ setting: qsTr("Maximum number of tasks per project")
+ page: "MaxTasks"
+ }
+
+ ListElement {
+ setting: qsTr("Show completed tasks")
+ page: "ToggleCompletedTasks"
+ }
+ }
+
+ delegate: ItemDelegate {
+ width: parent.width
+ text: setting
+ font.pointSize: AppSettings.fontSize
+
+ onClicked: stackView.push(page + "Page.qml")
+
+ required property string setting
+ required property string page
+
+ Image {
+ source: IOS.theme === IOS.Dark ? "images/back-white.png"
+ : "images/back.png"
+ width: 20
+ height: 20
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ fillMode: Image.PreserveAspectFit
+ anchors.verticalCenter: parent.verticalCenter
+ mirror: true
+ }
+ }
+ }
+}
diff --git a/examples/quickcontrols2/ios/todolist/ToggleCompletedTasksPage.qml b/examples/quickcontrols2/ios/todolist/ToggleCompletedTasksPage.qml
new file mode 100644
index 0000000000..df2145866a
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/ToggleCompletedTasksPage.qml
@@ -0,0 +1,34 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+Page {
+ ColumnLayout {
+ width: parent.width
+ anchors.verticalCenter: parent.verticalCenter
+
+ Label {
+ id: toggleText
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: Text.Wrap
+ text: toggleTasksSwitch.checked ? qsTr("Completed tasks will be shown.")
+ : qsTr("Completed tasks will be hidden.")
+ font.pointSize: AppSettings.fontSize
+
+ Layout.fillWidth: true
+ }
+
+ Switch {
+ id: toggleTasksSwitch
+ checked: AppSettings.showDoneTasks
+
+ Layout.alignment: Qt.AlignHCenter
+ Layout.topMargin: 10
+
+ onClicked: AppSettings.showDoneTasks = checked
+ }
+ }
+}
diff --git a/examples/quickcontrols2/ios/todolist/doc/images/qtquickcontrols2-todolist.png b/examples/quickcontrols2/ios/todolist/doc/images/qtquickcontrols2-todolist.png
new file mode 100644
index 0000000000..5be7190a43
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/doc/images/qtquickcontrols2-todolist.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/doc/src/qtquickcontrols2-todolist.qdoc b/examples/quickcontrols2/ios/todolist/doc/src/qtquickcontrols2-todolist.qdoc
new file mode 100644
index 0000000000..12e2d4fca5
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/doc/src/qtquickcontrols2-todolist.qdoc
@@ -0,0 +1,22 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example ios/todolist
+ \keyword Qt Quick Controls - To Do List
+ \title Qt Quick Controls - To Do List
+ \keyword Qt Quick Controls 2 - To Do List
+ \ingroup qtquickcontrols2-examples
+ \brief To do list application for iOS.
+
+ This example demonstrates how to create a simple to do list application for
+ iOS using the \l {iOS Style}.
+
+ \image qtquickcontrols2-todolist.png
+
+ The example also shows how an in-memory SQL database can be created and
+ used purely through QML, without needing C++, through the use of
+ \l {Qt Quick Local Storage QML Types}{LocalStorage}.
+
+ \include examples-run.qdocinc
+*/
diff --git a/examples/quickcontrols2/ios/todolist/images/add-new.png b/examples/quickcontrols2/ios/todolist/images/add-new.png
new file mode 100644
index 0000000000..2e60e48a2d
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/add-new.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/add-new@2x.png b/examples/quickcontrols2/ios/todolist/images/add-new@2x.png
new file mode 100644
index 0000000000..edb8b62847
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/add-new@2x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/add-new@3x.png b/examples/quickcontrols2/ios/todolist/images/add-new@3x.png
new file mode 100644
index 0000000000..b5b9b6a5d6
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/add-new@3x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/back-white.png b/examples/quickcontrols2/ios/todolist/images/back-white.png
new file mode 100644
index 0000000000..503bdf4d48
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/back-white.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/back-white@2x.png b/examples/quickcontrols2/ios/todolist/images/back-white@2x.png
new file mode 100644
index 0000000000..e201ec6d5b
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/back-white@2x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/back-white@3x.png b/examples/quickcontrols2/ios/todolist/images/back-white@3x.png
new file mode 100644
index 0000000000..eb8b7ffc68
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/back-white@3x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/back.png b/examples/quickcontrols2/ios/todolist/images/back.png
new file mode 100644
index 0000000000..94580efd7f
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/back.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/back@2x.png b/examples/quickcontrols2/ios/todolist/images/back@2x.png
new file mode 100644
index 0000000000..b5cf424e91
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/back@2x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/back@3x.png b/examples/quickcontrols2/ios/todolist/images/back@3x.png
new file mode 100644
index 0000000000..50d5102f4e
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/back@3x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/close-white.png b/examples/quickcontrols2/ios/todolist/images/close-white.png
new file mode 100644
index 0000000000..72163067a6
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/close-white.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/close-white@2x.png b/examples/quickcontrols2/ios/todolist/images/close-white@2x.png
new file mode 100644
index 0000000000..54828e84d1
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/close-white@2x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/close-white@3x.png b/examples/quickcontrols2/ios/todolist/images/close-white@3x.png
new file mode 100644
index 0000000000..dd67cf1b69
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/close-white@3x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/close.png b/examples/quickcontrols2/ios/todolist/images/close.png
new file mode 100644
index 0000000000..eba32b637d
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/close.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/close@2x.png b/examples/quickcontrols2/ios/todolist/images/close@2x.png
new file mode 100644
index 0000000000..72cf76317a
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/close@2x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/close@3x.png b/examples/quickcontrols2/ios/todolist/images/close@3x.png
new file mode 100644
index 0000000000..6cb2ea58d9
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/close@3x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/plus-math.png b/examples/quickcontrols2/ios/todolist/images/plus-math.png
new file mode 100644
index 0000000000..b0d182d23e
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/plus-math.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/plus-math@2x.png b/examples/quickcontrols2/ios/todolist/images/plus-math@2x.png
new file mode 100644
index 0000000000..112a132084
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/plus-math@2x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/plus-math@3x.png b/examples/quickcontrols2/ios/todolist/images/plus-math@3x.png
new file mode 100644
index 0000000000..ca513d200b
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/plus-math@3x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/settings.png b/examples/quickcontrols2/ios/todolist/images/settings.png
new file mode 100644
index 0000000000..600981fb35
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/settings.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/settings@2x.png b/examples/quickcontrols2/ios/todolist/images/settings@2x.png
new file mode 100644
index 0000000000..80541aa028
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/settings@2x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/images/settings@3x.png b/examples/quickcontrols2/ios/todolist/images/settings@3x.png
new file mode 100644
index 0000000000..48c2b2a8c0
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/images/settings@3x.png
Binary files differ
diff --git a/examples/quickcontrols2/ios/todolist/main.qml b/examples/quickcontrols2/ios/todolist/main.qml
new file mode 100644
index 0000000000..a0067643f1
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/main.qml
@@ -0,0 +1,32 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Window
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 390
+ height: 844
+ visible: true
+ title: "To Do List"
+
+ header: NavBar {
+ stackView: stackView
+ }
+
+ Flickable {
+ width: parent.width
+ height: parent.height
+ flickableDirection: Flickable.VerticalFlick
+ boundsBehavior: Flickable.StopAtBounds
+
+ ScrollIndicator.vertical: ScrollIndicator {}
+
+ StackView {
+ id: stackView
+ anchors.fill: parent
+ initialItem: HomePage {}
+ }
+ }
+}
diff --git a/examples/quickcontrols2/ios/todolist/qmldir b/examples/quickcontrols2/ios/todolist/qmldir
new file mode 100644
index 0000000000..e0c443110e
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/qmldir
@@ -0,0 +1,2 @@
+singleton Database 1.0 Database.qml
+singleton AppSettings 1.0 AppSettings.qml
diff --git a/examples/quickcontrols2/ios/todolist/src/main.cpp b/examples/quickcontrols2/ios/todolist/src/main.cpp
new file mode 100644
index 0000000000..1db4f7ae37
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/src/main.cpp
@@ -0,0 +1,32 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQuickControls2/qquickstyle.h>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQuickStyle::setStyle("iOS");
+
+ QQmlApplicationEngine engine;
+ const QUrl url(u"qrc:/main.qml"_qs);
+ QObject::connect(
+ &engine, &QQmlApplicationEngine::objectCreated, &app,
+ [url](QObject *obj, const QUrl &objUrl) {
+ if (!obj && url == objUrl)
+ QCoreApplication::exit(-1);
+ },
+ Qt::QueuedConnection);
+
+ engine.addImportPath(":/");
+
+ engine.load(url);
+ if (engine.rootObjects().isEmpty())
+ return -1;
+
+ return app.exec();
+}
diff --git a/examples/quickcontrols2/ios/todolist/todolist.pro b/examples/quickcontrols2/ios/todolist/todolist.pro
new file mode 100644
index 0000000000..d77d718a62
--- /dev/null
+++ b/examples/quickcontrols2/ios/todolist/todolist.pro
@@ -0,0 +1,42 @@
+TEMPLATE = app
+TARGET = todolist
+QT += quick quickcontrols2
+
+SOURCES += src/main.cpp
+
+RESOURCES += \
+ images/back.png \
+ images/back@2x.png \
+ images/back@3x.png \
+ images/back-white.png \
+ images/back-white@2x.png \
+ images/back-white@3x.png \
+ images/close.png \
+ images/close@2x.png \
+ images/close@3x.png \
+ images/close-white.png \
+ images/close-white@2x.png \
+ images/close-white@3x.png \
+ images/plus-math.png \
+ images/plus-math@2x.png \
+ images/plus-math@3x.png \
+ images/settings.png \
+ images/settings@2x.png \
+ images/settings@3x.png \
+ images/add-new.png \
+ images/add-new@2x.png \
+ images/add-new@3x.png \
+ main.qml \
+ AppSettings.qml \
+ Database.qml \
+ FontSizePage.qml \
+ HomePage.qml \
+ MaxTasksPage.qml \
+ NavBar.qml \
+ ProjectPage.qml \
+ SettingsPage.qml \
+ ToggleCompletedTasksPage.qml \
+ qmldir
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/ios/todolist
+INSTALLS += target
diff --git a/examples/quickcontrols2/sidepanel/CMakeLists.txt b/examples/quickcontrols2/sidepanel/CMakeLists.txt
index 0e94bca5fb..e61bc46538 100644
--- a/examples/quickcontrols2/sidepanel/CMakeLists.txt
+++ b/examples/quickcontrols2/sidepanel/CMakeLists.txt
@@ -11,41 +11,33 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/sidepanel")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick)
-qt_add_executable(sidepanel
+qt_add_executable(sidepanelexample WIN32 MACOSX_BUNDLE
sidepanel.cpp
)
-set_target_properties(sidepanel PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
+qt_add_qml_module(sidepanelexample
+ URI sidepanel
+ VERSION 1.0
+ NO_RESOURCE_TARGET_PATH
+ QML_FILES
+ "sidepanel.qml"
+ RESOURCES
+ "images/qt-logo.png"
+ "images/qt-logo@2x.png"
+ "images/qt-logo@3x.png"
+ "images/qt-logo@4x.png"
+ "qtquickcontrols2.conf"
+ "doc/images/qtquickcontrols2-sidepanel-landscape.png"
+ "doc/images/qtquickcontrols2-sidepanel-portrait.png"
)
-target_link_libraries(sidepanel PUBLIC
+target_link_libraries(sidepanelexample PUBLIC
Qt::Core
Qt::Gui
Qt::Quick
)
-# Resources:
-set(qmake_immediate_resource_files
- "doc/images/qtquickcontrols2-sidepanel-landscape.png"
- "doc/images/qtquickcontrols2-sidepanel-portrait.png"
- "images/qt-logo.png"
- "images/qt-logo@2x.png"
- "images/qt-logo@3x.png"
- "images/qt-logo@4x.png"
- "qtquickcontrols2.conf"
- "sidepanel.qml"
-)
-
-qt6_add_resources(sidepanel "qmake_immediate"
- PREFIX
- "/"
- FILES
- ${qmake_immediate_resource_files}
-)
-
-install(TARGETS sidepanel
+install(TARGETS sidepanelexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quickcontrols2/swipetoremove/CMakeLists.txt b/examples/quickcontrols2/swipetoremove/CMakeLists.txt
index 66862b9171..8b3c1578c9 100644
--- a/examples/quickcontrols2/swipetoremove/CMakeLists.txt
+++ b/examples/quickcontrols2/swipetoremove/CMakeLists.txt
@@ -4,42 +4,34 @@ project(swipetoremove LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/swipetoremove")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml)
-qt_add_executable(swipetoremove
+qt_add_executable(swipetoremoveexample WIN32 MACOSX_BUNDLE
swipetoremove.cpp
)
-
-set_target_properties(swipetoremove PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(swipetoremove PUBLIC
+target_link_libraries(swipetoremoveexample PUBLIC
Qt::Core
Qt::Gui
Qt::Qml
)
# Resources:
-set(qmake_immediate_resource_files
- "fonts/fontello.ttf"
- "swipetoremove.qml"
-)
-
-qt6_add_resources(swipetoremove "qmake_immediate"
- PREFIX
- "/"
- FILES
- ${qmake_immediate_resource_files}
+qt_add_qml_module(swipetoremoveexample
+ URI swipetoremove
+ VERSION 1.0
+ NO_RESOURCE_TARGET_PATH
+ QML_FILES
+ "swipetoremove.qml"
+ RESOURCES
+ "fonts/fontello.ttf"
)
-install(TARGETS swipetoremove
+install(TARGETS swipetoremoveexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quickcontrols2/swipetoremove/swipetoremove.pro b/examples/quickcontrols2/swipetoremove/swipetoremove.pro
index 8e6bd5f663..bcdb45cd45 100644
--- a/examples/quickcontrols2/swipetoremove/swipetoremove.pro
+++ b/examples/quickcontrols2/swipetoremove/swipetoremove.pro
@@ -2,12 +2,9 @@ TEMPLATE = app
TARGET = swipetoremove
QT += qml
-SOURCES += \
- swipetoremove.cpp
+SOURCES += swipetoremove.cpp
-RESOURCES += \
- swipetoremove.qml \
- fonts/fontello.ttf
+RESOURCES += swipetoremove.qml
target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/swipetoremove
INSTALLS += target
diff --git a/examples/quickcontrols2/texteditor/CMakeLists.txt b/examples/quickcontrols2/texteditor/CMakeLists.txt
index 52851f1b9b..82bf3c31cf 100644
--- a/examples/quickcontrols2/texteditor/CMakeLists.txt
+++ b/examples/quickcontrols2/texteditor/CMakeLists.txt
@@ -11,49 +11,45 @@ set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/texteditor")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick QuickControls2 OPTIONAL_COMPONENTS Widgets)
-qt_add_executable(texteditor WIN32 MACOSX_BUNDLE
+qt_add_executable(texteditorexample WIN32 MACOSX_BUNDLE
documenthandler.cpp
texteditor.cpp
)
-target_link_libraries(texteditor PUBLIC
+qt_add_qml_module(texteditorexample
+ URI texteditor
+ VERSION 1.0
+ NO_RESOURCE_TARGET_PATH
+ QML_FILES
+ "qml/+touch/texteditor.qml"
+ "qml/texteditor.qml"
+ RESOURCES
+ "texteditor.html"
+ "+touch/texteditor.html"
+ "fonts/fontello.ttf"
+ "images/qt-logo.png"
+)
+
+target_link_libraries(texteditorexample PUBLIC
Qt::Core
Qt::Gui
Qt::Quick
Qt::QuickControls2
)
-# Resources:
-set(texteditor_resource_files
- "+touch/texteditor.html"
- "fonts/fontello.ttf"
- "images/qt-logo.png"
- "qml/+touch/texteditor.qml"
- "qml/texteditor.qml"
- "qtquickcontrols2.conf"
- "texteditor.html"
-)
-
-qt6_add_resources(texteditor "texteditor"
- PREFIX
- "/"
- FILES
- ${texteditor_resource_files}
-)
-
if(TARGET Qt::Widgets)
- target_link_libraries(texteditor PUBLIC
+ target_link_libraries(texteditorexample PUBLIC
Qt::Widgets
)
endif()
if(CMAKE_CROSSCOMPILING)
- target_compile_definitions(texteditor PUBLIC
+ target_compile_definitions(texteditorexample PUBLIC
QT_EXTRA_FILE_SELECTOR="touch"
)
endif()
-install(TARGETS texteditor
+install(TARGETS texteditorexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quickcontrols2/texteditor/documenthandler.cpp b/examples/quickcontrols2/texteditor/documenthandler.cpp
index a3a26f1ad4..9571aa03ba 100644
--- a/examples/quickcontrols2/texteditor/documenthandler.cpp
+++ b/examples/quickcontrols2/texteditor/documenthandler.cpp
@@ -276,4 +276,73 @@ void DocumentHandler::setFont(const QFont & font){
emit fontChanged();
}
+bool DocumentHandler::bold() const
+{
+ const QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return m_document->textDocument()->defaultFont().bold();
+ return cursor.charFormat().font().bold();
+}
+
+void DocumentHandler::setBold(bool bold)
+{
+ const QTextCursor cursor = textCursor();
+ if (!cursor.isNull() && cursor.charFormat().font().bold() == bold)
+ return;
+
+ QFont font = cursor.charFormat().font();
+ font.setBold(bold);
+ QTextCharFormat format;
+ format.setFont(font);
+ mergeFormatOnWordOrSelection(format);
+
+ emit boldChanged();
+}
+
+bool DocumentHandler::underline() const
+{
+ const QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return m_document->textDocument()->defaultFont().underline();
+ return cursor.charFormat().font().underline();
+}
+
+void DocumentHandler::setUnderline(bool underline)
+{
+ const QTextCursor cursor = textCursor();
+ if (!cursor.isNull() && cursor.charFormat().font().underline() == underline)
+ return;
+
+ QFont font = cursor.charFormat().font();
+ font.setUnderline(underline);
+ QTextCharFormat format;
+ format.setFont(font);
+ mergeFormatOnWordOrSelection(format);
+
+ emit underlineChanged();
+}
+
+bool DocumentHandler::italic() const
+{
+ const QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return m_document->textDocument()->defaultFont().italic();
+ return cursor.charFormat().font().italic();
+}
+
+void DocumentHandler::setItalic(bool italic)
+{
+ const QTextCursor cursor = textCursor();
+ if (!cursor.isNull() && cursor.charFormat().font().italic() == italic)
+ return;
+
+ QFont font = cursor.charFormat().font();
+ font.setItalic(italic);
+ QTextCharFormat format;
+ format.setFont(font);
+ mergeFormatOnWordOrSelection(format);
+
+ emit italicChanged();
+}
+
#include "moc_documenthandler.cpp"
diff --git a/examples/quickcontrols2/texteditor/documenthandler.h b/examples/quickcontrols2/texteditor/documenthandler.h
index c993748a5f..b750997885 100644
--- a/examples/quickcontrols2/texteditor/documenthandler.h
+++ b/examples/quickcontrols2/texteditor/documenthandler.h
@@ -28,6 +28,10 @@ class DocumentHandler : public QObject
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
+ Q_PROPERTY(bool bold READ bold WRITE setBold NOTIFY boldChanged)
+ Q_PROPERTY(bool underline READ underline WRITE setUnderline NOTIFY underlineChanged)
+ Q_PROPERTY(bool italic READ italic WRITE setItalic NOTIFY italicChanged)
+
Q_PROPERTY(QString fileName READ fileName NOTIFY fileUrlChanged)
Q_PROPERTY(QString fileType READ fileType NOTIFY fileUrlChanged)
Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY fileUrlChanged)
@@ -58,6 +62,15 @@ public:
QFont font() const;
void setFont(const QFont & font);
+ bool bold() const;
+ void setBold(bool bold);
+
+ bool underline() const;
+ void setUnderline(bool underline);
+
+ bool italic() const;
+ void setItalic(bool italic);
+
QString fileName() const;
QString fileType() const;
QUrl fileUrl() const;
@@ -76,6 +89,9 @@ Q_SIGNALS:
void selectionEndChanged();
void fontChanged();
+ void boldChanged();
+ void underlineChanged();
+ void italicChanged();
void textColorChanged();
void alignmentChanged();
diff --git a/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml b/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml
index debc5bfa30..2a0d9f117f 100644
--- a/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml
+++ b/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml
@@ -102,9 +102,6 @@ ApplicationWindow {
footer: ToolBar {
visible: !textArea.readOnly && textArea.activeFocus
- Material.primary: "#E0E0E0"
- Material.elevation: 0
-
Flickable {
anchors.fill: parent
contentWidth: toolRow.implicitWidth
diff --git a/examples/quickcontrols2/texteditor/qml/texteditor.qml b/examples/quickcontrols2/texteditor/qml/texteditor.qml
index 205dde520e..decf0801e4 100644
--- a/examples/quickcontrols2/texteditor/qml/texteditor.qml
+++ b/examples/quickcontrols2/texteditor/qml/texteditor.qml
@@ -153,7 +153,7 @@ ApplicationWindow {
selectedNameFilter.index: 1
nameFilters: ["Text files (*.txt)", "HTML files (*.html *.htm)", "Markdown files (*.md *.markdown)"]
currentFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
- onAccepted: document.load(file)
+ onAccepted: document.load(selectedFile)
}
FileDialog {
@@ -168,14 +168,13 @@ ApplicationWindow {
FontDialog {
id: fontDialog
-
- onAccepted: document.font = fontDialog.selectedFont
- onVisibleChanged: if (visible) currentFont = document.font
+ onAccepted: document.font = selectedFont
}
- Platform.ColorDialog {
+ ColorDialog {
id: colorDialog
- currentColor: "black"
+ selectedColor: "black"
+ onAccepted: document.textColor = selectedColor
}
MessageDialog {
@@ -290,14 +289,20 @@ ApplicationWindow {
font.underline: document.underline
font.strikeout: document.strikeout
focusPolicy: Qt.TabFocus
- onClicked: fontDialog.open()
+ onClicked: function () {
+ fontDialog.selectedFont = document.font
+ fontDialog.open()
+ }
}
ToolButton {
id: textColorButton
text: "\uF1FC" // icon-brush
font.family: "fontello"
focusPolicy: Qt.TabFocus
- onClicked: colorDialog.open()
+ onClicked: function () {
+ colorDialog.selectedColor = document.textColor
+ colorDialog.open()
+ }
Rectangle {
width: aFontMetrics.width + 3
@@ -368,7 +373,6 @@ ApplicationWindow {
cursorPosition: textArea.cursorPosition
selectionStart: textArea.selectionStart
selectionEnd: textArea.selectionEnd
- textColor: colorDialog.color
property alias family: document.font.family
property alias bold: document.font.bold
@@ -451,12 +455,18 @@ ApplicationWindow {
Platform.MenuItem {
text: qsTr("Font...")
- onTriggered: fontDialog.open()
+ onTriggered: function () {
+ fontDialog.selectedFont = document.font
+ fontDialog.open()
+ }
}
Platform.MenuItem {
text: qsTr("Color...")
- onTriggered: colorDialog.open()
+ onTriggered: function () {
+ colorDialog.selectedColor = document.textColor
+ colorDialog.open()
+ }
}
}
diff --git a/examples/quickcontrols2/texteditor/qtquickcontrols2.conf b/examples/quickcontrols2/texteditor/qtquickcontrols2.conf
deleted file mode 100644
index ecac617fcb..0000000000
--- a/examples/quickcontrols2/texteditor/qtquickcontrols2.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-[Controls]
-Style=Material
-
-[Material]
-Primary=White
-Foreground=#444444
-Accent=Blue
-Theme=System
-
-[Universal]
-Theme=System
diff --git a/examples/quickcontrols2/texteditor/texteditor.qrc b/examples/quickcontrols2/texteditor/texteditor.qrc
index 8f2da8432b..cdb7225a39 100644
--- a/examples/quickcontrols2/texteditor/texteditor.qrc
+++ b/examples/quickcontrols2/texteditor/texteditor.qrc
@@ -1,6 +1,5 @@
<RCC>
<qresource prefix="/">
- <file>qtquickcontrols2.conf</file>
<file>images/qt-logo.png</file>
<file>fonts/fontello.ttf</file>
<file>qml/texteditor.qml</file>
diff --git a/src/3rdparty/masm/assembler/ARM64Assembler.h b/src/3rdparty/masm/assembler/ARM64Assembler.h
index 9928da3abd..847b0b09b0 100644
--- a/src/3rdparty/masm/assembler/ARM64Assembler.h
+++ b/src/3rdparty/masm/assembler/ARM64Assembler.h
@@ -657,6 +657,10 @@ public:
data.realTypes.m_bitNumber = bitNumber;
data.realTypes.m_compareRegister = compareRegister;
}
+ LinkRecord(const LinkRecord& other)
+ {
+ *this = other;
+ }
void operator=(const LinkRecord& other)
{
data.realTypes = other.data.realTypes;
diff --git a/src/3rdparty/masm/assembler/ARMv7Assembler.h b/src/3rdparty/masm/assembler/ARMv7Assembler.h
index 330b6c3629..fe0bc0ed74 100644
--- a/src/3rdparty/masm/assembler/ARMv7Assembler.h
+++ b/src/3rdparty/masm/assembler/ARMv7Assembler.h
@@ -481,6 +481,10 @@ public:
data.realTypes.m_linkType = LinkInvalid;
data.realTypes.m_condition = condition;
}
+ LinkRecord(const LinkRecord &other)
+ {
+ *this = other;
+ }
void operator=(const LinkRecord& other)
{
data.copyTypes.content[0] = other.data.copyTypes.content[0];
diff --git a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
index 868a101935..a8990a92b4 100644
--- a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
+++ b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
@@ -227,7 +227,7 @@ void OSAllocator::commit(void* address, size_t bytes, bool writable, bool execut
while (madvise(address, bytes, MADV_WILLNEED)) {
if (errno != EAGAIN)
- CRASH();
+ break; // We don't have to crash here. MADV_WILLNEED is only advisory
}
#elif HAVE(MADV_FREE_REUSE)
diff --git a/src/3rdparty/masm/wtf/Platform.h b/src/3rdparty/masm/wtf/Platform.h
index 29decfadcf..5c83dec2b9 100644
--- a/src/3rdparty/masm/wtf/Platform.h
+++ b/src/3rdparty/masm/wtf/Platform.h
@@ -224,6 +224,7 @@
|| defined(__ARM_ARCH_6K__) \
|| defined(__ARM_ARCH_6Z__) \
|| defined(__ARM_ARCH_6ZK__) \
+ || defined(__ARM_ARCH_6KZ__) \
|| defined(__ARM_ARCH_6T2__) \
|| defined(__ARMV6__)
#define WTF_ARM_ARCH_VERSION 6
diff --git a/src/3rdparty/masm/yarr/YarrInterpreter.cpp b/src/3rdparty/masm/yarr/YarrInterpreter.cpp
index cdcd16af64..f57fe363b4 100644
--- a/src/3rdparty/masm/yarr/YarrInterpreter.cpp
+++ b/src/3rdparty/masm/yarr/YarrInterpreter.cpp
@@ -2406,8 +2406,8 @@ unsigned interpret(BytecodePattern* bytecode, const String& input, unsigned star
{
SuperSamplerScope superSamplerScope(false);
if (input.is8Bit())
- return Interpreter<LChar>(bytecode, output, input.characters8(), input.length(), start).interpret();
- return Interpreter<UChar>(bytecode, output, input.characters16(), input.length(), start).interpret();
+ return Interpreter<LChar>(bytecode, output, input.characters8(), input.size(), start).interpret();
+ return Interpreter<UChar>(bytecode, output, input.characters16(), input.size(), start).interpret();
}
unsigned interpret(BytecodePattern* bytecode, const LChar* input, unsigned length, unsigned start, unsigned* output)
diff --git a/src/3rdparty/masm/yarr/YarrParser.h b/src/3rdparty/masm/yarr/YarrParser.h
index d5433286dd..a6044d49ac 100644
--- a/src/3rdparty/masm/yarr/YarrParser.h
+++ b/src/3rdparty/masm/yarr/YarrParser.h
@@ -215,7 +215,7 @@ private:
: m_delegate(delegate)
, m_backReferenceLimit(backReferenceLimit)
, m_data(pattern.characters<CharType>())
- , m_size(pattern.length())
+ , m_size(pattern.size())
, m_isUnicode(isUnicode)
{
}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 71d6b0d910..dc3ea3494c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -28,10 +28,12 @@ if(TARGET Qt::Gui AND TARGET Qt::qsb AND QT_FEATURE_qml_animation)
add_subdirectory(quick)
add_subdirectory(quicklayouts)
- find_package(Qt6 ${PROJECT_VERSION} CONFIG COMPONENTS Test) # special case
- if(QT_FEATURE_testlib AND TARGET Qt::Test) # special case
+ find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS Test)
+ if(QT_FEATURE_testlib AND TARGET Qt::Test)
add_subdirectory(qmltest)
- add_subdirectory(quicktestutils)
+ if(QT_FEATURE_network)
+ add_subdirectory(quicktestutils)
+ endif()
endif()
if(QT_FEATURE_quick_particles)
@@ -52,7 +54,7 @@ if(TARGET Qt::Gui AND TARGET Qt::qsb AND QT_FEATURE_qml_animation)
add_subdirectory(quickdialogs2)
add_subdirectory(quicknativestyle)
- if(TARGET Qt::QuickControls2)
+ if(QT_FEATURE_testlib AND QT_FEATURE_network AND TARGET Qt::Test AND TARGET Qt::QuickControls2)
add_subdirectory(quickcontrolstestutils)
endif()
else()
diff --git a/src/labs/animation/qquickboundaryrule.cpp b/src/labs/animation/qquickboundaryrule.cpp
index fbf82023bc..08fa5f56ac 100644
--- a/src/labs/animation/qquickboundaryrule.cpp
+++ b/src/labs/animation/qquickboundaryrule.cpp
@@ -318,7 +318,7 @@ qreal QQuickBoundaryRule::peakOvershoot() const
}
/*!
- \qmlproperty enum QtQuick::BoundaryRule::overshootFilter
+ \qmlproperty enumeration QtQuick::BoundaryRule::overshootFilter
This property specifies the aggregation function that will be applied to
the intercepted property value.
@@ -384,7 +384,7 @@ bool QQuickBoundaryRule::returnToBounds()
}
/*!
- \qmlproperty qreal QtQuick::BoundaryRule::easing
+ \qmlproperty enumeration QtQuick::BoundaryRule::easing
This property holds the easing curve to be applied in overshoot mode
(whenever the \l minimum or \l maximum constraint is violated, while
diff --git a/src/labs/folderlistmodel/fileinfothread.cpp b/src/labs/folderlistmodel/fileinfothread.cpp
index fa726d95c3..edde6422e8 100644
--- a/src/labs/folderlistmodel/fileinfothread.cpp
+++ b/src/labs/folderlistmodel/fileinfothread.cpp
@@ -268,7 +268,7 @@ void FileInfoThread::getFileInfos(const QString &path)
const QFileInfoList fileInfoList = currentDir.entryInfoList(nameFilters, filter, sortFlags);
if (!fileInfoList.isEmpty()) {
- filePropertyList.reserve(fileInfoList.count());
+ filePropertyList.reserve(fileInfoList.size());
for (const QFileInfo &info : fileInfoList) {
//qDebug() << "Adding file : " << info.fileName() << "to list ";
filePropertyList << FileProperty(info);
diff --git a/src/labs/folderlistmodel/qquickfolderlistmodel.cpp b/src/labs/folderlistmodel/qquickfolderlistmodel.cpp
index c1070e3f4f..3b07efab77 100644
--- a/src/labs/folderlistmodel/qquickfolderlistmodel.cpp
+++ b/src/labs/folderlistmodel/qquickfolderlistmodel.cpp
@@ -175,7 +175,7 @@ QString QQuickFolderListModelPrivate::resolvePath(const QUrl &path)
QString localPath = QQmlFile::urlToLocalFileOrQrc(path);
QUrl localUrl = QUrl(localPath);
QString fullPath = localUrl.path();
- if (localUrl.scheme().length())
+ if (localUrl.scheme().size())
fullPath = localUrl.scheme() + QLatin1Char(':') + fullPath;
return QDir::cleanPath(fullPath);
}
diff --git a/src/labs/models/qqmldelegatecomponent.cpp b/src/labs/models/qqmldelegatecomponent.cpp
index 45e64995fb..3a9bb647c6 100644
--- a/src/labs/models/qqmldelegatecomponent.cpp
+++ b/src/labs/models/qqmldelegatecomponent.cpp
@@ -239,7 +239,7 @@ void QQmlDelegateChooser::choices_append(QQmlListProperty<QQmlDelegateChoice> *p
qsizetype QQmlDelegateChooser::choices_count(QQmlListProperty<QQmlDelegateChoice> *prop)
{
QQmlDelegateChooser *q = static_cast<QQmlDelegateChooser*>(prop->object);
- return q->m_choices.count();
+ return q->m_choices.size();
}
QQmlDelegateChoice *QQmlDelegateChooser::choices_at(QQmlListProperty<QQmlDelegateChoice> *prop, qsizetype index)
@@ -294,7 +294,7 @@ QQmlComponent *QQmlDelegateChooser::delegate(QQmlAdaptorModel *adaptorModel, int
}
// loop through choices, finding first one that fits
- for (int i = 0; i < m_choices.count(); ++i) {
+ for (int i = 0; i < m_choices.size(); ++i) {
const QQmlDelegateChoice *choice = m_choices.at(i);
if (choice->match(row, column, v))
return choice->delegate();
diff --git a/src/labs/models/qqmltablemodel.cpp b/src/labs/models/qqmltablemodel.cpp
index e95ea46c84..2822087439 100644
--- a/src/labs/models/qqmltablemodel.cpp
+++ b/src/labs/models/qqmltablemodel.cpp
@@ -627,7 +627,7 @@ void QQmlTableModel::columns_append(QQmlListProperty<QQmlTableModelColumn> *prop
qsizetype QQmlTableModel::columns_count(QQmlListProperty<QQmlTableModelColumn> *property)
{
const QQmlTableModel *model = static_cast<QQmlTableModel*>(property->object);
- return model->mColumns.count();
+ return model->mColumns.size();
}
QQmlTableModelColumn *QQmlTableModel::columns_at(QQmlListProperty<QQmlTableModelColumn> *property, qsizetype index)
diff --git a/src/labs/platform/doc/qtlabsplatform.qdocconf b/src/labs/platform/doc/qtlabsplatform.qdocconf
index f159fff9bf..b7f056521c 100644
--- a/src/labs/platform/doc/qtlabsplatform.qdocconf
+++ b/src/labs/platform/doc/qtlabsplatform.qdocconf
@@ -19,7 +19,7 @@ qhp.QtLabsPlatform.subprojects.qmltypes.indexTitle = Qt Labs Platform QML Types
qhp.QtLabsPlatform.subprojects.qmltypes.selectors = qmlclass
qhp.QtLabsPlatform.subprojects.qmltypes.sortPages = true
-depends = qtcore qtgui qtdoc qtqml qtqmlmodels qtquick qtquickcontrols qtwidgets
+depends = qtcore qtgui qtdoc qtqml qtqmlcore qtqmlmodels qtquick qtquickcontrols qtwidgets
# This module has no documented C++ types, clear the module header
moduleheader =
diff --git a/src/labs/platform/qquicklabsplatformdialog_p.h b/src/labs/platform/qquicklabsplatformdialog_p.h
index a8d810696c..e04b097694 100644
--- a/src/labs/platform/qquicklabsplatformdialog_p.h
+++ b/src/labs/platform/qquicklabsplatformdialog_p.h
@@ -116,7 +116,7 @@ private:
QPlatformDialogHelper *m_handle;
};
-class QPlatformDialogHelperForeign
+class QPlatformDialogHelperQuickLabsForeign
{
Q_GADGET
QML_FOREIGN(QPlatformDialogHelper)
diff --git a/src/labs/platform/qquicklabsplatformfiledialog.cpp b/src/labs/platform/qquicklabsplatformfiledialog.cpp
index 540da2b3bc..4cd3172820 100644
--- a/src/labs/platform/qquicklabsplatformfiledialog.cpp
+++ b/src/labs/platform/qquicklabsplatformfiledialog.cpp
@@ -308,7 +308,7 @@ void QQuickLabsPlatformFileDialog::setNameFilters(const QStringList &filters)
m_options->setNameFilters(filters);
if (m_selectedNameFilter) {
int index = m_selectedNameFilter->index();
- if (index < 0 || index >= filters.count())
+ if (index < 0 || index >= filters.size())
index = 0;
m_selectedNameFilter->update(filters.value(index));
}
diff --git a/src/labs/platform/qquicklabsplatformfolderdialog.cpp b/src/labs/platform/qquicklabsplatformfolderdialog.cpp
index f152213ff2..512f241b7d 100644
--- a/src/labs/platform/qquicklabsplatformfolderdialog.cpp
+++ b/src/labs/platform/qquicklabsplatformfolderdialog.cpp
@@ -91,7 +91,6 @@ void QQuickLabsPlatformFolderDialog::setFolder(const QUrl &folder)
return;
m_folder = folder;
- setCurrentFolder(folder);
emit folderChanged();
}
diff --git a/src/labs/platform/qquicklabsplatformmenu.cpp b/src/labs/platform/qquicklabsplatformmenu.cpp
index 04f1abd15d..cd23813d63 100644
--- a/src/labs/platform/qquicklabsplatformmenu.cpp
+++ b/src/labs/platform/qquicklabsplatformmenu.cpp
@@ -194,7 +194,7 @@ QQuickLabsPlatformMenu::~QQuickLabsPlatformMenu()
void QQuickLabsPlatformMenu::unparentSubmenus()
{
- for (QQuickLabsPlatformMenuItem *item : qAsConst(m_items)) {
+ for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items)) {
if (QQuickLabsPlatformMenu *subMenu = item->subMenu())
subMenu->setParentMenu(nullptr);
item->setMenu(nullptr);
@@ -234,7 +234,7 @@ QPlatformMenu * QQuickLabsPlatformMenu::create()
connect(m_handle, &QPlatformMenu::aboutToShow, this, &QQuickLabsPlatformMenu::aboutToShow);
connect(m_handle, &QPlatformMenu::aboutToHide, this, &QQuickLabsPlatformMenu::aboutToHide);
- for (QQuickLabsPlatformMenuItem *item : qAsConst(m_items))
+ for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items))
m_handle->insertMenuItem(item->create(), nullptr);
if (m_menuItem) {
@@ -278,7 +278,7 @@ void QQuickLabsPlatformMenu::sync()
m_systemTrayIcon->handle()->updateMenu(m_handle);
#endif
- for (QQuickLabsPlatformMenuItem *item : qAsConst(m_items))
+ for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items))
item->sync();
}
@@ -564,7 +564,7 @@ void QQuickLabsPlatformMenu::setIcon(const QQuickLabsPlatformIcon &icon)
*/
void QQuickLabsPlatformMenu::addItem(QQuickLabsPlatformMenuItem *item)
{
- insertItem(m_items.count(), item);
+ insertItem(m_items.size(), item);
}
/*!
@@ -613,7 +613,7 @@ void QQuickLabsPlatformMenu::removeItem(QQuickLabsPlatformMenuItem *item)
*/
void QQuickLabsPlatformMenu::addMenu(QQuickLabsPlatformMenu *menu)
{
- insertMenu(m_items.count(), menu);
+ insertMenu(m_items.size(), menu);
}
/*!
@@ -654,7 +654,7 @@ void QQuickLabsPlatformMenu::clear()
if (m_items.isEmpty())
return;
- for (QQuickLabsPlatformMenuItem *item : qAsConst(m_items)) {
+ for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items)) {
m_data.removeOne(item);
if (m_handle)
m_handle->removeMenuItem(item->handle());
@@ -809,7 +809,7 @@ void QQuickLabsPlatformMenu::data_append(QQmlListProperty<QObject> *property, QO
qsizetype QQuickLabsPlatformMenu::data_count(QQmlListProperty<QObject> *property)
{
QQuickLabsPlatformMenu *menu = static_cast<QQuickLabsPlatformMenu *>(property->object);
- return menu->m_data.count();
+ return menu->m_data.size();
}
QObject *QQuickLabsPlatformMenu::data_at(QQmlListProperty<QObject> *property, qsizetype index)
@@ -833,7 +833,7 @@ void QQuickLabsPlatformMenu::items_append(QQmlListProperty<QQuickLabsPlatformMen
qsizetype QQuickLabsPlatformMenu::items_count(QQmlListProperty<QQuickLabsPlatformMenuItem> *property)
{
QQuickLabsPlatformMenu *menu = static_cast<QQuickLabsPlatformMenu *>(property->object);
- return menu->m_items.count();
+ return menu->m_items.size();
}
QQuickLabsPlatformMenuItem *QQuickLabsPlatformMenu::items_at(QQmlListProperty<QQuickLabsPlatformMenuItem> *property, qsizetype index)
diff --git a/src/labs/platform/qquicklabsplatformmenubar.cpp b/src/labs/platform/qquicklabsplatformmenubar.cpp
index ed7ebf9de3..8c0b4fd042 100644
--- a/src/labs/platform/qquicklabsplatformmenubar.cpp
+++ b/src/labs/platform/qquicklabsplatformmenubar.cpp
@@ -63,6 +63,7 @@ QT_BEGIN_NAMESPACE
\li macOS
\li Android
\li Linux (only available on desktop environments that provide a global D-Bus menu bar)
+ \li Windows
\endlist
\labs
@@ -84,7 +85,7 @@ QQuickLabsPlatformMenuBar::QQuickLabsPlatformMenuBar(QObject *parent)
QQuickLabsPlatformMenuBar::~QQuickLabsPlatformMenuBar()
{
- for (QQuickLabsPlatformMenu *menu : qAsConst(m_menus))
+ for (QQuickLabsPlatformMenu *menu : std::as_const(m_menus))
menu->setMenuBar(nullptr);
delete m_handle;
m_handle = nullptr;
@@ -153,7 +154,7 @@ void QQuickLabsPlatformMenuBar::setWindow(QWindow *window)
*/
void QQuickLabsPlatformMenuBar::addMenu(QQuickLabsPlatformMenu *menu)
{
- insertMenu(m_menus.count(), menu);
+ insertMenu(m_menus.size(), menu);
}
/*!
@@ -203,7 +204,7 @@ void QQuickLabsPlatformMenuBar::clear()
if (m_menus.isEmpty())
return;
- for (QQuickLabsPlatformMenu *menu : qAsConst(m_menus)) {
+ for (QQuickLabsPlatformMenu *menu : std::as_const(m_menus)) {
m_data.removeOne(menu);
if (m_handle)
m_handle->removeMenu(menu->handle());
@@ -222,7 +223,7 @@ void QQuickLabsPlatformMenuBar::classBegin()
void QQuickLabsPlatformMenuBar::componentComplete()
{
m_complete = true;
- for (QQuickLabsPlatformMenu *menu : qAsConst(m_menus))
+ for (QQuickLabsPlatformMenu *menu : std::as_const(m_menus))
menu->sync();
if (!m_window)
setWindow(findWindow());
@@ -256,7 +257,7 @@ void QQuickLabsPlatformMenuBar::data_append(QQmlListProperty<QObject> *property,
qsizetype QQuickLabsPlatformMenuBar::data_count(QQmlListProperty<QObject> *property)
{
QQuickLabsPlatformMenuBar *menuBar = static_cast<QQuickLabsPlatformMenuBar *>(property->object);
- return menuBar->m_data.count();
+ return menuBar->m_data.size();
}
QObject *QQuickLabsPlatformMenuBar::data_at(QQmlListProperty<QObject> *property, qsizetype index)
@@ -280,7 +281,7 @@ void QQuickLabsPlatformMenuBar::menus_append(QQmlListProperty<QQuickLabsPlatform
qsizetype QQuickLabsPlatformMenuBar::menus_count(QQmlListProperty<QQuickLabsPlatformMenu> *property)
{
QQuickLabsPlatformMenuBar *menuBar = static_cast<QQuickLabsPlatformMenuBar *>(property->object);
- return menuBar->m_menus.count();
+ return menuBar->m_menus.size();
}
QQuickLabsPlatformMenu *QQuickLabsPlatformMenuBar::menus_at(QQmlListProperty<QQuickLabsPlatformMenu> *property, qsizetype index)
diff --git a/src/labs/platform/qquicklabsplatformmenuitem.cpp b/src/labs/platform/qquicklabsplatformmenuitem.cpp
index 43afaa0f9f..31e91add36 100644
--- a/src/labs/platform/qquicklabsplatformmenuitem.cpp
+++ b/src/labs/platform/qquicklabsplatformmenuitem.cpp
@@ -90,16 +90,7 @@ QQuickLabsPlatformMenuItem::~QQuickLabsPlatformMenuItem()
m_menu->removeItem(this);
if (m_group)
m_group->removeItem(this);
-#if QT_CONFIG(shortcut)
- if (m_shortcutId != -1) {
- QKeySequence sequence;
- if (m_shortcut.metaType().id() == QMetaType::Int)
- sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt()));
- else
- sequence = QKeySequence::fromString(m_shortcut.toString());
- QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(m_shortcutId, this, sequence);
- }
-#endif
+ removeShortcut();
delete m_iconLoader;
m_iconLoader = nullptr;
delete m_handle;
@@ -266,8 +257,15 @@ void QQuickLabsPlatformMenuItem::setEnabled(bool enabled)
if (m_enabled == enabled)
return;
+ if (!enabled)
+ removeShortcut();
+
bool wasEnabled = isEnabled();
m_enabled = enabled;
+
+ if (enabled)
+ addShortcut();
+
sync();
if (isEnabled() != wasEnabled)
emit enabledChanged();
@@ -473,31 +471,10 @@ void QQuickLabsPlatformMenuItem::setShortcut(const QVariant& shortcut)
if (m_shortcut == shortcut)
return;
-#if QT_CONFIG(shortcut)
- if (m_shortcutId != -1) {
- QKeySequence sequence;
- if (m_shortcut.metaType().id() == QMetaType::Int)
- sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt()));
- else
- sequence = QKeySequence::fromString(m_shortcut.toString());
- QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(m_shortcutId, this, sequence);
- }
-#endif
+ removeShortcut();
m_shortcut = shortcut;
sync();
-#if QT_CONFIG(shortcut)
- QKeySequence sequence;
- if (m_shortcut.metaType().id() == QMetaType::Int)
- sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt()));
- else
- sequence = QKeySequence::fromString(m_shortcut.toString());
- if (!sequence.isEmpty()) {
- m_shortcutId = QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, sequence,
- Qt::WindowShortcut, QQuickShortcutContext::matcher);
- } else {
- m_shortcutId = -1;
- }
-#endif
+ addShortcut();
emit shortcutChanged();
}
@@ -603,6 +580,38 @@ void QQuickLabsPlatformMenuItem::updateIcon()
sync();
}
+void QQuickLabsPlatformMenuItem::addShortcut()
+{
+#if QT_CONFIG(shortcut)
+ QKeySequence sequence;
+ if (m_shortcut.metaType().id() == QMetaType::Int)
+ sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt()));
+ else
+ sequence = QKeySequence::fromString(m_shortcut.toString());
+ if (!sequence.isEmpty() && m_enabled) {
+ m_shortcutId = QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, sequence,
+ Qt::WindowShortcut, QQuickShortcutContext::matcher);
+ } else {
+ m_shortcutId = -1;
+ }
+#endif
+}
+
+void QQuickLabsPlatformMenuItem::removeShortcut()
+{
+#if QT_CONFIG(shortcut)
+ if (m_shortcutId == -1)
+ return;
+
+ QKeySequence sequence;
+ if (m_shortcut.metaType().id() == QMetaType::Int)
+ sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt()));
+ else
+ sequence = QKeySequence::fromString(m_shortcut.toString());
+ QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(m_shortcutId, this, sequence);
+#endif
+}
+
QT_END_NAMESPACE
#include "moc_qquicklabsplatformmenuitem_p.cpp"
diff --git a/src/labs/platform/qquicklabsplatformmenuitem_p.h b/src/labs/platform/qquicklabsplatformmenuitem_p.h
index 48c03eca33..f02f2536fd 100644
--- a/src/labs/platform/qquicklabsplatformmenuitem_p.h
+++ b/src/labs/platform/qquicklabsplatformmenuitem_p.h
@@ -131,6 +131,9 @@ private Q_SLOTS:
void updateIcon();
private:
+ void addShortcut();
+ void removeShortcut();
+
bool m_complete;
bool m_enabled;
bool m_visible;
diff --git a/src/labs/platform/qquicklabsplatformmenuitemgroup.cpp b/src/labs/platform/qquicklabsplatformmenuitemgroup.cpp
index df121e47ff..33580dd04e 100644
--- a/src/labs/platform/qquicklabsplatformmenuitemgroup.cpp
+++ b/src/labs/platform/qquicklabsplatformmenuitemgroup.cpp
@@ -131,7 +131,7 @@ void QQuickLabsPlatformMenuItemGroup::setEnabled(bool enabled)
m_enabled = enabled;
emit enabledChanged();
- for (QQuickLabsPlatformMenuItem *item : qAsConst(m_items)) {
+ for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items)) {
if (item->m_enabled) {
item->sync();
emit item->enabledChanged();
@@ -160,7 +160,7 @@ void QQuickLabsPlatformMenuItemGroup::setVisible(bool visible)
m_visible = visible;
emit visibleChanged();
- for (QQuickLabsPlatformMenuItem *item : qAsConst(m_items)) {
+ for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items)) {
if (item->m_visible) {
item->sync();
emit item->visibleChanged();
@@ -189,7 +189,7 @@ void QQuickLabsPlatformMenuItemGroup::setExclusive(bool exclusive)
m_exclusive = exclusive;
emit exclusiveChanged();
- for (QQuickLabsPlatformMenuItem *item : qAsConst(m_items))
+ for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items))
item->sync();
}
@@ -284,7 +284,7 @@ void QQuickLabsPlatformMenuItemGroup::clear()
if (m_items.isEmpty())
return;
- for (QQuickLabsPlatformMenuItem *item : qAsConst(m_items)) {
+ for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items)) {
item->setGroup(nullptr);
disconnect(item, &QQuickLabsPlatformMenuItem::checkedChanged, this, &QQuickLabsPlatformMenuItemGroup::updateCurrent);
disconnect(item, &QQuickLabsPlatformMenuItem::triggered, this, &QQuickLabsPlatformMenuItemGroup::activateItem);
@@ -339,7 +339,7 @@ void QQuickLabsPlatformMenuItemGroup::items_append(QQmlListProperty<QQuickLabsPl
qsizetype QQuickLabsPlatformMenuItemGroup::items_count(QQmlListProperty<QQuickLabsPlatformMenuItem> *prop)
{
QQuickLabsPlatformMenuItemGroup *group = static_cast<QQuickLabsPlatformMenuItemGroup *>(prop->object);
- return group->m_items.count();
+ return group->m_items.size();
}
QQuickLabsPlatformMenuItem *QQuickLabsPlatformMenuItemGroup::items_at(QQmlListProperty<QQuickLabsPlatformMenuItem> *prop, qsizetype index)
diff --git a/src/labs/platform/qquicklabsplatformstandardpaths.cpp b/src/labs/platform/qquicklabsplatformstandardpaths.cpp
index e44c1b87d1..3133cdd306 100644
--- a/src/labs/platform/qquicklabsplatformstandardpaths.cpp
+++ b/src/labs/platform/qquicklabsplatformstandardpaths.cpp
@@ -3,6 +3,8 @@
#include "qquicklabsplatformstandardpaths_p.h"
+#if QT_DEPRECATED_SINCE(6, 4)
+
#include <QtQml/qqmlengine.h>
QT_BEGIN_NAMESPACE
@@ -13,6 +15,7 @@ QT_BEGIN_NAMESPACE
//! \instantiates QQuickLabsPlatformStandardPaths
\inqmlmodule Qt.labs.platform
\since 5.8
+ \deprecated [6.4] Use QtCore::StandardPaths instead.
\brief Provides access to the standard system paths.
The StandardPaths singleton type provides methods for querying the standard
@@ -27,7 +30,7 @@ QT_BEGIN_NAMESPACE
\labs
- \sa FileDialog, FolderDialog, QStandardPaths
+ \sa QtCore::StandardPaths, FileDialog, FolderDialog, QStandardPaths
*/
static QList<QUrl> toUrlList(const QStringList &paths)
@@ -137,3 +140,5 @@ QUrl QQuickLabsPlatformStandardPaths::writableLocation(QStandardPaths::StandardL
QT_END_NAMESPACE
#include "moc_qquicklabsplatformstandardpaths_p.cpp"
+
+#endif // QT_DEPRECATED_SINCE(6, 4)
diff --git a/src/labs/platform/qquicklabsplatformstandardpaths_p.h b/src/labs/platform/qquicklabsplatformstandardpaths_p.h
index 1e0d96b953..9941c3081e 100644
--- a/src/labs/platform/qquicklabsplatformstandardpaths_p.h
+++ b/src/labs/platform/qquicklabsplatformstandardpaths_p.h
@@ -21,6 +21,8 @@
#include <QtQml/qqml.h>
#include <QtCore/private/qglobal_p.h>
+#if QT_DEPRECATED_SINCE(6, 4)
+
QT_BEGIN_NAMESPACE
class QQmlEngine;
@@ -56,4 +58,6 @@ QML_DECLARE_TYPE(QQuickLabsPlatformStandardPaths)
Q_DECLARE_METATYPE(QStandardPaths::StandardLocation)
Q_DECLARE_METATYPE(QStandardPaths::LocateOptions)
+#endif // QT_DEPRECATED_SINCE(6, 4)
+
#endif // QQUICKLABSPLATFORMSTANDARDPATHS_P_H
diff --git a/src/labs/platform/widgets/qwidgetplatformfiledialog.cpp b/src/labs/platform/widgets/qwidgetplatformfiledialog.cpp
index ae9d7d3cb0..738982b5c6 100644
--- a/src/labs/platform/widgets/qwidgetplatformfiledialog.cpp
+++ b/src/labs/platform/widgets/qwidgetplatformfiledialog.cpp
@@ -21,7 +21,7 @@ QWidgetPlatformFileDialog::QWidgetPlatformFileDialog(QObject *parent)
});
connect(m_dialog.data(), &QFileDialog::filesSelected, [this](const QList<QString> &files) {
QList<QUrl> urls;
- urls.reserve(files.count());
+ urls.reserve(files.size());
for (const QString &file : files)
urls += QUrl::fromLocalFile(file);
emit filesSelected(urls);
diff --git a/src/labs/platform/widgets/qwidgetplatformmenu.cpp b/src/labs/platform/widgets/qwidgetplatformmenu.cpp
index 1db01a5e79..a154775b94 100644
--- a/src/labs/platform/widgets/qwidgetplatformmenu.cpp
+++ b/src/labs/platform/widgets/qwidgetplatformmenu.cpp
@@ -6,6 +6,7 @@
#include <QtGui/qaction.h>
#include <QtGui/qwindow.h>
+#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtWidgets/qmenu.h>
QT_BEGIN_NAMESPACE
@@ -38,7 +39,7 @@ void QWidgetPlatformMenu::insertMenuItem(QPlatformMenuItem *item, QPlatformMenuI
m_menu->insertAction(widgetBefore ? widgetBefore->action() : nullptr, widgetItem->action());
int index = m_items.indexOf(widgetBefore);
if (index < 0)
- index = m_items.count();
+ index = m_items.size();
m_items.insert(index, widgetItem);
}
@@ -112,7 +113,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
QPoint targetPos = targetRect.bottomLeft();
if (window)
- targetPos = window->mapToGlobal(targetPos);
+ targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
diff --git a/src/labs/sharedimage/qsharedimageprovider.cpp b/src/labs/sharedimage/qsharedimageprovider.cpp
index 7bac6d4e03..69f0013b06 100644
--- a/src/labs/sharedimage/qsharedimageprovider.cpp
+++ b/src/labs/sharedimage/qsharedimageprovider.cpp
@@ -45,7 +45,7 @@ QImage QuickSharedImageLoader::loadFile(const QString &path, ImageParameters *pa
}
}
- if (params && params->count() > OriginalSize)
+ if (params && params->size() > OriginalSize)
params->replace(OriginalSize, realSize);
return image;
diff --git a/src/labs/wavefrontmesh/qwavefrontmesh.cpp b/src/labs/wavefrontmesh/qwavefrontmesh.cpp
index 536447c26d..844ebfbd84 100644
--- a/src/labs/wavefrontmesh/qwavefrontmesh.cpp
+++ b/src/labs/wavefrontmesh/qwavefrontmesh.cpp
@@ -245,7 +245,7 @@ void QWavefrontMesh::readData()
d->textureCoordinates.append(QVector2D(u, v));
} else if (command == "v") {
// Format: v <x> <y> <z> [w]
- if (tokens.length() < 4 || tokens.length() > 5) {
+ if (tokens.size() < 4 || tokens.size() > 5) {
setLastError(InvalidSourceError);
return;
}
@@ -438,7 +438,7 @@ QString QWavefrontMesh::log() const
bool QWavefrontMesh::validateAttributes(const QList<QByteArray> &attributes, int *posIndex)
{
Q_D(QWavefrontMesh);
- const int attrCount = attributes.count();
+ const int attrCount = attributes.size();
int positionIndex = attributes.indexOf(qtPositionAttributeName());
int texCoordIndex = attributes.indexOf(qtTexCoordAttributeName());
diff --git a/src/particles/qquickcustomaffector.cpp b/src/particles/qquickcustomaffector.cpp
index 92b52065bb..71ada8a5b9 100644
--- a/src/particles/qquickcustomaffector.cpp
+++ b/src/particles/qquickcustomaffector.cpp
@@ -84,7 +84,7 @@ void QQuickCustomAffector::affectSystem(qreal dt)
updateOffsets();
QList<QQuickParticleData*> toAffect;
- for (const QQuickParticleGroupData *gd : qAsConst(m_system->groupData)) {
+ for (const QQuickParticleGroupData *gd : std::as_const(m_system->groupData)) {
if (activeGroup(gd->index)) {
for (QQuickParticleData *d : gd->data) {
if (shouldAffect(d)) {
@@ -98,7 +98,7 @@ void QQuickCustomAffector::affectSystem(qreal dt)
return;
if (justAffected) {
- for (const QQuickParticleData *d : qAsConst(toAffect)) {//Not postAffect to avoid saying the particle changed
+ for (const QQuickParticleData *d : std::as_const(toAffect)) {//Not postAffect to avoid saying the particle changed
if (m_onceOff)
m_onceOffed << qMakePair(d->groupId, d->index);
emit affected(d->curX(m_system), d->curY(m_system));
@@ -140,7 +140,7 @@ void QQuickCustomAffector::affectSystem(qreal dt)
doAffect(dt);
}
- for (QQuickParticleData *d : qAsConst(toAffect))
+ for (QQuickParticleData *d : std::as_const(toAffect))
if (d->update == 1.0)
postAffect(d);
}
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp
index b4461f5a7e..07076c6d29 100644
--- a/src/particles/qquickimageparticle.cpp
+++ b/src/particles/qquickimageparticle.cpp
@@ -730,6 +730,7 @@ void QQuickImageParticle::sceneGraphInvalidated()
m_material = nullptr;
delete m_outgoingNode;
m_outgoingNode = nullptr;
+ m_apiChecked = false;
}
void QQuickImageParticle::setImage(const QUrl &image)
@@ -981,7 +982,7 @@ void QQuickImageParticle::resetColor()
{
m_explicitColor = false;
for (auto groupId : groupIds()) {
- for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) {
+ for (QQuickParticleData* d : std::as_const(m_system->groupData[groupId]->data)) {
if (d->colorOwner == this) {
d->colorOwner = nullptr;
}
@@ -1000,7 +1001,7 @@ void QQuickImageParticle::resetRotation()
{
m_explicitRotation = false;
for (auto groupId : groupIds()) {
- for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) {
+ for (QQuickParticleData* d : std::as_const(m_system->groupData[groupId]->data)) {
if (d->rotationOwner == this) {
d->rotationOwner = nullptr;
}
@@ -1017,7 +1018,7 @@ void QQuickImageParticle::resetDeformation()
{
m_explicitDeformation = false;
for (auto groupId : groupIds()) {
- for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) {
+ for (QQuickParticleData* d : std::as_const(m_system->groupData[groupId]->data)) {
if (d->deformationOwner == this) {
d->deformationOwner = nullptr;
}
@@ -1038,11 +1039,17 @@ void QQuickImageParticle::reset()
update();
}
+
+void QQuickImageParticle::invalidateSceneGraph()
+{
+ reset();
+}
+
void QQuickImageParticle::createEngine()
{
if (m_spriteEngine)
delete m_spriteEngine;
- if (m_sprites.count()) {
+ if (m_sprites.size()) {
m_spriteEngine = new QQuickSpriteEngine(m_sprites, this);
connect(m_spriteEngine, SIGNAL(stateChanged(int)),
this, SLOT(spriteAdvance(int)), Qt::DirectConnection);
@@ -1244,7 +1251,7 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node)
m_debugMode = m_system->m_debugMode;
- if (m_sprites.count() || m_bypassOptimizations) {
+ if (m_sprites.size() || m_bypassOptimizations) {
perfLevel = Sprites;
} else if (m_colorTable || m_sizeTable || m_opacityTable) {
perfLevel = Tabled;
@@ -1261,7 +1268,7 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node)
for (auto groupId : groupIds()) {
//For sharing higher levels, need to have highest used so it renders
- for (QQuickParticlePainter* p : qAsConst(m_system->groupData[groupId]->painters)) {
+ for (QQuickParticlePainter* p : std::as_const(m_system->groupData[groupId]->painters)) {
QQuickImageParticle* other = qobject_cast<QQuickImageParticle*>(p);
if (other){
if (other->perfLevel > perfLevel) {
@@ -1616,7 +1623,7 @@ void QQuickImageParticle::spritesUpdate(qreal time)
ImageMaterialData *state = getState(m_material);
// Sprite progression handled CPU side, so as to have per-frame control.
for (auto groupId : groupIds()) {
- for (QQuickParticleData* mainDatum : qAsConst(m_system->groupData[groupId]->data)) {
+ for (QQuickParticleData* mainDatum : std::as_const(m_system->groupData[groupId]->data)) {
QSGGeometryNode *node = m_nodes[groupId];
if (!node)
continue;
@@ -1624,7 +1631,7 @@ void QQuickImageParticle::spritesUpdate(qreal time)
// This is particularly important for cut-up sprites.
QQuickParticleData* datum = (mainDatum->animationOwner == this ? mainDatum : getShadowDatum(mainDatum));
int spriteIdx = 0;
- for (int i = 0; i<m_startsIdx.count(); i++) {
+ for (int i = 0; i<m_startsIdx.size(); i++) {
if (m_startsIdx[i].second == groupId){
spriteIdx = m_startsIdx[i].first + datum->index;
break;
@@ -1677,12 +1684,12 @@ void QQuickImageParticle::spritesUpdate(qreal time)
void QQuickImageParticle::spriteAdvance(int spriteIdx)
{
- if (!m_startsIdx.count())//Probably overly defensive
+ if (!m_startsIdx.size())//Probably overly defensive
return;
int gIdx = -1;
int i;
- for (i = 0; i<m_startsIdx.count(); i++) {
+ for (i = 0; i<m_startsIdx.size(); i++) {
if (spriteIdx < m_startsIdx[i].first) {
gIdx = m_startsIdx[i-1].second;
break;
diff --git a/src/particles/qquickimageparticle_p.h b/src/particles/qquickimageparticle_p.h
index 9b80aef0a1..b380bca821 100644
--- a/src/particles/qquickimageparticle_p.h
+++ b/src/particles/qquickimageparticle_p.h
@@ -359,6 +359,8 @@ private Q_SLOTS:
void spritesUpdate(qreal time = 0 );
void mainThreadFetchImageData();
void finishBuildParticleNodes(QSGNode **n);
+ void invalidateSceneGraph();
+
private:
struct ImageData {
QUrl source;
diff --git a/src/particles/qquickitemparticle.cpp b/src/particles/qquickitemparticle.cpp
index dd8d989378..cd48095b18 100644
--- a/src/particles/qquickitemparticle.cpp
+++ b/src/particles/qquickitemparticle.cpp
@@ -125,7 +125,7 @@ void QQuickItemParticle::take(QQuickItem *item, bool prioritize)
void QQuickItemParticle::give(QQuickItem *item)
{
for (auto groupId : groupIds()) {
- for (QQuickParticleData* data : qAsConst(m_system->groupData[groupId]->data)) {
+ for (QQuickParticleData* data : std::as_const(m_system->groupData[groupId]->data)) {
if (data->delegate == item){
m_deletables << item;
data->delegate = nullptr;
@@ -173,7 +173,7 @@ void QQuickItemParticle::tick(int time)
Q_UNUSED(time);//only needed because QTickAnimationProxy expects one
processDeletables();
for (auto groupId : groupIds()) {
- for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) {
+ for (QQuickParticleData* d : std::as_const(m_system->groupData[groupId]->data)) {
if (!d->delegate && d->t != -1 && d->stillAlive(m_system)) {
QQuickItem* parentItem = nullptr;
if (!m_pendingItems.isEmpty()){
@@ -214,7 +214,7 @@ void QQuickItemParticle::reset()
// but leave it alone if the logical particle is maintained
QSet<QQuickItem*> lost = QSet<QQuickItem*>(m_managed.cbegin(), m_managed.cend());
for (auto groupId : groupIds()) {
- for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) {
+ for (QQuickParticleData* d : std::as_const(m_system->groupData[groupId]->data)) {
lost.remove(d->delegate);
}
}
@@ -251,7 +251,7 @@ void QQuickItemParticle::prepareNextFrame()
//TODO: Size, better fade?
for (auto groupId : groupIds()) {
- for (QQuickParticleData* data : qAsConst(m_system->groupData[groupId]->data)) {
+ for (QQuickParticleData* data : std::as_const(m_system->groupData[groupId]->data)) {
QQuickItem* item = data->delegate;
if (!item)
continue;
diff --git a/src/particles/qquickmaskextruder.cpp b/src/particles/qquickmaskextruder.cpp
index 36b6413503..b7b245758f 100644
--- a/src/particles/qquickmaskextruder.cpp
+++ b/src/particles/qquickmaskextruder.cpp
@@ -69,9 +69,9 @@ void QQuickMaskExtruder::finishMaskLoading()
QPointF QQuickMaskExtruder::extrude(const QRectF &r)
{
ensureInitialized(r);
- if (!m_mask.count() || m_img.isNull())
+ if (!m_mask.size() || m_img.isNull())
return r.topLeft();
- const QPointF p = m_mask[QRandomGenerator::global()->bounded(m_mask.count())];
+ const QPointF p = m_mask[QRandomGenerator::global()->bounded(m_mask.size())];
//### Should random sub-pixel positioning be added?
return p + r.topLeft();
}
diff --git a/src/particles/qquickparticleaffector.cpp b/src/particles/qquickparticleaffector.cpp
index d3594a7bac..17038f4593 100644
--- a/src/particles/qquickparticleaffector.cpp
+++ b/src/particles/qquickparticleaffector.cpp
@@ -177,9 +177,9 @@ void QQuickParticleAffector::affectSystem(qreal dt)
updateOffsets();//### Needed if an ancestor is transformed.
if (m_onceOff)
dt = 1.0;
- for (QQuickParticleGroupData* gd : qAsConst(m_system->groupData)) {
+ for (QQuickParticleGroupData* gd : std::as_const(m_system->groupData)) {
if (activeGroup(gd->index)) {
- for (QQuickParticleData* d : qAsConst(gd->data)) {
+ for (QQuickParticleData* d : std::as_const(gd->data)) {
if (shouldAffect(d)) {
bool affected = false;
qreal myDt = dt;
diff --git a/src/particles/qquickparticlesystem.cpp b/src/particles/qquickparticlesystem.cpp
index 2bceb2456a..655cd4a78e 100644
--- a/src/particles/qquickparticlesystem.cpp
+++ b/src/particles/qquickparticlesystem.cpp
@@ -288,7 +288,7 @@ QQuickParticleGroupData::QQuickParticleGroupData(const QString &name, QQuickPart
QQuickParticleGroupData::~QQuickParticleGroupData()
{
- for (QQuickParticleData *d : qAsConst(data))
+ for (QQuickParticleData *d : std::as_const(data))
delete d;
}
@@ -311,7 +311,7 @@ void QQuickParticleGroupData::setSize(int newSize)
}
int delta = newSize - m_size;
m_size = newSize;
- for (QQuickParticlePainter *p : qAsConst(painters))
+ for (QQuickParticlePainter *p : std::as_const(painters))
p->setCount(p->count() + delta);
}
@@ -324,7 +324,7 @@ void QQuickParticleGroupData::kill(QQuickParticleData* d)
{
Q_ASSERT(d->groupId == index);
d->lifeSpan = 0;//Kill off
- for (QQuickParticlePainter *p : qAsConst(painters))
+ for (QQuickParticlePainter *p : std::as_const(painters))
p->reload(d);
freeList.free(d->index);
}
@@ -543,7 +543,7 @@ QQuickParticleSystem::QQuickParticleSystem(QQuickItem *parent) :
QQuickParticleSystem::~QQuickParticleSystem()
{
- for (QQuickParticleGroupData *gd : qAsConst(groupData))
+ for (QQuickParticleGroupData *gd : std::as_const(groupData))
delete gd;
}
@@ -557,10 +557,10 @@ void QQuickParticleSystem::initGroups()
groupIds.clear();
nextFreeGroupId = 0;
- for (auto e : qAsConst(m_emitters)) {
+ for (auto e : std::as_const(m_emitters)) {
e->reclaculateGroupId();
}
- for (QQuickParticlePainter *p : qAsConst(m_painters)) {
+ for (QQuickParticlePainter *p : std::as_const(m_painters)) {
p->recalculateGroupIds();
}
@@ -632,7 +632,7 @@ void QQuickParticleSystem::setPaused(bool arg) {
if (m_animation && m_animation->state() != QAbstractAnimation::Stopped)
m_paused ? m_animation->pause() : m_animation->resume();
if (!m_paused) {
- for (QQuickParticlePainter *p : qAsConst(m_painters)) {
+ for (QQuickParticlePainter *p : std::as_const(m_painters)) {
if (p) {
p->update();
}
@@ -741,12 +741,12 @@ void QQuickParticleSystem::reset()
if (!m_running)
return;
- for (QQuickParticleEmitter *e : qAsConst(m_emitters))
+ for (QQuickParticleEmitter *e : std::as_const(m_emitters))
e->reset();
emittersChanged();
- for (QQuickParticlePainter *p : qAsConst(m_painters)) {
+ for (QQuickParticlePainter *p : std::as_const(m_painters)) {
loadPainter(p);
p->reset();
}
@@ -807,7 +807,7 @@ void QQuickParticleSystem::emittersChanged()
}
// Populate groups and set sizes.
- for (int i = 0; i < m_emitters.count(); ) {
+ for (int i = 0; i < m_emitters.size(); ) {
QQuickParticleEmitter *e = m_emitters.at(i);
if (!e) {
m_emitters.removeAt(i);
@@ -839,13 +839,13 @@ void QQuickParticleSystem::emittersChanged()
if (particleCount > bySysIdx.size())//New datum requests haven't updated it
bySysIdx.resize(particleCount);
- for (QQuickParticleAffector *a : qAsConst(m_affectors)) {//Groups may have changed
+ for (QQuickParticleAffector *a : std::as_const(m_affectors)) {//Groups may have changed
if (a) {
a->m_updateIntSet = true;
}
}
- for (QQuickParticlePainter *p : qAsConst(m_painters))
+ for (QQuickParticlePainter *p : std::as_const(m_painters))
loadPainter(p);
if (!m_groups.isEmpty())
@@ -860,7 +860,7 @@ void QQuickParticleSystem::createEngine()
if (stateEngine && m_debugMode)
qDebug() << "Resetting Existing Sprite Engine...";
//### Solve the losses if size/states go down
- for (QQuickParticleGroup *group : qAsConst(m_groups)) {
+ for (QQuickParticleGroup *group : std::as_const(m_groups)) {
bool exists = false;
for (auto it = groupIds.keyBegin(), end = groupIds.keyEnd(); it != end; ++it) {
if (group->name() == *it) {
@@ -873,14 +873,14 @@ void QQuickParticleSystem::createEngine()
}
}
- if (m_groups.count()) {
+ if (m_groups.size()) {
//Reorder groups List so as to have the same order as groupData
// TODO: can't we just merge the two lists?
QList<QQuickParticleGroup*> newList;
for (int i = 0, ei = groupData.size(); i != ei; ++i) {
bool exists = false;
QString name = groupData[i]->name();
- for (QQuickParticleGroup *existing : qAsConst(m_groups)) {
+ for (QQuickParticleGroup *existing : std::as_const(m_groups)) {
if (existing->name() == name) {
newList << existing;
exists = true;
@@ -893,8 +893,8 @@ void QQuickParticleSystem::createEngine()
}
m_groups = newList;
QList<QQuickStochasticState*> states;
- states.reserve(m_groups.count());
- for (QQuickParticleGroup *g : qAsConst(m_groups))
+ states.reserve(m_groups.size());
+ for (QQuickParticleGroup *g : std::as_const(m_groups))
states << (QQuickStochasticState*)g;
if (!stateEngine)
@@ -952,7 +952,7 @@ int QQuickParticleSystem::nextSystemIndex()
QQuickParticleData* QQuickParticleSystem::newDatum(int groupId, bool respectLimits, int sysIndex)
{
- Q_ASSERT(groupId < groupData.count());//XXX shouldn't really be an assert
+ Q_ASSERT(groupId < groupData.size());//XXX shouldn't really be an assert
QQuickParticleData* ret = groupData[groupId]->newDatum(respectLimits);
if (!ret) {
@@ -999,10 +999,10 @@ void QQuickParticleSystem::finishNewDatum(QQuickParticleData *pd)
Q_ASSERT(pd);
groupData[pd->groupId]->prepareRecycler(pd);
- for (QQuickParticleAffector *a : qAsConst(m_affectors))
+ for (QQuickParticleAffector *a : std::as_const(m_affectors))
if (a && a->m_needsReset)
a->reset(pd);
- for (QQuickParticlePainter *p : qAsConst(groupData[pd->groupId]->painters))
+ for (QQuickParticlePainter *p : std::as_const(groupData[pd->groupId]->painters))
if (p)
p->load(pd);
}
@@ -1025,18 +1025,18 @@ void QQuickParticleSystem::updateCurrentTime( int currentTime )
bool oldClear = m_empty;
m_empty = true;
- for (QQuickParticleGroupData *gd : qAsConst(groupData))//Recycle all groups and see if they're out of live particles
+ for (QQuickParticleGroupData *gd : std::as_const(groupData))//Recycle all groups and see if they're out of live particles
m_empty = gd->recycle() && m_empty;
if (stateEngine)
stateEngine->updateSprites(timeInt);
- for (QQuickParticleEmitter *emitter : qAsConst(m_emitters))
+ for (QQuickParticleEmitter *emitter : std::as_const(m_emitters))
emitter->emitWindow(timeInt);
- for (QQuickParticleAffector *a : qAsConst(m_affectors))
+ for (QQuickParticleAffector *a : std::as_const(m_affectors))
a->affectSystem(dt);
for (QQuickParticleData *d : needsReset)
- for (QQuickParticlePainter *p : qAsConst(groupData[d->groupId]->painters))
+ for (QQuickParticlePainter *p : std::as_const(groupData[d->groupId]->painters))
p->reload(d);
if (oldClear != m_empty)
diff --git a/src/particles/qquicktrailemitter.cpp b/src/particles/qquicktrailemitter.cpp
index 97d1e11baf..4deb96c1e5 100644
--- a/src/particles/qquicktrailemitter.cpp
+++ b/src/particles/qquicktrailemitter.cpp
@@ -147,7 +147,7 @@ void QQuickTrailEmitter::emitWindow(int timeStamp)
int gId = m_system->groupIds[m_follow];
int gId2 = groupId();
- for (int i=0; i<m_system->groupData[gId]->data.count(); i++) {
+ for (int i=0; i<m_system->groupData[gId]->data.size(); i++) {
QQuickParticleData *d = m_system->groupData[gId]->data[i];
if (!d->stillAlive(m_system)){
m_lastEmission[i] = time; //Should only start emitting when it returns to life
diff --git a/src/plugins/qmllint/quick/quicklintplugin.cpp b/src/plugins/qmllint/quick/quicklintplugin.cpp
index fca4fecc36..c266bfbe11 100644
--- a/src/plugins/qmllint/quick/quicklintplugin.cpp
+++ b/src/plugins/qmllint/quick/quicklintplugin.cpp
@@ -132,10 +132,10 @@ void AttachedPropertyTypeValidatorPass::onRead(const QQmlSA::Element &element,
const QQmlSA::Element &readScope,
QQmlJS::SourceLocation location)
{
- Q_UNUSED(readScope)
- Q_UNUSED(propertyName)
-
- checkWarnings(element, readScope, location);
+ // If the attachment does not have such a property or method then
+ // it's either a more general error or an enum. Enums are fine.
+ if (element->hasProperty(propertyName) || element->hasMethod(propertyName))
+ checkWarnings(element, readScope, location);
}
void AttachedPropertyTypeValidatorPass::onWrite(const QQmlSA::Element &element,
diff --git a/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp b/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp
index 3a7cda534c..0bc017b3d2 100644
--- a/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp
+++ b/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp
@@ -129,7 +129,7 @@ void QPacketProtocol::send(const QByteArray &data)
qint64 QPacketProtocol::packetsAvailable() const
{
Q_D(const QPacketProtocol);
- return d->packets.count();
+ return d->packets.size();
}
/*!
@@ -223,7 +223,7 @@ void QPacketProtocol::readyToRead()
static_cast<qint64>(d->inProgressSize - d->inProgress.size())));
QByteArray toRead(bytesToRead, Qt::Uninitialized);
- if (!d->readFromDevice(toRead.data(), toRead.length())) {
+ if (!d->readFromDevice(toRead.data(), toRead.size())) {
emit error();
return;
}
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
index 7708260f8c..1fcc1e7772 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
@@ -122,7 +122,7 @@ QDataStream &operator>>(QDataStream &ds,
static inline bool isSignalPropertyName(const QString &signalName)
{
// see QmlCompiler::isSignalPropertyName
- return signalName.length() >= 3 && signalName.startsWith(QLatin1String("on")) &&
+ return signalName.size() >= 3 && signalName.startsWith(QLatin1String("on")) &&
signalName.at(2).isLetter() && signalName.at(2).isUpper();
}
@@ -259,8 +259,8 @@ void QQmlEngineDebugServiceImpl::buildObjectDump(QDataStream &message,
QObjectList children = object->children();
- int childrenCount = children.count();
- for (int ii = 0; ii < children.count(); ++ii) {
+ int childrenCount = children.size();
+ for (int ii = 0; ii < children.size(); ++ii) {
if (qobject_cast<QQmlContext*>(children[ii]))
--childrenCount;
}
@@ -269,7 +269,7 @@ void QQmlEngineDebugServiceImpl::buildObjectDump(QDataStream &message,
QList<QQmlObjectProperty> fakeProperties;
- for (int ii = 0; ii < children.count(); ++ii) {
+ for (int ii = 0; ii < children.size(); ++ii) {
QObject *child = children.at(ii);
if (qobject_cast<QQmlContext*>(child))
continue;
@@ -318,12 +318,12 @@ void QQmlEngineDebugServiceImpl::buildObjectDump(QDataStream &message,
}
}
- message << int(propertyIndexes.size() + fakeProperties.count());
+ message << int(propertyIndexes.size() + fakeProperties.size());
for (int ii = 0; ii < propertyIndexes.size(); ++ii)
message << propertyData(object, propertyIndexes.at(ii));
- for (int ii = 0; ii < fakeProperties.count(); ++ii)
+ for (int ii = 0; ii < fakeProperties.size(); ++ii)
message << fakeProperties[ii];
}
@@ -332,7 +332,7 @@ void QQmlEngineDebugServiceImpl::prepareDeferredObjects(QObject *obj)
qmlExecuteDeferred(obj);
QObjectList children = obj->children();
- for (int ii = 0; ii < children.count(); ++ii) {
+ for (int ii = 0; ii < children.size(); ++ii) {
QObject *child = children.at(ii);
prepareDeferredObjects(child);
}
@@ -343,7 +343,7 @@ void QQmlEngineDebugServiceImpl::storeObjectIds(QObject *co)
{
QQmlDebugService::idForObject(co);
QObjectList children = co->children();
- for (int ii = 0; ii < children.count(); ++ii)
+ for (int ii = 0; ii < children.size(); ++ii)
storeObjectIds(children.at(ii));
}
@@ -380,14 +380,14 @@ void QQmlEngineDebugServiceImpl::buildObjectList(QDataStream &message,
}
count = 0;
- for (int ii = 0; ii < instances.count(); ++ii) {
+ for (int ii = 0; ii < instances.size(); ++ii) {
QQmlData *data = QQmlData::get(instances.at(ii));
if (data->context == p.data())
count ++;
}
message << count;
- for (int ii = 0; ii < instances.count(); ++ii) {
+ for (int ii = 0; ii < instances.size(); ++ii) {
QQmlData *data = QQmlData::get(instances.at(ii));
if (data->context == p.data())
message << objectData(instances.at(ii));
@@ -465,9 +465,9 @@ void QQmlEngineDebugServiceImpl::processMessage(const QByteArray &message)
if (type == "LIST_ENGINES") {
rs << QByteArray("LIST_ENGINES_R");
- rs << queryId << int(m_engines.count());
+ rs << queryId << int(m_engines.size());
- for (int ii = 0; ii < m_engines.count(); ++ii) {
+ for (int ii = 0; ii < m_engines.size(); ++ii) {
QJSEngine *engine = m_engines.at(ii);
QString engineName = engine->objectName();
@@ -523,7 +523,7 @@ void QQmlEngineDebugServiceImpl::processMessage(const QByteArray &message)
const QList<QObject*> objects = objectForLocationInfo(file, lineNumber, columnNumber);
rs << QByteArray("FETCH_OBJECTS_FOR_LOCATION_R") << queryId
- << int(objects.count());
+ << int(objects.size());
for (QObject *object : objects) {
if (recurse)
@@ -755,7 +755,7 @@ bool QQmlEngineDebugServiceImpl::setMethodBody(int objectId, const QString &meth
QList<QByteArray> paramNames = metaMethod.parameterNames();
QString paramStr;
- for (int ii = 0; ii < paramNames.count(); ++ii) {
+ for (int ii = 0; ii < paramNames.size(); ++ii) {
if (ii != 0) paramStr.append(QLatin1Char(','));
paramStr.append(QString::fromUtf8(paramNames.at(ii)));
}
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp
index 7a7d2f37b4..d72c11d439 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp
@@ -40,7 +40,6 @@ private:
int m_id;
QQmlWatcher *m_watch;
QObject *m_object;
- bool m_isGadget;
int m_debugId;
QMetaProperty m_property;
@@ -52,7 +51,6 @@ QQmlWatchProxy::QQmlWatchProxy(int id, QQmlExpression *exp, int debugId, QQmlWat
m_id(id),
m_watch(parent),
m_object(nullptr),
- m_isGadget(false),
m_debugId(debugId),
m_expr(exp)
{
@@ -66,7 +64,6 @@ QQmlWatchProxy::QQmlWatchProxy(int id, QObject *object, int debugId, const QMeta
m_id(id),
m_watch(parent),
m_object(object),
- m_isGadget(typeid(*m_object) == typeid(QQmlGadgetPtrWrapper)),
m_debugId(debugId),
m_property(prop),
m_expr(nullptr)
@@ -84,8 +81,6 @@ void QQmlWatchProxy::notifyValueChanged()
QVariant v;
if (m_expr)
v = m_expr->evaluate();
- else if (m_isGadget)
- v = static_cast<QQmlGadgetPtrWrapper *>(m_object)->readOnGadget(m_property);
else
v = m_property.read(m_object);
emit m_watch->propertyChanged(m_id, m_debugId, m_property, v);
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
index b78a09f0fb..904749d7f6 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
@@ -242,7 +242,7 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int
// Only type and index are used by Qt Creator, so we keep it easy:
QVector<QV4::Heap::ExecutionContext::ContextType> scopeTypes = getScopeTypes(frameNr);
- for (int i = 0, ei = scopeTypes.count(); i != ei; ++i) {
+ for (int i = 0, ei = scopeTypes.size(); i != ei; ++i) {
int type = encodeScopeType(scopeTypes[i]);
if (type == -1)
continue;
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp
index 6ad9c6f0ac..a1d07e6654 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp
@@ -73,7 +73,7 @@ void QV4DebuggerAgent::addDebugger(QV4Debugger *debugger)
debugger->setBreakOnThrow(m_breakOnThrow);
- for (const BreakPoint &breakPoint : qAsConst(m_breakPoints))
+ for (const BreakPoint &breakPoint : std::as_const(m_breakPoints))
if (breakPoint.enabled)
debugger->addBreakPoint(breakPoint.fileName, breakPoint.lineNr, breakPoint.condition);
@@ -120,7 +120,7 @@ void QV4DebuggerAgent::resumeAll() const
int QV4DebuggerAgent::addBreakPoint(const QString &fileName, int lineNumber, bool enabled, const QString &condition)
{
if (enabled) {
- for (QV4Debugger *debugger : qAsConst(m_debuggers))
+ for (QV4Debugger *debugger : std::as_const(m_debuggers))
debugger->addBreakPoint(fileName, lineNumber, condition);
}
@@ -138,7 +138,7 @@ void QV4DebuggerAgent::removeBreakPoint(int id)
m_breakPoints.remove(id);
if (breakPoint.enabled)
- for (QV4Debugger *debugger : qAsConst(m_debuggers))
+ for (QV4Debugger *debugger : std::as_const(m_debuggers))
debugger->removeBreakPoint(breakPoint.fileName, breakPoint.lineNr);
}
@@ -155,7 +155,7 @@ void QV4DebuggerAgent::enableBreakPoint(int id, bool onoff)
return;
breakPoint.enabled = onoff;
- for (QV4Debugger *debugger : qAsConst(m_debuggers)) {
+ for (QV4Debugger *debugger : std::as_const(m_debuggers)) {
if (onoff)
debugger->addBreakPoint(breakPoint.fileName, breakPoint.lineNr, breakPoint.condition);
else
@@ -178,14 +178,14 @@ void QV4DebuggerAgent::setBreakOnThrow(bool onoff)
{
if (onoff != m_breakOnThrow) {
m_breakOnThrow = onoff;
- for (QV4Debugger *debugger : qAsConst(m_debuggers))
+ for (QV4Debugger *debugger : std::as_const(m_debuggers))
debugger->setBreakOnThrow(onoff);
}
}
void QV4DebuggerAgent::clearAllPauseRequests()
{
- for (QV4Debugger *debugger : qAsConst(m_debuggers))
+ for (QV4Debugger *debugger : std::as_const(m_debuggers))
debugger->clearPauseRequest();
}
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
index 647804d62e..6ed24f29d1 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
@@ -124,7 +124,7 @@ FrameJob::FrameJob(QV4DataCollector *collector, int frameNr) :
void FrameJob::run()
{
QVector<QV4::StackFrame> frames = collector->engine()->stackTrace(frameNr + 1);
- if (frameNr >= frames.length()) {
+ if (frameNr >= frames.size()) {
success = false;
} else {
result = collector->buildFrame(frames[frameNr], frameNr);
@@ -175,8 +175,8 @@ void ValueLookupJob::run()
QScopedPointer<QObject> scopeObject;
QV4::ExecutionEngine *engine = collector->engine();
QV4::Scope scope(engine);
- QV4::Heap::ExecutionContext *qmlContext = nullptr;
- if (engine->qmlEngine() && !engine->qmlContext()) {
+ QV4::Heap::ExecutionContext *qmlContext = engine->qmlContext();
+ if (engine->qmlEngine() && !qmlContext) {
scopeObject.reset(new QObject);
qmlContext = QV4::QmlContext::create(engine->currentContext(),
QQmlContextData::get(engine->qmlEngine()->rootContext()),
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
index 2488a10c0d..7b9d74a030 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
@@ -395,10 +395,10 @@ public:
QV4Debugger *debugger = debugService->debuggerAgent.pausedDebugger();
if (!debugger) {
const QList<QV4Debugger *> &debuggers = debugService->debuggerAgent.debuggers();
- if (debuggers.count() > 1) {
+ if (debuggers.size() > 1) {
createErrorResponse(QStringLiteral("Cannot lookup values if multiple debuggers are running and none is paused"));
return;
- } else if (debuggers.count() == 0) {
+ } else if (debuggers.size() == 0) {
createErrorResponse(QStringLiteral("No debuggers available to lookup values"));
return;
}
@@ -611,10 +611,10 @@ public:
QV4Debugger *debugger = debugService->debuggerAgent.pausedDebugger();
if (!debugger) {
const QList<QV4Debugger *> &debuggers = debugService->debuggerAgent.debuggers();
- if (debuggers.count() > 1) {
+ if (debuggers.size() > 1) {
createErrorResponse(QStringLiteral("Cannot evaluate expressions if multiple debuggers are running and none is paused"));
return;
- } else if (debuggers.count() == 0) {
+ } else if (debuggers.size() == 0) {
createErrorResponse(QStringLiteral("No debuggers available to evaluate expressions"));
return;
}
@@ -734,7 +734,7 @@ void QV4DebugServiceImpl::signalEmitted(const QString &signal)
//Normalize to Lower case.
QString signalName = signal.left(signal.indexOf(QLatin1Char('('))).toLower();
- for (const QString &signal : qAsConst(breakOnSignals)) {
+ for (const QString &signal : std::as_const(breakOnSignals)) {
if (signal == signalName) {
// TODO: pause debugger
break;
diff --git a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
index 72b9fa5f4c..fb9ec74dc6 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
@@ -60,7 +60,7 @@ void GlobalInspector::setSelectedItems(const QList<QQuickItem *> &items)
return;
QList<QObject*> objectList;
- objectList.reserve(items.count());
+ objectList.reserve(items.size());
for (QQuickItem *item : items)
objectList << item;
@@ -81,7 +81,7 @@ void GlobalInspector::sendCurrentObjects(const QList<QObject*> &objects)
ds << QByteArray(EVENT) << m_eventId++ << QByteArray(SELECT);
QList<int> debugIds;
- debugIds.reserve(objects.count());
+ debugIds.reserve(objects.size());
for (QObject *object : objects)
debugIds << QQmlDebugService::idForObject(object);
ds << debugIds;
@@ -192,7 +192,7 @@ void GlobalInspector::removeWindow(QQuickWindow *window)
void GlobalInspector::setParentWindow(QQuickWindow *window, QWindow *parentWindow)
{
- for (QmlJSDebugger::QQuickWindowInspector *inspector : qAsConst(m_windowInspectors)) {
+ for (QmlJSDebugger::QQuickWindowInspector *inspector : std::as_const(m_windowInspectors)) {
if (inspector->quickWindow() == window)
inspector->setParentWindow(parentWindow);
}
@@ -222,7 +222,7 @@ bool GlobalInspector::syncSelectedItems(const QList<QQuickItem *> &items)
selectionChanged = true;
connect(item, &QObject::destroyed, this, &GlobalInspector::removeFromSelectedItems);
m_selectedItems.append(item);
- for (QQuickWindowInspector *inspector : qAsConst(m_windowInspectors)) {
+ for (QQuickWindowInspector *inspector : std::as_const(m_windowInspectors)) {
if (inspector->isEnabled() && inspector->quickWindow() == item->window()) {
m_highlightItems.insert(item, new SelectionHighlight(titleForItem(item), item,
inspector->overlay()));
@@ -284,12 +284,12 @@ void GlobalInspector::processMessage(const QByteArray &message)
ds >> requestId >> command;
if (command == ENABLE) {
- for (QQuickWindowInspector *inspector : qAsConst(m_windowInspectors))
+ for (QQuickWindowInspector *inspector : std::as_const(m_windowInspectors))
inspector->setEnabled(true);
success = !m_windowInspectors.isEmpty();
} else if (command == DISABLE) {
setSelectedItems(QList<QQuickItem*>());
- for (QQuickWindowInspector *inspector : qAsConst(m_windowInspectors))
+ for (QQuickWindowInspector *inspector : std::as_const(m_windowInspectors))
inspector->setEnabled(false);
success = !m_windowInspectors.isEmpty();
} else if (command == SELECT) {
@@ -297,7 +297,7 @@ void GlobalInspector::processMessage(const QByteArray &message)
ds >> debugIds;
QList<QQuickItem *> selectedObjects;
- for (int debugId : qAsConst(debugIds)) {
+ for (int debugId : std::as_const(debugIds)) {
if (QQuickItem *obj =
qobject_cast<QQuickItem *>(QQmlDebugService::objectForId(debugId)))
selectedObjects << obj;
@@ -311,7 +311,7 @@ void GlobalInspector::processMessage(const QByteArray &message)
} else if (command == SHOW_APP_ON_TOP) {
bool showOnTop;
ds >> showOnTop;
- for (QmlJSDebugger::QQuickWindowInspector *inspector : qAsConst(m_windowInspectors))
+ for (QmlJSDebugger::QQuickWindowInspector *inspector : std::as_const(m_windowInspectors))
inspector->setShowAppOnTop(showOnTop);
success = !m_windowInspectors.isEmpty();
} else if (command == CREATE_OBJECT) {
diff --git a/src/plugins/qmltooling/qmldbg_inspector/inspecttool.cpp b/src/plugins/qmltooling/qmldbg_inspector/inspecttool.cpp
index 2bf043d9b9..cedb17e150 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/inspecttool.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/inspecttool.cpp
@@ -86,7 +86,7 @@ void InspectTool::touchEvent(QTouchEvent *event)
switch (event->type()) {
case QEvent::TouchBegin:
- if (touchPoints.count() == 1 && (event->touchPointStates() & QEventPoint::State::Pressed)) {
+ if (touchPoints.size() == 1 && (event->touchPointStates() & QEventPoint::State::Pressed)) {
m_mousePosition = touchPoints.first().position();
m_tapEvent = true;
} else {
@@ -94,14 +94,14 @@ void InspectTool::touchEvent(QTouchEvent *event)
}
break;
case QEvent::TouchUpdate: {
- if (touchPoints.count() > 1)
+ if (touchPoints.size() > 1)
m_tapEvent = false;
- else if ((touchPoints.count() == 1) && (event->touchPointStates() & QEventPoint::State::Updated))
+ else if ((touchPoints.size() == 1) && (event->touchPointStates() & QEventPoint::State::Updated))
m_mousePosition = touchPoints.first().position();
break;
}
case QEvent::TouchEnd: {
- if (touchPoints.count() == 1 && m_tapEvent) {
+ if (touchPoints.size() == 1 && m_tapEvent) {
m_tapEvent = false;
bool doubleTap = event->timestamp() - m_touchTimestamp
< static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval());
@@ -125,9 +125,9 @@ void InspectTool::selectNextItem()
if (m_lastClickedItem != inspector()->topVisibleItemAt(m_mousePosition))
return;
QList<QQuickItem*> items = inspector()->itemsAt(m_mousePosition);
- for (int i = 0; i < items.count(); i++) {
+ for (int i = 0; i < items.size(); i++) {
if (m_lastItem == items[i]) {
- if (i + 1 < items.count())
+ if (i + 1 < items.size())
m_lastItem = items[i+1];
else
m_lastItem = items[0];
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp
index 945fe4e985..b9ba13c9e7 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp
@@ -29,7 +29,7 @@ static QQuickItem *itemAt(QQuickItem *item, const QPointF &pos,
}
QList<QQuickItem *> children = QQuickItemPrivate::get(item)->paintOrderChildItems();
- for (int i = children.count() - 1; i >= 0; --i) {
+ for (int i = children.size() - 1; i >= 0; --i) {
QQuickItem *child = children.at(i);
if (QQuickItem *betterCandidate = itemAt(child, item->mapToItem(child, pos),
overlay))
@@ -60,7 +60,7 @@ static void collectItemsAt(QQuickItem *item, const QPointF &pos,
}
QList<QQuickItem *> children = QQuickItemPrivate::get(item)->paintOrderChildItems();
- for (int i = children.count() - 1; i >= 0; --i) {
+ for (int i = children.size() - 1; i >= 0; --i) {
QQuickItem *child = children.at(i);
collectItemsAt(child, item->mapToItem(child, pos), overlay, resultList);
}
diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
index 73a7c28b09..68dcd1add0 100644
--- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
+++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
@@ -172,7 +172,7 @@ QQmlNativeDebugConnector::QQmlNativeDebugConnector()
QQmlNativeDebugConnector::~QQmlNativeDebugConnector()
{
- for (QQmlDebugService *service : qAsConst(m_services)) {
+ for (QQmlDebugService *service : std::as_const(m_services)) {
service->stateAboutToBeChanged(QQmlDebugService::NotConnected);
service->setState(QQmlDebugService::NotConnected);
service->stateChanged(QQmlDebugService::NotConnected);
@@ -199,12 +199,12 @@ void QQmlNativeDebugConnector::addEngine(QJSEngine *engine)
Q_ASSERT(!m_engines.contains(engine));
TRACE_PROTOCOL("Add engine to connector:" << engine);
- for (QQmlDebugService *service : qAsConst(m_services))
+ for (QQmlDebugService *service : std::as_const(m_services))
service->engineAboutToBeAdded(engine);
announceObjectAvailability(QLatin1String("qmlengine"), engine, true);
- for (QQmlDebugService *service : qAsConst(m_services))
+ for (QQmlDebugService *service : std::as_const(m_services))
service->engineAdded(engine);
m_engines.append(engine);
@@ -215,12 +215,12 @@ void QQmlNativeDebugConnector::removeEngine(QJSEngine *engine)
Q_ASSERT(m_engines.contains(engine));
TRACE_PROTOCOL("Remove engine from connector:" << engine);
- for (QQmlDebugService *service : qAsConst(m_services))
+ for (QQmlDebugService *service : std::as_const(m_services))
service->engineAboutToBeRemoved(engine);
announceObjectAvailability(QLatin1String("qmlengine"), engine, false);
- for (QQmlDebugService *service : qAsConst(m_services))
+ for (QQmlDebugService *service : std::as_const(m_services))
service->engineRemoved(engine);
m_engines.removeOne(engine);
diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp
index 16f62d00d2..10d52c75ee 100644
--- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp
@@ -260,7 +260,7 @@ void NativeDebugger::signalEmitted(const QString &signal)
//Normalize to Lower case.
QString signalName = signal.left(signal.indexOf(QLatin1Char('('))).toLower();
- for (const QString &signal : qAsConst(breakOnSignals)) {
+ for (const QString &signal : std::as_const(breakOnSignals)) {
if (signal == signalName) {
// TODO: pause debugger
break;
@@ -710,7 +710,7 @@ void QQmlNativeDebugServiceImpl::engineAboutToBeRemoved(QJSEngine *engine)
void QQmlNativeDebugServiceImpl::stateAboutToBeChanged(QQmlDebugService::State state)
{
if (state == Enabled) {
- for (NativeDebugger *debugger : qAsConst(m_debuggers)) {
+ for (NativeDebugger *debugger : std::as_const(m_debuggers)) {
QV4::ExecutionEngine *engine = debugger->engine();
if (!engine->debugger())
engine->setDebugger(debugger);
@@ -734,7 +734,7 @@ void QQmlNativeDebugServiceImpl::messageReceived(const QByteArray &message)
} else if (cmd == QLatin1String("echo")) {
response.insert(QStringLiteral("result"), arguments);
} else {
- for (NativeDebugger *debugger : qAsConst(m_debuggers))
+ for (NativeDebugger *debugger : std::as_const(m_debuggers))
if (debugger)
debugger->handleCommand(&response, cmd, arguments);
}
diff --git a/src/plugins/qmltooling/qmldbg_preview/proxytranslator.cpp b/src/plugins/qmltooling/qmldbg_preview/proxytranslator.cpp
index 557d6a0082..d0004455d7 100644
--- a/src/plugins/qmltooling/qmldbg_preview/proxytranslator.cpp
+++ b/src/plugins/qmltooling/qmldbg_preview/proxytranslator.cpp
@@ -64,14 +64,14 @@ void ProxyTranslator::setLanguage(const QUrl &context, const QLocale &locale)
}
// unfortunately setUiLanguage set new translators, so do this first
- for (QQmlEngine *engine : qAsConst(m_engines))
+ for (QQmlEngine *engine : std::as_const(m_engines))
engine->setUiLanguage(locale.bcp47Name());
// make sure proxy translator is the first used translator
QCoreApplication::removeTranslator(this);
QCoreApplication::installTranslator(this);
- for (QQmlEngine *engine : qAsConst(m_engines)) {
+ for (QQmlEngine *engine : std::as_const(m_engines)) {
// have two retranslate runs to get elided warning even the same language was set
m_enable = false;
engine->retranslate();
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp
index 859f89367f..04d18b66ef 100644
--- a/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp
@@ -109,7 +109,7 @@ public:
if (s == false)
qWarning() << "disable WatchTextElides is not implemented";
watchTextElides = s;
- for (auto &&information : qAsConst(objectTranslationBindingMultiMap)) {
+ for (auto &&information : std::as_const(objectTranslationBindingMultiMap)) {
QObject *scopeObject = information.scopeObject;
int elideIndex = scopeObject->metaObject()->indexOfProperty("elide");
if (elideIndex >= 0) {
@@ -143,7 +143,7 @@ public:
QVector<QmlElement> qmlElements;
- for (auto &&information : qAsConst(objectTranslationBindingMultiMap)) {
+ for (auto &&information : std::as_const(objectTranslationBindingMultiMap)) {
QObject *scopeObject = information.scopeObject;
auto compilationUnit = information.compilationUnit;
@@ -209,7 +209,7 @@ public:
packet << Reply::TranslationIssues;
QVector<TranslationIssue> issues;
- for (auto &&information : qAsConst(objectTranslationBindingMultiMap)) {
+ for (auto &&information : std::as_const(objectTranslationBindingMultiMap)) {
if (!proxyTranslator->hasTranslation(information)) {
TranslationIssue issue;
issue.type = TranslationIssue::Type::Missing;
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
index 9f83ae8db9..3afdaa53f1 100644
--- a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
@@ -18,7 +18,7 @@ static bool isRelative(const QString &path)
return true;
if (path.at(0) == '/')
return false;
- if (path.at(0) == ':' && path.length() >= 2 && path.at(1) == '/')
+ if (path.at(0) == ':' && path.size() >= 2 && path.at(1) == '/')
return false;
#ifdef Q_OS_WIN
if (path.length() >= 2 && path.at(1) == ':')
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp
index 2acef4f781..7601c59cac 100644
--- a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp
@@ -104,7 +104,7 @@ void QQmlPreviewHandler::loadUrl(const QUrl &url)
m_component.reset(nullptr);
QQuickPixmap::purgeCache();
- const int numEngines = m_engines.count();
+ const int numEngines = m_engines.size();
if (numEngines > 1) {
emit error(QString::fromLatin1("%1 QML engines available. We cannot decide which one "
"should load the component.").arg(numEngines));
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp
index 164d01970e..819d46b124 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp
@@ -91,10 +91,10 @@ void QQmlEngineControlServiceImpl::stateChanged(State)
{
// We flush everything for any kind of state change, to avoid complicated timing issues.
QMutexLocker lock(&dataMutex);
- for (QJSEngine *engine : qAsConst(startingEngines))
+ for (QJSEngine *engine : std::as_const(startingEngines))
emit attachedToEngine(engine);
startingEngines.clear();
- for (QJSEngine *engine : qAsConst(stoppingEngines))
+ for (QJSEngine *engine : std::as_const(stoppingEngines))
emit detachedFromEngine(engine);
stoppingEngines.clear();
}
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
index 9836672b4c..be753ed10f 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
@@ -92,9 +92,9 @@ static void qQmlProfilerDataToByteArrays(const QQmlProfilerData &d,
qint64 QQmlProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
{
- while (next != data.length()) {
+ while (next != data.size()) {
const QQmlProfilerData &nextData = data.at(next);
- if (nextData.time > until || messages.length() > s_numMessagesPerBatch)
+ if (nextData.time > until || messages.size() > s_numMessagesPerBatch)
return nextData.time;
qQmlProfilerDataToByteArrays(nextData, locations, messages);
++next;
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
index 6d7edd88bd..614890a8fd 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
@@ -67,8 +67,8 @@ void QQmlProfilerServiceImpl::dataReady(QQmlAbstractProfilerAdapter *profiler)
m_startTimes.insert(0, profiler);
if (dataComplete) {
QList<QJSEngine *> enginesToRelease;
- for (QJSEngine *engine : qAsConst(m_stoppingEngines)) {
- const auto range = qAsConst(m_engineProfilers).equal_range(engine);
+ for (QJSEngine *engine : std::as_const(m_stoppingEngines)) {
+ const auto range = std::as_const(m_engineProfilers).equal_range(engine);
const auto startTimesEnd = m_startTimes.cend();
for (auto it = range.first; it != range.second; ++it) {
if (std::find(m_startTimes.cbegin(), startTimesEnd, *it) != startTimesEnd) {
@@ -78,7 +78,7 @@ void QQmlProfilerServiceImpl::dataReady(QQmlAbstractProfilerAdapter *profiler)
}
}
sendMessages();
- for (QJSEngine *engine : qAsConst(enginesToRelease)) {
+ for (QJSEngine *engine : std::as_const(enginesToRelease)) {
m_stoppingEngines.removeOne(engine);
emit detachedFromEngine(engine);
}
@@ -114,7 +114,7 @@ void QQmlProfilerServiceImpl::engineAdded(QJSEngine *engine)
if (m_globalEnabled)
startProfiling(engine, m_globalFeatures);
- const auto range = qAsConst(m_engineProfilers).equal_range(engine);
+ const auto range = std::as_const(m_engineProfilers).equal_range(engine);
for (auto it = range.first; it != range.second; ++it)
(*it)->stopWaiting();
}
@@ -126,7 +126,7 @@ void QQmlProfilerServiceImpl::engineAboutToBeRemoved(QJSEngine *engine)
QMutexLocker lock(&m_configMutex);
bool isRunning = false;
- const auto range = qAsConst(m_engineProfilers).equal_range(engine);
+ const auto range = std::as_const(m_engineProfilers).equal_range(engine);
for (auto it = range.first; it != range.second; ++it) {
QQmlAbstractProfilerAdapter *profiler = *it;
if (profiler->isRunning())
@@ -147,7 +147,7 @@ void QQmlProfilerServiceImpl::engineRemoved(QJSEngine *engine)
"QML profilers have to be removed from the engine thread");
QMutexLocker lock(&m_configMutex);
- const auto range = qAsConst(m_engineProfilers).equal_range(engine);
+ const auto range = std::as_const(m_engineProfilers).equal_range(engine);
for (auto it = range.first; it != range.second; ++it) {
QQmlAbstractProfilerAdapter *profiler = *it;
removeProfilerFromStartTimes(profiler);
@@ -172,7 +172,7 @@ void QQmlProfilerServiceImpl::addGlobalProfiler(QQmlAbstractProfilerAdapter *pro
// Global profilers are started whenever any engine profiler is started and stopped when
// all engine profilers are stopped.
quint64 features = 0;
- for (QQmlAbstractProfilerAdapter *engineProfiler : qAsConst(m_engineProfilers))
+ for (QQmlAbstractProfilerAdapter *engineProfiler : std::as_const(m_engineProfilers))
features |= engineProfiler->features();
if (features != 0)
@@ -220,7 +220,7 @@ void QQmlProfilerServiceImpl::startProfiling(QJSEngine *engine, quint64 features
d << m_timer.nsecsElapsed() << static_cast<qint32>(Event) << static_cast<qint32>(StartTrace);
bool startedAny = false;
if (engine != nullptr) {
- const auto range = qAsConst(m_engineProfilers).equal_range(engine);
+ const auto range = std::as_const(m_engineProfilers).equal_range(engine);
for (auto it = range.first; it != range.second; ++it) {
QQmlAbstractProfilerAdapter *profiler = *it;
if (!profiler->isRunning()) {
@@ -243,12 +243,12 @@ void QQmlProfilerServiceImpl::startProfiling(QJSEngine *engine, quint64 features
startedAny = true;
}
}
- for (QJSEngine *profiledEngine : qAsConst(engines))
+ for (QJSEngine *profiledEngine : std::as_const(engines))
d << idForObject(profiledEngine);
}
if (startedAny) {
- for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_globalProfilers)) {
+ for (QQmlAbstractProfilerAdapter *profiler : std::as_const(m_globalProfilers)) {
if (!profiler->isRunning())
profiler->startProfiling(features);
}
@@ -291,7 +291,7 @@ void QQmlProfilerServiceImpl::stopProfiling(QJSEngine *engine)
if (stopping.isEmpty())
return;
- for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_globalProfilers)) {
+ for (QQmlAbstractProfilerAdapter *profiler : std::as_const(m_globalProfilers)) {
if (!profiler->isRunning())
continue;
m_startTimes.insert(-1, profiler);
@@ -305,10 +305,10 @@ void QQmlProfilerServiceImpl::stopProfiling(QJSEngine *engine)
emit stopFlushTimer();
m_waitingForStop = true;
- for (QQmlAbstractProfilerAdapter *profiler : qAsConst(reporting))
+ for (QQmlAbstractProfilerAdapter *profiler : std::as_const(reporting))
profiler->reportData();
- for (QQmlAbstractProfilerAdapter *profiler : qAsConst(stopping))
+ for (QQmlAbstractProfilerAdapter *profiler : std::as_const(stopping))
profiler->stopProfiling();
}
@@ -325,7 +325,7 @@ void QQmlProfilerServiceImpl::sendMessages()
<< static_cast<qint32>(EndTrace);
QSet<QJSEngine *> seen;
- for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_startTimes)) {
+ for (QQmlAbstractProfilerAdapter *profiler : std::as_const(m_startTimes)) {
for (QMultiHash<QJSEngine *, QQmlAbstractProfilerAdapter *>::iterator i(m_engineProfilers.begin());
i != m_engineProfilers.end(); ++i) {
if (i.value() == profiler && !seen.contains(i.key())) {
@@ -345,14 +345,14 @@ void QQmlProfilerServiceImpl::sendMessages()
if (next != -1)
m_startTimes.insert(next, first);
- if (messages.length() >= QQmlAbstractProfilerAdapter::s_numMessagesPerBatch) {
+ if (messages.size() >= QQmlAbstractProfilerAdapter::s_numMessagesPerBatch) {
emit messagesToClient(name(), messages);
messages.clear();
}
}
bool stillRunning = false;
- for (const QQmlAbstractProfilerAdapter *profiler : qAsConst(m_engineProfilers)) {
+ for (const QQmlAbstractProfilerAdapter *profiler : std::as_const(m_engineProfilers)) {
if (profiler->isRunning()) {
stillRunning = true;
break;
@@ -446,21 +446,21 @@ void QQmlProfilerServiceImpl::flush()
QMutexLocker lock(&m_configMutex);
QList<QQmlAbstractProfilerAdapter *> reporting;
- for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_engineProfilers)) {
+ for (QQmlAbstractProfilerAdapter *profiler : std::as_const(m_engineProfilers)) {
if (profiler->isRunning()) {
m_startTimes.insert(-1, profiler);
reporting.append(profiler);
}
}
- for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_globalProfilers)) {
+ for (QQmlAbstractProfilerAdapter *profiler : std::as_const(m_globalProfilers)) {
if (profiler->isRunning()) {
m_startTimes.insert(-1, profiler);
reporting.append(profiler);
}
}
- for (QQmlAbstractProfilerAdapter *profiler : qAsConst(reporting))
+ for (QQmlAbstractProfilerAdapter *profiler : std::as_const(reporting))
profiler->reportData();
}
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
index 945a9bee95..1a3e17fcbc 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
@@ -38,14 +38,14 @@ qint64 QV4ProfilerAdapter::appendMemoryEvents(qint64 until, QList<QByteArray> &m
// Make it const, so that we cannot accidentally detach it.
const QVector<QV4::Profiling::MemoryAllocationProperties> &memoryData = m_memoryData;
- while (memoryData.length() > m_memoryPos && memoryData[m_memoryPos].timestamp <= until) {
+ while (memoryData.size() > m_memoryPos && memoryData[m_memoryPos].timestamp <= until) {
const QV4::Profiling::MemoryAllocationProperties &props = memoryData[m_memoryPos];
d << props.timestamp << int(MemoryAllocation) << int(props.type) << props.size;
++m_memoryPos;
messages.append(d.squeezedData());
d.clear();
}
- return memoryData.length() == m_memoryPos ? -1 : memoryData[m_memoryPos].timestamp;
+ return memoryData.size() == m_memoryPos ? -1 : memoryData[m_memoryPos].timestamp;
}
qint64 QV4ProfilerAdapter::finalizeMessages(qint64 until, QList<QByteArray> &messages,
@@ -80,9 +80,9 @@ qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &message
while (true) {
while (!m_stack.isEmpty() &&
- (m_functionCallPos == functionCallData.length() ||
+ (m_functionCallPos == functionCallData.size() ||
m_stack.top() <= functionCallData[m_functionCallPos].start)) {
- if (m_stack.top() > until || messages.length() > s_numMessagesPerBatch)
+ if (m_stack.top() > until || messages.size() > s_numMessagesPerBatch)
return finalizeMessages(until, messages, m_stack.top(), d);
appendMemoryEvents(m_stack.top(), messages, d);
@@ -90,11 +90,11 @@ qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &message
messages.append(d.squeezedData());
d.clear();
}
- while (m_functionCallPos != functionCallData.length() &&
+ while (m_functionCallPos != functionCallData.size() &&
(m_stack.empty() || functionCallData[m_functionCallPos].start < m_stack.top())) {
const QV4::Profiling::FunctionCallProperties &props =
functionCallData[m_functionCallPos];
- if (props.start > until || messages.length() > s_numMessagesPerBatch)
+ if (props.start > until || messages.size() > s_numMessagesPerBatch)
return finalizeMessages(until, messages, props.start, d);
appendMemoryEvents(props.start, messages, d);
@@ -117,7 +117,7 @@ qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &message
m_stack.push(props.end);
++m_functionCallPos;
}
- if (m_stack.empty() && m_functionCallPos == functionCallData.length())
+ if (m_stack.empty() && m_functionCallPos == functionCallData.size())
return finalizeMessages(until, messages, -1, d);
}
}
diff --git a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp
index a7fe757df6..9eba1e23a6 100644
--- a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp
+++ b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp
@@ -119,7 +119,7 @@ static void qQuickProfilerDataToByteArrays(const QQuickProfilerData &data,
qint64 QQuickProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
{
while (next < m_data.size()) {
- if (m_data[next].time <= until && messages.length() <= s_numMessagesPerBatch)
+ if (m_data[next].time <= until && messages.size() <= s_numMessagesPerBatch)
qQuickProfilerDataToByteArrays(m_data[next++], messages);
else
return m_data[next].time;
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.cpp
index 2583f005a7..9107715f28 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.cpp
@@ -442,7 +442,7 @@ void QQmlDebugServerImpl::receiveMessage()
QStringList pluginNames;
QList<float> pluginVersions;
if (clientSupportsMultiPackets) { // otherwise, disable all plugins
- const int count = m_plugins.count();
+ const int count = m_plugins.size();
pluginNames.reserve(count);
pluginVersions.reserve(count);
for (QHash<QString, QQmlDebugService *>::ConstIterator i = m_plugins.constBegin();
@@ -558,12 +558,12 @@ void QQmlDebugServerImpl::addEngine(QJSEngine *engine)
QMutexLocker locker(&m_helloMutex);
Q_ASSERT(!m_engineConditions.contains(engine));
- for (QQmlDebugService *service : qAsConst(m_plugins))
+ for (QQmlDebugService *service : std::as_const(m_plugins))
service->engineAboutToBeAdded(engine);
- m_engineConditions[engine].waitForServices(&m_helloMutex, m_plugins.count());
+ m_engineConditions[engine].waitForServices(&m_helloMutex, m_plugins.size());
- for (QQmlDebugService *service : qAsConst(m_plugins))
+ for (QQmlDebugService *service : std::as_const(m_plugins))
service->engineAdded(engine);
}
@@ -575,12 +575,12 @@ void QQmlDebugServerImpl::removeEngine(QJSEngine *engine)
QMutexLocker locker(&m_helloMutex);
Q_ASSERT(m_engineConditions.contains(engine));
- for (QQmlDebugService *service : qAsConst(m_plugins))
+ for (QQmlDebugService *service : std::as_const(m_plugins))
service->engineAboutToBeRemoved(engine);
- m_engineConditions[engine].waitForServices(&m_helloMutex, m_plugins.count());
+ m_engineConditions[engine].waitForServices(&m_helloMutex, m_plugins.size());
- for (QQmlDebugService *service : qAsConst(m_plugins))
+ for (QQmlDebugService *service : std::as_const(m_plugins))
service->engineRemoved(engine);
m_engineConditions.remove(engine);
diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp
index 7eb9cfd4a5..988a999e19 100644
--- a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp
+++ b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp
@@ -73,7 +73,7 @@ void QSGOpenVGInternalRectangleNode::setGradientStops(const QGradientStops &stop
//normalize stops
bool needsNormalization = false;
- for (const QGradientStop &stop : qAsConst(stops)) {
+ for (const QGradientStop &stop : std::as_const(stops)) {
if (stop.first < 0.0 || stop.first > 1.0) {
needsNormalization = true;
continue;
@@ -218,7 +218,7 @@ void QSGOpenVGInternalRectangleNode::render()
vgSetParameteri(m_rectanglePaint, VG_PAINT_COLOR_RAMP_PREMULTIPLIED, false);
QVector<VGfloat> stops;
- for (const QGradientStop &stop : qAsConst(m_gradientStops)) {
+ for (const QGradientStop &stop : std::as_const(m_gradientStops)) {
// offset
stops.append(stop.first);
// color
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp
index 1aac62675c..39905673ff 100644
--- a/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp
+++ b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp
@@ -81,7 +81,7 @@ void QSGOpenVGNodeVisitor::endVisit(QSGClipNode *)
vgMask(0,VG_FILL_MASK, 0, 0, VG_MAXINT, VG_MAXINT);
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
vgLoadIdentity();
- for (auto path : qAsConst(m_clipStack)) {
+ for (auto path : std::as_const(m_clipStack)) {
vgRenderToMask(path, VG_FILL_PATH, VG_INTERSECT_MASK);
}
}
diff --git a/src/qml/Qt6AndroidQmlMacros.cmake b/src/qml/Qt6AndroidQmlMacros.cmake
index 5284c3e71c..787b358975 100644
--- a/src/qml/Qt6AndroidQmlMacros.cmake
+++ b/src/qml/Qt6AndroidQmlMacros.cmake
@@ -26,18 +26,16 @@ function(_qt_internal_generate_android_qml_deployment_settings out_var target)
get_target_property(target_source_dir ${target} SOURCE_DIR)
# QML import paths
- if(NOT "${QT_QML_OUTPUT_DIRECTORY}" STREQUAL "")
- # Need to prepend the default qml module output directory to take precedence
- # over other qml import paths.
- get_target_property(native_qml_import_paths "${target}" _qt_native_qml_import_paths)
- if(native_qml_import_paths)
- list(PREPEND native_qml_import_paths "${QT_QML_OUTPUT_DIRECTORY}")
- else()
- set(native_qml_import_paths "${QT_QML_OUTPUT_DIRECTORY}")
- endif()
- set_property(TARGET "${target}" PROPERTY
- "_qt_native_qml_import_paths" "${native_qml_import_paths}")
+ _qt_internal_collect_target_qml_import_paths(qml_import_paths ${target})
+ get_target_property(native_qml_import_paths "${target}" _qt_native_qml_import_paths)
+ if(native_qml_import_paths)
+ list(PREPEND native_qml_import_paths "${qml_import_paths}")
+ else()
+ set(native_qml_import_paths "${qml_import_paths}")
endif()
+ list(REMOVE_DUPLICATES native_qml_import_paths)
+ set_property(TARGET "${target}" PROPERTY
+ _qt_native_qml_import_paths "${native_qml_import_paths}")
_qt_internal_add_android_deployment_multi_value_property(${out_var} "qml-import-paths"
${target} "_qt_native_qml_import_paths")
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index 20b8101103..f307c1f4be 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -715,16 +715,18 @@ macro(_qt_internal_genex_getoption var target property)
set(${var} "$<BOOL:$<TARGET_PROPERTY:${target},${property}>>")
endmacro()
+# Gets the Qt import paths, prepends -I, appends the values to the given import_paths_var output
+# variable.
function(_qt_internal_extend_qml_import_paths import_paths_var)
set(local_var ${${import_paths_var}})
- # prepend extra import path which is a current module's build dir: we need
- # this to ensure correct importing of QML modules when having a prefix-build
- # with QLibraryInfo::path(QLibraryInfo::QmlImportsPath) pointing to the
- # install location
- if(QT_BUILDING_QT AND QT_WILL_INSTALL)
- list(PREPEND local_var -I "${QT_BUILD_DIR}/${INSTALL_QMLDIR}")
- endif()
+ _qt_internal_get_main_qt_qml_import_paths(qt_import_paths)
+
+ # Append the paths instead of prepending them, to ensure Qt import paths are searched after
+ # any target or build dir specific import paths.
+ foreach(import_path IN LISTS qt_import_paths)
+ list(APPEND local_var -I "${import_path}")
+ endforeach()
set(${import_paths_var} ${local_var} PARENT_SCOPE)
endfunction()
@@ -780,9 +782,11 @@ function(_qt_internal_target_enable_qmllint target)
_qt_internal_extend_qml_import_paths(import_args)
+ _qt_internal_get_tool_wrapper_script_path(tool_wrapper)
set(cmd
- ${QT_TOOL_COMMAND_WRAPPER_PATH}
- ${QT_CMAKE_EXPORT_NAMESPACE}::qmllint
+ ${tool_wrapper}
+ $<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::qmllint>
+ --bare
${import_args}
${qrc_args}
${qmllint_files}
@@ -918,8 +922,10 @@ function(_qt_internal_target_enable_qmlcachegen target output_targets_var qmlcac
if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.20")
set(qmlcachegen "$<COMMAND_CONFIG:${qmlcachegen}>")
endif()
+
+ _qt_internal_get_tool_wrapper_script_path(tool_wrapper)
set(cmd
- ${QT_TOOL_COMMAND_WRAPPER_PATH}
+ ${tool_wrapper}
${qmlcachegen}
--resource-name "${qmlcache_resource_name}"
${qrc_resource_args}
@@ -1342,12 +1348,14 @@ function(_qt_internal_target_enable_qmltc target)
set(compiled_cpp "${target_binary_dir}/.qmltc/${target}/${file_name}.cpp")
get_filename_component(out_dir ${compiled_header} DIRECTORY)
+ _qt_internal_get_tool_wrapper_script_path(tool_wrapper)
add_custom_command(
OUTPUT ${compiled_header} ${compiled_cpp}
COMMAND ${CMAKE_COMMAND} -E make_directory ${out_dir}
COMMAND
- ${QT_TOOL_COMMAND_WRAPPER_PATH}
+ ${tool_wrapper}
${qmltc_executable}
+ --bare
--header "${compiled_header}"
--impl "${compiled_cpp}"
${common_args}
@@ -1598,12 +1606,18 @@ function(qt6_add_qml_plugin target)
)
endif()
+ get_target_property(install_rpath ${target} INSTALL_RPATH)
# Ignore any CMAKE_INSTALL_RPATH and set a better default RPATH on platforms
# that support it, if allowed. Projects will often set CMAKE_INSTALL_RPATH
# for executables or backing libraries, but forget about plugins. Because
# the path for QML plugins depends on their URI, it is unlikely that
# CMAKE_INSTALL_RPATH would ever be intended for use with QML plugins.
- if(NOT WIN32 AND NOT QT_NO_QML_PLUGIN_RPATH)
+ #
+ # Avoid setting INSTALL_RPATH if it was set before. This is mostly
+ # applicable for the Qml plugins built in Qt tree, that got INSTALL_RPATH
+ # from the qt_internal_add_plugin function, but also can be the case for the
+ # user Qml plugins created manually.
+ if(NOT WIN32 AND NOT QT_NO_QML_PLUGIN_RPATH AND NOT install_rpath)
# Construct a relative path from a default install location (assumed to
# be qml/target-path) to ${CMAKE_INSTALL_LIBDIR}. This would be
# applicable for Apple too (although unusual) if this is a bare install
@@ -1690,13 +1704,13 @@ function(qt6_add_qml_plugin target)
string(APPEND qt_qml_plugin_outro "} // namespace ${arg_NAMESPACE}")
endif()
- string(APPEND qt_qml_plugin_intro "extern void ${register_types_function_name}();\nQ_GHS_KEEP_REFERENCE(${register_types_function_name});")
+ string(APPEND qt_qml_plugin_intro "extern void ${register_types_function_name}();\nQ_GHS_KEEP_REFERENCE(${register_types_function_name})")
# Indenting here is deliberately different so as to make the generated
# file have sensible indenting
set(qt_qml_plugin_constructor_content
"volatile auto registration = &${register_types_function_name};
- Q_UNUSED(registration);"
+ Q_UNUSED(registration)"
)
set(generated_cpp_file
@@ -2040,6 +2054,12 @@ function(qt6_target_qml_sources target)
get_source_file_property(qml_file_singleton ${qml_file_src} QT_QML_SINGLETON_TYPE)
get_source_file_property(qml_file_internal ${qml_file_src} QT_QML_INTERNAL_TYPE)
+ if (qml_file_singleton AND qml_file_internal)
+ message(FATAL_ERROR
+ "${qml_file_src} is marked as both internal and as a "
+ "singleton, but singletons cannot be internal!")
+ endif()
+
if (NOT qml_file_versions)
set(qml_file_versions ${qml_module_files_versions})
endif()
@@ -2095,12 +2115,15 @@ function(qt6_target_qml_sources target)
else()
set(qmlcachegen_cmd "${qmlcachegen}")
endif()
+
+ _qt_internal_get_tool_wrapper_script_path(tool_wrapper)
add_custom_command(
OUTPUT ${compiled_file}
COMMAND ${CMAKE_COMMAND} -E make_directory ${out_dir}
COMMAND
- ${QT_TOOL_COMMAND_WRAPPER_PATH}
+ ${tool_wrapper}
${qmlcachegen_cmd}
+ --bare
--resource-path "${file_resource_path}"
${cachegen_args}
-o "${compiled_file}"
@@ -2226,9 +2249,19 @@ function(qt6_generate_foreign_qml_types source_target destination_qml_target)
message(FATAL_ERROR "Need target metatypes.json file")
endif()
+ get_target_property(automoc_enabled ${destination_qml_target} AUTOMOC)
+ if(NOT automoc_enabled)
+ message(FATAL_ERROR "qt6_generate_foreign_qml_types requires AUTOMOC to be enabled "
+ "on target '${destination_qml_target}'.")
+ endif()
+
set(registration_files_base ${source_target}_${destination_qml_target})
- set(additional_sources ${registration_files_base}.cpp ${registration_files_base}.h)
+ set(additional_sources
+ "${CMAKE_CURRENT_BINARY_DIR}/${registration_files_base}.cpp"
+ "${CMAKE_CURRENT_BINARY_DIR}/${registration_files_base}.h"
+ )
+ _qt_internal_get_tool_wrapper_script_path(tool_wrapper)
add_custom_command(
OUTPUT
${additional_sources}
@@ -2237,7 +2270,7 @@ function(qt6_generate_foreign_qml_types source_target destination_qml_target)
${target_metatypes_json_file}
${QT_CMAKE_EXPORT_NAMESPACE}::qmltyperegistrar
COMMAND
- ${QT_TOOL_COMMAND_WRAPPER_PATH}
+ ${tool_wrapper}
$<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::qmltyperegistrar>
"--extract"
-o ${registration_files_base}
@@ -2247,7 +2280,6 @@ function(qt6_generate_foreign_qml_types source_target destination_qml_target)
)
target_sources(${destination_qml_target} PRIVATE ${additional_sources})
- qt6_wrap_cpp(${additional_sources} TARGET ${destination_qml_target})
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
@@ -2399,6 +2431,11 @@ function(_qt_internal_qml_type_registration target)
if (TARGET ${target}Private)
list(APPEND cmd_args --private-includes)
+ else()
+ string(REGEX MATCH "Private$" privateSuffix ${target})
+ if (privateSuffix)
+ list(APPEND cmd_args --private-includes)
+ endif()
endif()
get_target_property(target_metatypes_json_file ${target} INTERFACE_QT_META_TYPES_BUILD_FILE)
@@ -2428,6 +2465,7 @@ function(_qt_internal_qml_type_registration target)
)
endif()
+ _qt_internal_get_tool_wrapper_script_path(tool_wrapper)
add_custom_command(
OUTPUT
${type_registration_cpp_file}
@@ -2438,7 +2476,7 @@ function(_qt_internal_qml_type_registration target)
${QT_CMAKE_EXPORT_NAMESPACE}::qmltyperegistrar
"$<$<BOOL:${genex_list}>:${genex_list}>"
COMMAND
- ${QT_TOOL_COMMAND_WRAPPER_PATH}
+ ${tool_wrapper}
$<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::qmltyperegistrar>
${cmd_args}
-o ${type_registration_cpp_file}
@@ -2540,6 +2578,84 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
endfunction()
endif()
+# Get Qt provided QML import paths.
+# The appending order is important. Build dirs are preferred over install dirs.
+function(_qt_internal_get_main_qt_qml_import_paths out_var)
+ set(qml_import_paths "")
+
+ # When building a qml module as part of a prefix Qt build that is not yet installed, add an
+ # extra import path which is the current module's build dir: we need
+ # this to ensure correct importing of QML modules when having a prefix-build
+ # with QLibraryInfo::path(QLibraryInfo::QmlImportsPath) pointing to the
+ # install location.
+ if(QT_BUILDING_QT AND QT_WILL_INSTALL)
+ set(build_dir_import_path "${QT_BUILD_DIR}/${INSTALL_QMLDIR}")
+ if(IS_DIRECTORY "${build_dir_import_path}")
+ list(APPEND qml_import_paths "${build_dir_import_path}")
+ endif()
+ endif()
+
+ # We could have multiple additional installation prefixes: one per Qt repository (conan).
+ # Or just extra ones, that might be needed during cross-compilation or example building.
+ # Add those that have a "qml" subdirectory.
+ # The additional prefixes have priority over the main Qt prefix, so they come first.
+ if(NOT "${_qt_additional_packages_prefix_paths}" STREQUAL "")
+ __qt_internal_prefix_paths_to_roots(
+ additional_root_paths "${_qt_additional_packages_prefix_paths}")
+ foreach(root IN ITEMS ${additional_root_paths})
+ set(candidate "${root}/${QT6_INSTALL_QML}")
+ if(IS_DIRECTORY "${candidate}")
+ list(APPEND qml_import_paths "${candidate}")
+ endif()
+ endforeach()
+ endif()
+
+ # Add the main Qt "<prefix>/qml" import path.
+ if(QT6_INSTALL_PREFIX)
+ set(main_import_path "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_QML}")
+ if(IS_DIRECTORY "${main_import_path}")
+ list(APPEND qml_import_paths "${main_import_path}")
+ endif()
+ endif()
+
+ set(${out_var} "${qml_import_paths}" PARENT_SCOPE)
+endfunction()
+
+function(_qt_internal_collect_target_qml_import_paths out_var target)
+ set(qml_import_paths "")
+ # Get custom import paths provided during qt_add_qml_module call.
+ get_target_property(qml_import_path ${target} QT_QML_IMPORT_PATH)
+ if(qml_import_path)
+ list(APPEND qml_import_paths ${qml_import_path})
+ endif()
+
+ # Facilitate self-import so we can find the qmldir file
+ get_target_property(module_out_dir ${target} QT_QML_MODULE_OUTPUT_DIRECTORY)
+ if(module_out_dir)
+ list(APPEND qml_import_paths "${module_out_dir}")
+ endif()
+
+ # Find qmldir files we copied to the build directory
+ if(NOT "${QT_QML_OUTPUT_DIRECTORY}" STREQUAL "")
+ if(EXISTS "${QT_QML_OUTPUT_DIRECTORY}")
+ list(APPEND qml_import_paths "${QT_QML_OUTPUT_DIRECTORY}")
+ endif()
+ else()
+ list(APPEND qml_import_paths "${CMAKE_CURRENT_BINARY_DIR}")
+ endif()
+
+ set(${out_var} "${qml_import_paths}" PARENT_SCOPE)
+endfunction()
+
+function(_qt_internal_collect_qml_import_paths out_var target)
+ _qt_internal_collect_target_qml_import_paths(qml_import_paths ${target})
+
+ # Add the Qt import paths last.
+ _qt_internal_get_main_qt_qml_import_paths(qt_main_import_paths)
+ list(APPEND qml_import_paths ${qt_main_import_paths})
+
+ set(${out_var} "${qml_import_paths}" PARENT_SCOPE)
+endfunction()
function(_qt_internal_scan_qml_imports target imports_file_var when_to_scan)
if(NOT "${ARGN}" STREQUAL "")
@@ -2577,29 +2693,6 @@ but this file does not exist. Possible reasons include:
")
endif()
- # Find QML import paths.
- if("${_qt_additional_packages_prefix_paths}" STREQUAL "")
- # We have one installation prefix for all Qt modules. Add the "<prefix>/qml" directory.
- set(qml_import_paths "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_QML}")
- else()
- # We have multiple installation prefixes: one per Qt repository (conan). Add those that have
- # a "qml" subdirectory.
- set(qml_import_paths)
- foreach(root IN ITEMS ${QT6_INSTALL_PREFIX} ${_qt_additional_packages_prefix_paths})
- set(candidate "${root}/${QT6_INSTALL_QML}")
- if(IS_DIRECTORY "${candidate}")
- list(APPEND qml_import_paths "${candidate}")
- endif()
- endforeach()
- endif()
-
- # Construct the -importPath arguments.
- set(import_path_arguments)
- foreach(path IN LISTS qml_import_paths)
- list(APPEND import_path_arguments -importPath ${path})
- endforeach()
-
- # Run qmlimportscanner to generate the cmake file that records the import entries
get_target_property(target_source_dir ${target} SOURCE_DIR)
get_target_property(target_binary_dir ${target} BINARY_DIR)
set(out_dir "${target_binary_dir}/.qt_plugins")
@@ -2611,28 +2704,18 @@ but this file does not exist. Possible reasons include:
-rootPath "${target_source_dir}"
-cmake-output
-output-file "${imports_file}"
- ${import_path_arguments}
)
- get_target_property(qml_import_path ${target} QT_QML_IMPORT_PATH)
- if (qml_import_path)
- list(APPEND cmd_args ${qml_import_path})
- endif()
+ _qt_internal_collect_qml_import_paths(qml_import_paths ${target})
+ list(REMOVE_DUPLICATES qml_import_paths)
- # Facilitate self-import so we can find the qmldir file
- get_target_property(module_out_dir ${target} QT_QML_MODULE_OUTPUT_DIRECTORY)
- if(module_out_dir)
- list(APPEND cmd_args "${module_out_dir}")
- endif()
+ # Construct the -importPath arguments.
+ set(import_path_arguments)
+ foreach(path IN LISTS qml_import_paths)
+ list(APPEND import_path_arguments -importPath ${path})
+ endforeach()
- # Find qmldir files we copied to the build directory
- if(NOT "${QT_QML_OUTPUT_DIRECTORY}" STREQUAL "")
- if(EXISTS "${QT_QML_OUTPUT_DIRECTORY}")
- list(APPEND cmd_args "${QT_QML_OUTPUT_DIRECTORY}")
- endif()
- else()
- list(APPEND cmd_args "${CMAKE_CURRENT_BINARY_DIR}")
- endif()
+ list(APPEND cmd_args ${import_path_arguments})
# All of the module's .qml files will be listed in one of the generated
# .qrc files, so there's no need to list the files individually. We provide
@@ -2653,8 +2736,10 @@ but this file does not exist. Possible reasons include:
set(cmd_args "@${rsp_file}")
endif()
- set(import_scanner_args ${QT_TOOL_COMMAND_WRAPPER_PATH} ${tool_path} ${cmd_args})
+ _qt_internal_get_tool_wrapper_script_path(tool_wrapper)
+ set(import_scanner_args ${tool_wrapper} ${tool_path} ${cmd_args})
+ # Run qmlimportscanner to generate the cmake file that records the import entries
if(scan_at_build_time)
add_custom_command(
OUTPUT "${imports_file}"
diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp
index 196fe7ed4a..7bb2af476c 100644
--- a/src/qml/animations/qabstractanimationjob.cpp
+++ b/src/qml/animations/qabstractanimationjob.cpp
@@ -48,11 +48,11 @@ void QQmlAnimationTimer::unsetJobTimer(QAbstractAnimationJob *animation)
QQmlAnimationTimer::~QQmlAnimationTimer()
{
- for (const auto &animation : qAsConst(animations))
+ for (const auto &animation : std::as_const(animations))
unsetJobTimer(animation);
- for (const auto &animation : qAsConst(animationsToStart))
+ for (const auto &animation : std::as_const(animationsToStart))
unsetJobTimer(animation);
- for (const auto &animation : qAsConst(runningPauseAnimations))
+ for (const auto &animation : std::as_const(runningPauseAnimations))
unsetJobTimer(animation);
}
@@ -93,7 +93,7 @@ void QQmlAnimationTimer::updateAnimationsTime(qint64 delta)
//when the CPU load is high
if (delta) {
insideTick = true;
- for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) {
+ for (currentAnimationIdx = 0; currentAnimationIdx < animations.size(); ++currentAnimationIdx) {
QAbstractAnimationJob *animation = animations.at(currentAnimationIdx);
int elapsed = animation->m_totalCurrentTime
+ (animation->direction() == QAbstractAnimationJob::Forward ? delta : -delta);
@@ -101,7 +101,7 @@ void QQmlAnimationTimer::updateAnimationsTime(qint64 delta)
}
if (animationTickDump()) {
qDebug() << "***** Dumping Animation Tree ***** ( tick:" << lastTick << "delta:" << delta << ")";
- for (int i = 0; i < animations.count(); ++i)
+ for (int i = 0; i < animations.size(); ++i)
qDebug() << animations.at(i);
}
insideTick = false;
diff --git a/src/qml/animations/qabstractanimationjob_p.h b/src/qml/animations/qabstractanimationjob_p.h
index a933f49be3..6330b01bb1 100644
--- a/src/qml/animations/qabstractanimationjob_p.h
+++ b/src/qml/animations/qabstractanimationjob_p.h
@@ -193,7 +193,7 @@ public:
void updateAnimationsTime(qint64 timeStep) override;
//useful for profiling/debugging
- int runningAnimationCount() override { return animations.count(); }
+ int runningAnimationCount() override { return animations.size(); }
bool hasStartAnimationPending() const { return startAnimationPending; }
diff --git a/src/qml/common/qqmljsfixedpoolarray_p.h b/src/qml/common/qqmljsfixedpoolarray_p.h
index 16f60c002e..e946b1ecfd 100644
--- a/src/qml/common/qqmljsfixedpoolarray_p.h
+++ b/src/qml/common/qqmljsfixedpoolarray_p.h
@@ -44,7 +44,7 @@ public:
void allocate(MemoryPool *pool, const QVector<T> &vector)
{
- count = vector.count();
+ count = vector.size();
data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T)));
if (QTypeInfo<T>::isComplex) {
@@ -58,7 +58,7 @@ public:
template <typename Container>
void allocate(MemoryPool *pool, const Container &container)
{
- count = container.count();
+ count = container.size();
data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T)));
typename Container::ConstIterator it = container.constBegin();
for (int i = 0; i < count; ++i)
diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h
index 2edb73f7b0..23c75d705f 100644
--- a/src/qml/common/qv4compileddata_p.h
+++ b/src/qml/common/qv4compileddata_p.h
@@ -222,7 +222,7 @@ struct String
qint32_le size;
static int calculateSize(const QString &str) {
- return (sizeof(String) + (str.length() + 1) * sizeof(quint16) + 7) & ~0x7;
+ return (sizeof(String) + (str.size() + 1) * sizeof(quint16) + 7) & ~0x7;
}
};
@@ -578,7 +578,7 @@ struct Binding
static QString escapedString(const QString &string)
{
QString tmp = QLatin1String("\"");
- for (int i = 0; i < string.length(); ++i) {
+ for (int i = 0; i < string.size(); ++i) {
const QChar &c = string.at(i);
switch (c.unicode()) {
case 0x08:
@@ -1047,8 +1047,8 @@ public:
InlineComponentIterator inlineComponentsEnd() const {return InlineComponentIterator(this, nInlineComponents);}
typedef TableIterator<RequiredPropertyExtraData, Object, &Object::requiredPropertyExtraDataAt> RequiredPropertyExtraDataIterator;
- RequiredPropertyExtraDataIterator requiredPropertyExtraDataBegin() const {return RequiredPropertyExtraDataIterator(this, 0); };
- RequiredPropertyExtraDataIterator requiredPropertyExtraDataEnd() const {return RequiredPropertyExtraDataIterator(this, nRequiredPropertyExtraData); };
+ RequiredPropertyExtraDataIterator requiredPropertyExtraDataBegin() const {return RequiredPropertyExtraDataIterator(this, 0); }
+ RequiredPropertyExtraDataIterator requiredPropertyExtraDataEnd() const {return RequiredPropertyExtraDataIterator(this, nRequiredPropertyExtraData); }
int namedObjectsInComponentCount() const { return nNamedObjectsInComponent; }
// ---
diff --git a/src/qml/common/qv4stringtoarrayindex_p.h b/src/qml/common/qv4stringtoarrayindex_p.h
index ba5642a27d..fc71ca7072 100644
--- a/src/qml/common/qv4stringtoarrayindex_p.h
+++ b/src/qml/common/qv4stringtoarrayindex_p.h
@@ -52,7 +52,7 @@ uint stringToArrayIndex(const T *ch, const T *end)
inline uint stringToArrayIndex(const QString &str)
{
- return stringToArrayIndex(str.constData(), str.constData() + str.length());
+ return stringToArrayIndex(str.constData(), str.constData() + str.size());
}
} // namespace QV4
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 5beeda930f..92b1d897e3 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -1391,7 +1391,7 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O
// If it's a namespace, prepend the qualifier and we'll resolve it later to the correct type.
QString currentName = qualifiedIdElement->name.toString();
if (qualifiedIdElement->next) {
- for (const QV4::CompiledData::Import* import : qAsConst(_imports))
+ for (const QV4::CompiledData::Import* import : std::as_const(_imports))
if (import->qualifierIndex != emptyStringIndex
&& stringAt(import->qualifierIndex) == currentName) {
qualifiedIdElement = qualifiedIdElement->next;
@@ -1522,7 +1522,7 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen
jsUnit = createdUnit = output.jsGenerator.generateUnit();
// enable flag if we encountered pragma Singleton
- for (Pragma *p : qAsConst(output.pragmas)) {
+ for (Pragma *p : std::as_const(output.pragmas)) {
switch (p->type) {
case Pragma::Singleton:
createdUnit->flags |= Unit::IsSingleton;
@@ -1579,7 +1579,7 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen
const unsigned int objectOffset = sizeof(QV4::CompiledData::QmlUnit) + importSize;
uint nextOffset = objectOffset + objectOffsetTableSize;
- for (Object *o : qAsConst(output.objects)) {
+ for (Object *o : std::as_const(output.objects)) {
objectOffsets.insert(o, nextOffset);
nextOffset += QV4::CompiledData::Object::calculateSizeExcludingSignalsAndEnums(o->functionCount(), o->propertyCount(), o->aliasCount(), o->enumCount(), o->signalCount(), o->bindingCount(), o->namedObjectsInComponent.size(), o->inlineComponentCount(), o->requiredPropertyExtraDataCount());
@@ -1607,7 +1607,7 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen
// write imports
char *importPtr = data + qmlUnit->offsetToImports;
- for (const QV4::CompiledData::Import *imp : qAsConst(output.imports)) {
+ for (const QV4::CompiledData::Import *imp : std::as_const(output.imports)) {
QV4::CompiledData::Import *importToWrite = reinterpret_cast<QV4::CompiledData::Import*>(importPtr);
*importToWrite = *imp;
importPtr += sizeof(QV4::CompiledData::Import);
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index c0026aba1f..bab1f026c3 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -74,8 +74,8 @@ void QV4::Compiler::StringTableGenerator::serialize(CompiledData::Unit *unit)
QV4::CompiledData::String *s = reinterpret_cast<QV4::CompiledData::String *>(stringData);
Q_ASSERT(reinterpret_cast<uintptr_t>(s) % alignof(QV4::CompiledData::String) == 0);
- Q_ASSERT(qstr.length() >= 0);
- s->size = qstr.length();
+ Q_ASSERT(qstr.size() >= 0);
+ s->size = qstr.size();
ushort *uc = reinterpret_cast<ushort *>(reinterpret_cast<char *>(s) + sizeof(*s));
qToLittleEndian<ushort>(qstr.constData(), s->size, uc);
@@ -209,7 +209,7 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorO
{
registerString(module->fileName);
registerString(module->finalUrl);
- for (Context *f : qAsConst(module->functions)) {
+ for (Context *f : std::as_const(module->functions)) {
registerString(f->name);
registerString(f->returnType);
for (int i = 0; i < f->arguments.size(); ++i) {
@@ -219,7 +219,7 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorO
for (int i = 0; i < f->locals.size(); ++i)
registerString(f->locals.at(i));
}
- for (Context *c : qAsConst(module->blocks)) {
+ for (Context *c : std::as_const(module->blocks)) {
for (int i = 0; i < c->locals.size(); ++i)
registerString(c->locals.at(i));
}
@@ -290,7 +290,7 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorO
}
CompiledData::Lookup *lookupsToWrite = reinterpret_cast<CompiledData::Lookup*>(dataPtr + unit->offsetToLookupTable);
- for (const CompiledData::Lookup &l : qAsConst(lookups))
+ for (const CompiledData::Lookup &l : std::as_const(lookups))
*lookupsToWrite++ = l;
CompiledData::RegExp *regexpTable = reinterpret_cast<CompiledData::RegExp *>(dataPtr + unit->offsetToRegexpTable);
@@ -313,12 +313,12 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorO
// write js classes and js class lookup table
quint32_le *jsClassOffsetTable = reinterpret_cast<quint32_le *>(dataPtr + unit->offsetToJSClassTable);
- for (int i = 0; i < jsClassOffsets.count(); ++i)
+ for (int i = 0; i < jsClassOffsets.size(); ++i)
jsClassOffsetTable[i] = jsClassDataOffset + jsClassOffsets.at(i);
}
- if (translations.count()) {
- memcpy(dataPtr + unit->offsetToTranslationTable, translations.constData(), translations.count() * sizeof(CompiledData::TranslationData));
+ if (translations.size()) {
+ memcpy(dataPtr + unit->offsetToTranslationTable, translations.constData(), translations.size() * sizeof(CompiledData::TranslationData));
}
{
@@ -588,7 +588,7 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
unit.offsetToBlockTable = nextOffset;
nextOffset += unit.blockTableSize * sizeof(uint);
- unit.lookupTableSize = lookups.count();
+ unit.lookupTableSize = lookups.size();
unit.offsetToLookupTable = nextOffset;
nextOffset += unit.lookupTableSize * sizeof(CompiledData::Lookup);
@@ -603,7 +603,7 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
unit.offsetToConstantTable = nextOffset;
nextOffset += unit.constantTableSize * sizeof(ReturnedValue);
- unit.jsClassTableSize = jsClassOffsets.count();
+ unit.jsClassTableSize = jsClassOffsets.size();
unit.offsetToJSClassTable = nextOffset;
nextOffset += unit.jsClassTableSize * sizeof(uint);
@@ -612,7 +612,7 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
nextOffset = static_cast<quint32>(roundUpToMultipleOf(8, nextOffset));
- unit.translationTableSize = translations.count();
+ unit.translationTableSize = translations.size();
unit.offsetToTranslationTable = nextOffset;
nextOffset += unit.translationTableSize * sizeof(CompiledData::TranslationData);
@@ -625,16 +625,16 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
nextOffset = static_cast<quint32>(roundUpToMultipleOf(8, nextOffset));
};
- reserveExportTable(module->localExportEntries.count(), &unit.localExportEntryTableSize, &unit.offsetToLocalExportEntryTable);
- reserveExportTable(module->indirectExportEntries.count(), &unit.indirectExportEntryTableSize, &unit.offsetToIndirectExportEntryTable);
- reserveExportTable(module->starExportEntries.count(), &unit.starExportEntryTableSize, &unit.offsetToStarExportEntryTable);
+ reserveExportTable(module->localExportEntries.size(), &unit.localExportEntryTableSize, &unit.offsetToLocalExportEntryTable);
+ reserveExportTable(module->indirectExportEntries.size(), &unit.indirectExportEntryTableSize, &unit.offsetToIndirectExportEntryTable);
+ reserveExportTable(module->starExportEntries.size(), &unit.starExportEntryTableSize, &unit.offsetToStarExportEntryTable);
- unit.importEntryTableSize = module->importEntries.count();
+ unit.importEntryTableSize = module->importEntries.size();
unit.offsetToImportEntryTable = nextOffset;
nextOffset += unit.importEntryTableSize * sizeof(CompiledData::ImportEntry);
nextOffset = static_cast<quint32>(roundUpToMultipleOf(8, nextOffset));
- unit.moduleRequestTableSize = module->moduleRequests.count();
+ unit.moduleRequestTableSize = module->moduleRequests.size();
unit.offsetToModuleRequestTable = nextOffset;
nextOffset += unit.moduleRequestTableSize * sizeof(uint);
nextOffset = static_cast<quint32>(roundUpToMultipleOf(8, nextOffset));
@@ -696,7 +696,7 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
if (showStats) {
qDebug() << "Generated JS unit that is" << unit.unitSize << "bytes contains:";
qDebug() << " " << functionSize << "bytes for non-code function data for" << unit.functionTableSize << "functions";
- qDebug() << " " << translations.count() * sizeof(CompiledData::TranslationData) << "bytes for" << translations.count() << "translations";
+ qDebug() << " " << translations.size() * sizeof(CompiledData::TranslationData) << "bytes for" << translations.size() << "translations";
}
return unit;
diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp
index cb32f9ad43..1d4b0bde17 100644
--- a/src/qml/compiler/qv4compilercontext.cpp
+++ b/src/qml/compiler/qv4compilercontext.cpp
@@ -147,7 +147,7 @@ Context::ResolvedName Context::resolveName(const QString &name, const QQmlJS::So
return result;
if (c->contextType == ContextType::ESModule) {
- for (int i = 0; i < c->importEntries.count(); ++i) {
+ for (int i = 0; i < c->importEntries.size(); ++i) {
if (c->importEntries.at(i).localName == name) {
result.index = i;
result.type = ResolvedName::Import;
@@ -180,7 +180,7 @@ void Context::emitBlockHeader(Codegen *codegen)
if (requiresExecutionContext) {
if (blockIndex < 0) {
codegen->module()->blocks.append(this);
- blockIndex = codegen->module()->blocks.count() - 1;
+ blockIndex = codegen->module()->blocks.size() - 1;
}
if (contextType == ContextType::Global) {
@@ -272,7 +272,7 @@ void Context::emitBlockHeader(Codegen *codegen)
codegen->referenceForName(QStringLiteral("arguments"), false).storeConsumeAccumulator();
}
- for (const Context::Member &member : qAsConst(members)) {
+ for (const Context::Member &member : std::as_const(members)) {
if (member.function) {
const int function = codegen->defineFunction(member.function->name.toString(), member.function, member.function->formals, member.function->body);
codegen->loadClosure(function);
@@ -360,8 +360,8 @@ void Context::setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator)
break;
}
- sizeOfLocalTemporalDeadZone = localsInTDZ.count();
- for (auto &member: qAsConst(localsInTDZ)) {
+ sizeOfLocalTemporalDeadZone = localsInTDZ.size();
+ for (auto &member: std::as_const(localsInTDZ)) {
member->index = locals.size();
locals.append(member.key());
}
@@ -375,9 +375,9 @@ void Context::setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator)
}
}
- sizeOfRegisterTemporalDeadZone = registersInTDZ.count();
+ sizeOfRegisterTemporalDeadZone = registersInTDZ.size();
firstTemporalDeadZoneRegister = bytecodeGenerator->currentRegister();
- for (auto &member: qAsConst(registersInTDZ))
+ for (auto &member: std::as_const(registersInTDZ))
member->index = bytecodeGenerator->newRegister();
nRegisters = bytecodeGenerator->currentRegister() - registerOffset;
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp
index 29bc3918ea..157d2896aa 100644
--- a/src/qml/compiler/qv4compilerscanfunctions.cpp
+++ b/src/qml/compiler/qv4compilerscanfunctions.cpp
@@ -308,7 +308,7 @@ bool ScanFunctions::visit(PatternElement *ast)
declarationLocation.length = ast->lastSourceLocation().end() - declarationLocation.offset;
}
- for (const auto &name : qAsConst(names)) {
+ for (const auto &name : std::as_const(names)) {
if (_context->isStrict && (name.id == QLatin1String("eval") || name.id == QLatin1String("arguments")))
_cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Variable name may not be eval or arguments in strict mode"));
checkName(QStringView(name.id), ast->identifierToken);
@@ -721,7 +721,7 @@ void ScanFunctions::calcEscapingVariables()
{
Module *m = _cg->_module;
- for (Context *inner : qAsConst(m->contextMap)) {
+ for (Context *inner : std::as_const(m->contextMap)) {
if (inner->usesArgumentsObject != Context::ArgumentsObjectUsed)
continue;
if (inner->contextType != ContextType::Block && !inner->isArrowFunction)
@@ -733,7 +733,7 @@ void ScanFunctions::calcEscapingVariables()
c->usesArgumentsObject = Context::ArgumentsObjectUsed;
inner->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
}
- for (Context *inner : qAsConst(m->contextMap)) {
+ for (Context *inner : std::as_const(m->contextMap)) {
if (!inner->parent || inner->usesArgumentsObject == Context::ArgumentsObjectUnknown)
inner->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
if (inner->usesArgumentsObject == Context::ArgumentsObjectUsed) {
@@ -746,7 +746,7 @@ void ScanFunctions::calcEscapingVariables()
}
}
- for (Context *c : qAsConst(m->contextMap)) {
+ for (Context *c : std::as_const(m->contextMap)) {
if (c->contextType != ContextType::ESModule)
continue;
for (const auto &entry: c->exportEntries) {
@@ -757,8 +757,8 @@ void ScanFunctions::calcEscapingVariables()
break;
}
- for (Context *inner : qAsConst(m->contextMap)) {
- for (const QString &var : qAsConst(inner->usedVariables)) {
+ for (Context *inner : std::as_const(m->contextMap)) {
+ for (const QString &var : std::as_const(inner->usedVariables)) {
Context *c = inner;
while (c) {
Context *current = c;
@@ -820,7 +820,7 @@ void ScanFunctions::calcEscapingVariables()
c->innerFunctionAccessesThis |= innerFunctionAccessesThis;
}
}
- for (Context *c : qAsConst(m->contextMap)) {
+ for (Context *c : std::as_const(m->contextMap)) {
if (c->innerFunctionAccessesThis) {
// add an escaping 'this' variable
c->addLocalVar(QStringLiteral("this"), Context::VariableDefinition, VariableScope::Let);
@@ -846,7 +846,7 @@ void ScanFunctions::calcEscapingVariables()
c->requiresExecutionContext = true;
c->argumentsCanEscape = true;
} else {
- for (const auto &m : qAsConst(c->members)) {
+ for (const auto &m : std::as_const(c->members)) {
if (m.isLexicallyScoped()) {
c->requiresExecutionContext = true;
break;
@@ -861,13 +861,13 @@ void ScanFunctions::calcEscapingVariables()
mIt->canEscape = true;
}
const QLatin1String exprForOn("expression for on");
- if (c->contextType == ContextType::Binding && c->name.length() > exprForOn.size() &&
+ if (c->contextType == ContextType::Binding && c->name.size() > exprForOn.size() &&
c->name.startsWith(exprForOn) && c->name.at(exprForOn.size()).isUpper())
// we don't really need this for bindings, but we do for signal handlers, and in this case,
// we don't know if the code is a signal handler or not.
c->requiresExecutionContext = true;
if (c->allVarsEscape) {
- for (const auto &m : qAsConst(c->members))
+ for (const auto &m : std::as_const(c->members))
m.canEscape = true;
}
}
@@ -875,7 +875,7 @@ void ScanFunctions::calcEscapingVariables()
static const bool showEscapingVars = qEnvironmentVariableIsSet("QV4_SHOW_ESCAPING_VARS");
if (showEscapingVars) {
qDebug() << "==== escaping variables ====";
- for (Context *c : qAsConst(m->contextMap)) {
+ for (Context *c : std::as_const(m->contextMap)) {
qDebug() << "Context" << c << c->name << "requiresExecutionContext" << c->requiresExecutionContext << "isStrict" << c->isStrict;
qDebug() << " isArrowFunction" << c->isArrowFunction << "innerFunctionAccessesThis" << c->innerFunctionAccessesThis;
qDebug() << " parent:" << c->parent;
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index c7fdec1a4d..75408fd348 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -503,7 +503,7 @@ void dumpBytecode(const char *bytecode, int len, int nLocals, int nFormals, int
const QVector<CompiledData::CodeOffsetToLine> &lineNumberMapping = QVector<CompiledData::CodeOffsetToLine>());
inline void dumpBytecode(const QByteArray &bytecode, int nLocals, int nFormals, int startLine = 1,
const QVector<CompiledData::CodeOffsetToLine> &lineNumberMapping = QVector<CompiledData::CodeOffsetToLine>()) {
- dumpBytecode(bytecode.constData(), bytecode.length(), nLocals, nFormals, startLine, lineNumberMapping);
+ dumpBytecode(bytecode.constData(), bytecode.size(), nLocals, nFormals, startLine, lineNumberMapping);
}
union Instr
diff --git a/src/qml/debugger/qqmlconfigurabledebugservice_p.h b/src/qml/debugger/qqmlconfigurabledebugservice_p.h
index 8451f4e800..ce911c5baf 100644
--- a/src/qml/debugger/qqmlconfigurabledebugservice_p.h
+++ b/src/qml/debugger/qqmlconfigurabledebugservice_p.h
@@ -37,7 +37,7 @@ protected:
{
QMutexLocker lock(&m_configMutex);
m_waitingForConfiguration = false;
- for (QJSEngine *engine : qAsConst(m_waitingEngines))
+ for (QJSEngine *engine : std::as_const(m_waitingEngines))
Q_EMIT Base::attachedToEngine(engine);
m_waitingEngines.clear();
}
diff --git a/src/qml/debugger/qqmldebugconnector.cpp b/src/qml/debugger/qqmldebugconnector.cpp
index add0396228..0b66a29e18 100644
--- a/src/qml/debugger/qqmldebugconnector.cpp
+++ b/src/qml/debugger/qqmldebugconnector.cpp
@@ -95,7 +95,7 @@ QQmlDebugConnector *QQmlDebugConnector::instance()
int connectorEnd = params->arguments.indexOf(QLatin1Char(','), connectorBegin);
if (connectorEnd == -1)
- connectorEnd = params->arguments.length();
+ connectorEnd = params->arguments.size();
params->instance = loadQQmlDebugConnector(params->arguments.mid(
connectorBegin,
diff --git a/src/qml/doc/snippets/qmltc/tst_qmltc_examples.cpp b/src/qml/doc/snippets/qmltc/tst_qmltc_examples.cpp
index c933adfcaf..f82b9f6d39 100644
--- a/src/qml/doc/snippets/qmltc/tst_qmltc_examples.cpp
+++ b/src/qml/doc/snippets/qmltc/tst_qmltc_examples.cpp
@@ -162,7 +162,7 @@ void tst_qmltc_examples::helloWorld()
QVERIFY(!documentationCode.isEmpty());
auto begin = generatedCode.cbegin();
- for (const QString &existingString : qAsConst(documentationCode)) {
+ for (const QString &existingString : std::as_const(documentationCode)) {
auto pos = std::find(begin, generatedCode.cend(), existingString);
QVERIFY2(pos != generatedCode.cend(), qPrintable(u"Could not find: " + existingString));
begin = std::next(pos);
diff --git a/src/qml/doc/src/cmake/cmake-properties.qdoc b/src/qml/doc/src/cmake/cmake-properties.qdoc
index 0b8d2c9367..98858ca6d1 100644
--- a/src/qml/doc/src/cmake/cmake-properties.qdoc
+++ b/src/qml/doc/src/cmake/cmake-properties.qdoc
@@ -13,7 +13,7 @@ CMake source file properties:
/*!
-\page cmake-source-file-property-QT_QML_INTERNAL_TYPE.html
+\page cmake-source-file-property-qt-qml-internal-type.html
\ingroup cmake-source-file-properties-qtqml
\title QT_QML_INTERNAL_TYPE
@@ -30,7 +30,7 @@ Set this property to \c TRUE to indicate that the \c{.qml} file provides an inte
/*!
-\page cmake-source-file-property-QT_QML_SINGLETON_TYPE.html
+\page cmake-source-file-property-qt-qml-singleton-type.html
\ingroup cmake-source-file-properties-qtqml
\title QT_QML_SINGLETON_TYPE
@@ -53,7 +53,7 @@ how to set the \c QT_QML_SINGLETON_TYPE property.
/*!
-\page cmake-source-file-property-QT_QML_SKIP_CACHEGEN.html
+\page cmake-source-file-property-qt-qml-skip-cachegen.html
\ingroup cmake-source-file-properties-qtqml
\title QT_QML_SKIP_CACHEGEN
@@ -72,7 +72,7 @@ The file will still be added to the \c target as a resource in uncompiled form
/*!
-\page cmake-source-file-property-QT_QML_SKIP_QMLDIR_ENTRY.html
+\page cmake-source-file-property-qt-qml-skip-qmldir-entry.html
\ingroup cmake-source-file-properties-qtqml
\title QT_QML_SKIP_QMLDIR_ENTRY
@@ -91,7 +91,7 @@ the \c{.qml} file from being added as a type to the QML module's typeinfo file
/*!
-\page cmake-source-file-property-QT_QML_SKIP_QMLLINT.html
+\page cmake-source-file-property-qt-qml-skip-qmllint.html
\ingroup cmake-source-file-properties-qtqml
\title QT_QML_SKIP_QMLLINT
@@ -109,7 +109,7 @@ Set this property to \c TRUE to prevent the file from being included in
/*!
-\page cmake-source-file-property-QT_QML_SOURCE_TYPENAME.html
+\page cmake-source-file-property-qt-qml-source-typename.html
\ingroup cmake-source-file-properties-qtqml
\title QT_QML_SOURCE_TYPENAME
@@ -126,7 +126,7 @@ Use this property to override the \c QML type name provided by this file.
/*!
-\page cmake-source-file-property-QT_QML_SOURCE_VERSIONS.html
+\page cmake-source-file-property-qt-qml-source-versions.html
\ingroup cmake-source-file-properties-qtqml
\title QT_QML_SOURCE_VERSIONS
@@ -145,7 +145,7 @@ version after the \c{.0} release, specify those versions using this property.
/*!
-\page cmake-source-file-property-QT_QMLTC_FILE_BASENAME.html
+\page cmake-source-file-property-qt-qmltc-file-basename.html
\ingroup cmake-source-file-properties-qtqml
\title QT_QMLTC_FILE_BASENAME
@@ -163,7 +163,7 @@ conflicting file names.
*/
/*!
-\page cmake-source-file-property-QT_QML_SKIP_TYPE_COMPILER.html
+\page cmake-source-file-property-qt-qml-skip-type-compiler.html
\ingroup cmake-source-file-properties-qtqml
\title QT_QML_SKIP_TYPE_COMPILER
diff --git a/src/qml/doc/src/cmake/cmake-variables.qdoc b/src/qml/doc/src/cmake/cmake-variables.qdoc
index 15f73f074e..574b24e970 100644
--- a/src/qml/doc/src/cmake/cmake-variables.qdoc
+++ b/src/qml/doc/src/cmake/cmake-variables.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page cmake-variable-QT_QML_OUTPUT_DIRECTORY.html
+\page cmake-variable-qt-qml-output-directory.html
\ingroup cmake-variables-qtqml
\title QT_QML_OUTPUT_DIRECTORY
diff --git a/src/qml/doc/src/cmake/qt_add_qml_module.qdoc b/src/qml/doc/src/cmake/qt_add_qml_module.qdoc
index 20c343a1bd..e20876fede 100644
--- a/src/qml/doc/src/cmake/qt_add_qml_module.qdoc
+++ b/src/qml/doc/src/cmake/qt_add_qml_module.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_add_qml_module.html
+\page qt-add-qml-module.html
\ingroup cmake-commands-qtqml
\title qt_add_qml_module
@@ -364,8 +364,12 @@ been created. When \c NO_CREATE_PLUGIN_TARGET is given, \c PLUGIN_TARGET must
also be provided to explicitly name the plugin target.
Every QML module must define a \c URI. It should be specified in dotted URI
-notation, such as \c{QtQuick.Layouts}. It must not contain anything other than
-alphanumeric or dot characters. Other QML modules may use this name in
+notation, such as \c{QtQuick.Layouts}. Each segment must be a well-formed
+ECMAScript Identifier Name. This means, for example, the segments
+must not start with a number and they must not contain \e{-} (minus)
+characters. As the \c URI will be translated into directory names, you
+should restrict it to alphanumeric characters of the latin alphabet,
+underscores, and dots. Other QML modules may use this name in
\l{qtqml-syntax-imports.html}{import statements} to import the module. The
\c URI will be used in the \c module line of the generated
\l{Module Definition qmldir Files}{qmldir} file. The \c URI is also used to
diff --git a/src/qml/doc/src/cmake/qt_add_qml_plugin.qdoc b/src/qml/doc/src/cmake/qt_add_qml_plugin.qdoc
index cb98406a9d..2ce744559c 100644
--- a/src/qml/doc/src/cmake/qt_add_qml_plugin.qdoc
+++ b/src/qml/doc/src/cmake/qt_add_qml_plugin.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_add_qml_plugin.html
+\page qt-add-qml-plugin.html
\ingroup cmake-commands-qtqml
\title qt_add_qml_plugin
diff --git a/src/qml/doc/src/cmake/qt_deploy_qml_imports.qdoc b/src/qml/doc/src/cmake/qt_deploy_qml_imports.qdoc
index 92da84733e..cc3c61863c 100644
--- a/src/qml/doc/src/cmake/qt_deploy_qml_imports.qdoc
+++ b/src/qml/doc/src/cmake/qt_deploy_qml_imports.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_deploy_qml_imports.html
+\page qt-deploy-qml-imports.html
\ingroup cmake-commands-qtqml
\title qt_deploy_qml_imports
@@ -18,7 +18,7 @@ project.
\preliminarycmakecommand
-\include cmake-qml-qt-finalize-target-warning.cmake
+\include cmake-qml-qt-finalize-target-warning.qdocinc
\section1 Synopsis
diff --git a/src/qml/doc/src/cmake/qt_generate_deploy_qml_app_script.qdoc b/src/qml/doc/src/cmake/qt_generate_deploy_qml_app_script.qdoc
index 493a4fc029..fc78baddcd 100644
--- a/src/qml/doc/src/cmake/qt_generate_deploy_qml_app_script.qdoc
+++ b/src/qml/doc/src/cmake/qt_generate_deploy_qml_app_script.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_generate_deploy_qml_app_script.html
+\page qt-generate-deploy-qml-app-script.html
\ingroup cmake-commands-qtqml
\title qt_generate_deploy_qml_app_script
@@ -15,7 +15,7 @@
\cmakecommandsince 6.3
\preliminarycmakecommand
-\include cmake-qml-qt-finalize-target-warning.cmake
+\include cmake-qml-qt-finalize-target-warning.qdocinc
\section1 Synopsis
diff --git a/src/qml/doc/src/cmake/qt_generate_foreign_qml_types.qdoc b/src/qml/doc/src/cmake/qt_generate_foreign_qml_types.qdoc
index 856f0fe2b1..9bd412d36d 100644
--- a/src/qml/doc/src/cmake/qt_generate_foreign_qml_types.qdoc
+++ b/src/qml/doc/src/cmake/qt_generate_foreign_qml_types.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_generate_foreign_qml_types.html
+\page qt-generate-foreign-qml-types.html
\ingroup cmake-commands-qtqml
\title qt_generate_foreign_qml_types
@@ -67,4 +67,13 @@ the \c QML_ELEMENT macro).
The effect is equivalent to using \c QML_FOREIGN with custom structs in the QML library to expose
the types.
+
+\note In order to implement custom behavior, such as exposing an existing
+singleton instance with its own life cycle to QML, you should add custom types
+to your QML library (mylib_declarative in the above example). In turn, you
+should omit the \l QML_ELEMENT and similar macros from the original C++ classes
+so that qt_generate_foreign_qml_types() does not generate more QML integration
+structs for them. The QML macros, as well as any singleton factory functions,
+can be added to the structs that contain the \l QML_FOREIGN.
+
*/
diff --git a/src/qml/doc/src/cmake/qt_import_qml_plugins.qdoc b/src/qml/doc/src/cmake/qt_import_qml_plugins.qdoc
index b45e47ce55..8d6b32f903 100644
--- a/src/qml/doc/src/cmake/qt_import_qml_plugins.qdoc
+++ b/src/qml/doc/src/cmake/qt_import_qml_plugins.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_import_qml_plugins.html
+\page qt-import-qml-plugins.html
\ingroup cmake-commands-qtqml
\title qt_import_qml_plugins
diff --git a/src/qml/doc/src/cmake/qt_query_qml_module.qdoc b/src/qml/doc/src/cmake/qt_query_qml_module.qdoc
index 50996745c8..44d0a7f8da 100644
--- a/src/qml/doc/src/cmake/qt_query_qml_module.qdoc
+++ b/src/qml/doc/src/cmake/qt_query_qml_module.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_query_qml_module.html
+\page qt-query-qml-module.html
\ingroup cmake-commands-qtqml
\title qt_query_qml_module
diff --git a/src/qml/doc/src/cmake/qt_target_compile_qml_to_cpp.qdoc b/src/qml/doc/src/cmake/qt_target_compile_qml_to_cpp.qdoc
index d989c80fcf..0ef6e421ed 100644
--- a/src/qml/doc/src/cmake/qt_target_compile_qml_to_cpp.qdoc
+++ b/src/qml/doc/src/cmake/qt_target_compile_qml_to_cpp.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_target_compile_qml_to_cpp.html
+\page qt-target-compile-qml-to-cpp.html
\ingroup cmake-commands-qtqml
\title qt_target_compile_qml_to_cpp
diff --git a/src/qml/doc/src/cmake/qt_target_qml_sources.qdoc b/src/qml/doc/src/cmake/qt_target_qml_sources.qdoc
index 126c9767a0..35854d4b95 100644
--- a/src/qml/doc/src/cmake/qt_target_qml_sources.qdoc
+++ b/src/qml/doc/src/cmake/qt_target_qml_sources.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\page qt_target_qml_sources.html
+\page qt-target-qml-sources.html
\ingroup cmake-commands-qtqml
\title qt_target_qml_sources
diff --git a/src/qml/doc/src/cppintegration/definetypes.qdoc b/src/qml/doc/src/cppintegration/definetypes.qdoc
index 5799fda87e..ac1c751bf2 100644
--- a/src/qml/doc/src/cppintegration/definetypes.qdoc
+++ b/src/qml/doc/src/cppintegration/definetypes.qdoc
@@ -77,15 +77,18 @@ Types to QML} explains, the properties, methods and signals of any
QObject-derived class are accessible from QML code.
To register a QObject-derived class as an instantiable QML object type, add
-\c QML_ELEMENT or \c QML_NAMED_ELEMENT(<name>) to the class declaration and
+\c QML_ELEMENT or \c QML_NAMED_ELEMENT(<name>) to the class declaration. You
+also need to make adjustments in the build system. For qmake, add
\c {CONFIG += qmltypes}, a \c {QML_IMPORT_NAME}, and a
-\c QML_IMPORT_MAJOR_VERSION to your project file. This will register the class
-into the type namespace under the given major version, using either the class
-name or an explicitly given name as QML type name. The minor version(s) will
-be derived from any revisions attached to properties, methods, or signals. The
-default minor version is \c 0. You can explicitly restrict the type to be
-available only from specific minor versions by adding the
-\c QML_ADDED_IN_MINOR_VERSION() macro to the class declaration. Clients can
+\c QML_IMPORT_MAJOR_VERSION to your project file. For CMake, the file containing
+the class should be part of a target set-up with
+\l{qt_add_qml_module}{qt_add_qml_module()}.
+This will register the class into the type namespace under the given major version,
+using either the class name or an explicitly given name as QML type name. The
+minor version(s) will be derived from any revisions attached to properties,
+methods, or signals. The default minor version is \c 0. You can explicitly
+restrict the type to be available only from specific minor versions by adding
+the \c QML_ADDED_IN_MINOR_VERSION() macro to the class declaration. Clients can
import suitable versions of the namespace in order to use the type.
For example, suppose there is a \c Message class with \c author and
@@ -107,26 +110,52 @@ This type can be registered by adding an appropriate type namespace and version
number to the project file. For example, to make the type available in the
\c com.mycompany.messaging namespace with version 1.0:
-\code
-CONFIG += qmltypes
-QML_IMPORT_NAME = com.mycompany.messaging
-QML_IMPORT_MAJOR_VERSION = 1
-\endcode
+\if defined(onlinedocs)
+ \tab {build-qt-app}{tab-cmake}{CMake}{selected}
+ \tab {build-qt-app}{tab-qmake}{qmake}{}
+ \tabcontent {tab-cmake}
+ \else
+ \section3 Using CMake
+\endif
+ \badcode
+ qt_add_qml_module(messaging
+ URI com.mycompany.messaging
+ VERSION 1.0
+ SOURCES
+ message.cpp message.h
+ )
+ \endcode
+\if defined(onlinedocs)
+ \endtabcontent
+ \tabcontent {tab-qmake}
+\else
+ \section3 Using QMake
+\endif
+ \code
+ CONFIG += qmltypes
+ QML_IMPORT_NAME = com.mycompany.messaging
+ QML_IMPORT_MAJOR_VERSION = 1
+ \endcode
+
+ If the header the class is declared in is not accessible from your project's
+ include path, you may have to amend the include path so that the generated
+ registration code can be compiled.
+
+ \code
+ INCLUDEPATH += com/mycompany/messaging
+ \endcode
+\if defined(onlinedocs)
+ \endtabcontent
+\endif
-If the header the class is declared in is not accessible from your project's
-include path, you may have to amend the include path so that the generated
-registration code can be compiled:
-\code
-INCLUDEPATH += com/mycompany/messaging
-\endcode
The type can be used in an \l{qtqml-syntax-basics.html#object-declarations}
{object declaration} from QML, and its properties can be read and written to,
as per the example below:
\qml
-import com.mycompany.messaging 1.0
+import com.mycompany.messaging
Message {
author: "Amelie"
diff --git a/src/qml/doc/src/includes/cmake-qml-qt-finalize-target-warning.cmake b/src/qml/doc/src/includes/cmake-qml-qt-finalize-target-warning.qdocinc
index d3c7383d2e..9152726398 100644
--- a/src/qml/doc/src/includes/cmake-qml-qt-finalize-target-warning.cmake
+++ b/src/qml/doc/src/includes/cmake-qml-qt-finalize-target-warning.qdocinc
@@ -1,3 +1,6 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
\warning If you are using a CMake version lower than 3.19, make sure that you
pass the \c MANUAL_FINALIZATION option to
\l{qt_add_executable}{qt6_add_executable()}, and then call
diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc
index 89b52131d9..005bd0be94 100644
--- a/src/qml/doc/src/qmlfunctions.qdoc
+++ b/src/qml/doc/src/qmlfunctions.qdoc
@@ -173,7 +173,9 @@
\c{T *create(QQmlEngine *, QJSEngine *)} when the type is first accessed.
If both do exist and are accessible, the default constructor is preferred.
If there is no default constructor and no factory function the singleton is
- inaccessible.
+ inaccessible. The QML engine generally assumes ownership of the singleton and
+ will delete it when the engine itself is destroyed. You can prevent this by
+ calling QJSEngine::setObjectOwnership() on the singleton.
In order to declare a default-constructible class as singleton, all you have
to do is add \l QML_SINGLETON:
@@ -260,7 +262,7 @@
// Initialize this using myObject where you would previously
// call qmlRegisterSingletonInstance().
- static MySingleton *s_singletonInstance = nullptr;
+ inline static MySingleton *s_singletonInstance = nullptr;
static MySingleton *create(QQmlEngine *, QJSEngine *engine)
{
@@ -284,7 +286,7 @@
}
private:
- static QJSEngine *s_engine = nullptr;
+ inline static QJSEngine *s_engine = nullptr;
};
\endcode
diff --git a/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc b/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc
index 80dabe45b9..58e2027e1c 100644
--- a/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc
@@ -29,8 +29,12 @@ The type name has the following requirements:
This document is then automatically recognized by the engine as a definition of
a QML type. Additionally, a type defined in this manner is automatically made
-available to other QML files within the same directory as the engine searches
-within the immediate directory when resolving QML type names.
+available to other QML files within the same local directory as the engine
+searches within the immediate directory when resolving QML type names.
+
+\note The QML engine does not automatically search remote directories this way.
+You have to add a qmldir file if your documents are loaded over the network. See
+\l{Importing QML Document Directories}.
\section2 Custom QML Type Definition
@@ -251,14 +255,14 @@ The same declaration can also be given for C++-defined types. See
\section2 ComponentBehavior
With this pragma you can restrict components defined in this file to only
-create objects within the context of the same file. This holds for inline
+create objects within their original context. This holds for inline
components as well as Component elements explicitly or implicitly created
-as properties. If a component is bound to a file context, you can safely
+as properties. If a component is bound to its context, you can safely
use IDs from the rest of the file within the component. Otherwise, the
engine and the QML tooling cannot know in advance what type, if any, such
IDs will resolve to at run time.
-In order to bind the components to the file scope specify the \c{Bound}
+In order to bind the components to their context specify the \c{Bound}
argument:
\qml
@@ -268,7 +272,7 @@ pragma ComponentBehavior: Bound
The default is \c{Unbound}. You can also specify it explicitly. In a
future version of Qt the default will change to \c{Bound}.
-Delegate components bound to the file context don't receive their own
+Delegate components bound to their context don't receive their own
private contexts on instantiation. This means that model data can only
be passed via \l{Required Properties}{required properties} in this case.
Passing model data via context properties will not work. This concerns
diff --git a/src/qml/doc/src/qmllanguageref/modules/identifiedmodules.qdoc b/src/qml/doc/src/qmllanguageref/modules/identifiedmodules.qdoc
index 6e8751af70..93461f1ed7 100644
--- a/src/qml/doc/src/qmllanguageref/modules/identifiedmodules.qdoc
+++ b/src/qml/doc/src/qmllanguageref/modules/identifiedmodules.qdoc
@@ -20,6 +20,12 @@ Identified modules must be installed into the
\l{qtqml-syntax-imports.html#qml-import-path}{import path} in order to be found
by the QML engine.
+Syntactically, each dot-separated segment of the URI must be a well-formed
+ECMAScript Identifier Name. This means, for example, the segments must not start
+with a number and they must not contain \e{-} (minus) characters. As the URI
+will be translated into directory names, you should restrict it to alphanumeric
+characters of the latin alphabet, underscores, and dots.
+
\section1 Locally Installed Identified Modules
A directory of QML and/or C++ files can be shared as an identified module if it
@@ -147,7 +153,6 @@ An identified module has several restrictions upon it:
\li the module must register its types into the module identifier type
namespace
\li the module may not register types into any other module's namespace
-\li clients must specify a version when importing the module
\endlist
For example, if an identified module is installed into
@@ -164,10 +169,9 @@ module com.example.CustomUi
\endcode
Clients will then be able to import the above module with the following import
-statement (assuming that the module registers types into version 1.0 of its
-namespace):
+statement:
\qml
-import com.example.CustomUi 1.0
+import com.example.CustomUi
\endqml
*/
diff --git a/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc b/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc
index c6d5e1446b..ac82d8136e 100644
--- a/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc
+++ b/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc
@@ -419,7 +419,7 @@ documentation on this, no further action is needed. qmltyperegistrar will
automatically generate the \c .qmltypes files.
Example:
-If your module is in \c /tmp/imports/My/Module, a file caled \c plugins.qmltypes
+If your module is in \c /tmp/imports/My/Module, a file called \c plugins.qmltypes
should be generated alongside the actual plugin binary.
Add the line
diff --git a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
index c37fb81401..fca702a278 100644
--- a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
+++ b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
@@ -38,6 +38,14 @@ plugins. Library plugins should limit themselves to registering types, as
any manipulation of the engine's root context may cause conflicts or other
issues in the library user's code.
+\note When using the CMake \l qt_add_qml_module API, a plugin will be generated
+automatically for you. It will take care of type registration.
+You only need to write a custom plugin if you have special
+requirements, such as registering custom image
+providers. In that case, pass
+\l{NO_GENERATE_PLUGIN_SOURCE} to the \c qt_add_qml_module
+call to disable the generation of the default plugin.
+
The linker might erroneously remove the generated type registration
function as an optimization. You can prevent that by declaring a synthetic
volatile pointer to the function somewhere in your code. If your module is
diff --git a/src/qml/doc/src/qmllanguageref/syntax/directoryimports.qdoc b/src/qml/doc/src/qmllanguageref/syntax/directoryimports.qdoc
index 37298c8caf..7126033431 100644
--- a/src/qml/doc/src/qmllanguageref/syntax/directoryimports.qdoc
+++ b/src/qml/doc/src/qmllanguageref/syntax/directoryimports.qdoc
@@ -85,6 +85,11 @@ a file system path.
A directory of QML files can also be imported from a remote location if the
directory contains a directory listing \c qmldir file.
+\note This also holds for the implicit import of the directory a QML document
+resides in. If your QML documents are loaded from a remote location, you need
+to add qmldir files even if they don't contain any explicit directory import
+statements. Otherwise your QML documents won't see each other.
+
For example, if the \c myapp directory in the previous example was hosted at
"http://www.my-example-server.com", and the \c mycomponents directory
contained a \c qmldir file defined as follows:
diff --git a/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc b/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc
index a6158b14af..6e6088049c 100644
--- a/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc
+++ b/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc
@@ -12,12 +12,10 @@ resources and component directories are used within a QML document. The types
which may be used within a document depends on which modules, resources and
directories are imported by the document.
-\section2 Import Types
-
There are three different types of imports. Each import type has a slightly
different syntax, and different semantics apply to different import types.
-\section3 Module (Namespace) Imports
+\section2 Module (Namespace) Imports
The most common type of import is a module import. Clients can import
\l{qtqml-modules-identifiedmodules.html}{QML modules} which register QML object
@@ -112,7 +110,7 @@ Rectangle {
In this case, the engine will emit an error and refuse to load the file.
-\section4 C++ Module Imports
+\section3 C++ Module Imports
Usually, C++ types are declared using the QML_ELEMENT and QML_NAMED_ELEMENT()
macros and registered via the build system using QML_IMPORT_NAME and
@@ -122,7 +120,7 @@ module that can be imported to access the types.
This is most common in client applications which define their own QML object
types in C++.
-\section4 Importing into a Qualified Local Namespace
+\section3 Importing into a Qualified Local Namespace
The \c import statement may optionally use the \c as keyword to specify that
the types should be imported into a particular document-local namespace. If a
@@ -172,7 +170,7 @@ way that multiple modules can be imported into the global namespace. For example
\snippet qml/imports/merged-named-imports.qml imports
-\section3 Directory Imports
+\section2 Directory Imports
A directory which contains QML documents may also be imported directly in a
QML document. This provides a simple way for QML types to be segmented into
@@ -198,7 +196,7 @@ section about \l{Importing into a Qualified Local Namespace}.
For more information about directory imports, please see the in-depth
documentation about \l{qtqml-syntax-directoryimports.html}{directory imports}.
-\section3 JavaScript Resource Imports
+\section2 JavaScript Resource Imports
JavaScript resources may be imported directly in a QML document. Every
JavaScript resource must have an identifier by which it is accessed.
@@ -211,7 +209,7 @@ import "<JavaScriptFile>" as <Identifier>
Note that the \c <Identifier> must be unique within a QML document, unlike the
local namespace qualifier which can be applied to module imports.
-\section4 JavaScript Resources from Modules
+\section3 JavaScript Resources from Modules
Javascript files can be provided by modules, by adding identifier
definitions to the \c qmldir file which specifies the module.
@@ -254,7 +252,7 @@ Item {
}
\endqml
-\section4 Further Information
+\section3 Further Information
For more information about JavaScript resources, please see the documentation
about \l{qtqml-javascript-resources.html}
diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
index bbc5aae0f0..60e90217f4 100644
--- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
@@ -32,6 +32,7 @@ The set of QML object-type attribute types is as follows:
These attributes are discussed in detail below.
\section2 The \e id Attribute
+\keyword QML.id
Every QML object type has exactly one \e id attribute. This attribute is
provided by the language itself, and cannot be redefined or overridden by any
diff --git a/src/qml/doc/src/qmllanguageref/typesystem/valuetypes.qdoc b/src/qml/doc/src/qmllanguageref/typesystem/valuetypes.qdoc
index ef10620422..e497d5d5c8 100644
--- a/src/qml/doc/src/qmllanguageref/typesystem/valuetypes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/typesystem/valuetypes.qdoc
@@ -40,7 +40,7 @@ the client to import the module which provides them.
All of the value types listed below may be used as a \c property type in a QML
document, with the following exceptions:
\list
- \li \c list must be used in conjunction with a QML object type
+ \li \c list must be used in conjunction with an object or value type as element
\li \c enumeration cannot be used directly as the enumeration must be defined by a registered QML object type
\endlist
@@ -285,16 +285,7 @@ property is only invoked when the property is reassigned to a different object v
The \c list type refers to a list of QML objects or values.
- A list value can be accessed in a similar way to a JavaScript array:
-
- \list
- \li Values are assigned using the \c[] square bracket syntax with comma-separated values
- \li The \c length property provides the number of items in the list
- \li Values in the list are accessed using the \c [index] syntax
- \endlist
-
- Values can be dynamically added to the list by using the \c push method,
- as if it were a JavaScript Array
+ Properties of type \c list are empty by default.
A \c list can store QML objects or \l{QML Value Types}{value type} values.
@@ -311,7 +302,7 @@ property is only invoked when the property is reassigned to a different object v
can be assigned to and used as follows:
\qml
- import QtQuick 2.0
+ import QtQuick
Item {
width: 100; height: 100
@@ -335,7 +326,7 @@ property is only invoked when the property is reassigned to a different object v
If the list only contains one object, the square brackets may be omitted:
\qml
- import QtQuick 2.0
+ import QtQuick
Item {
width: 100; height: 100
@@ -343,17 +334,38 @@ property is only invoked when the property is reassigned to a different object v
}
\endqml
- Objects and values in a list can be replaced with the \c{[]} operator, just
- like entries of JavaScript arrays. You can also use \c{push()} to append
- entries, or you can set the \c length property of the list to truncate or
- extend it. You can not automatically extend the list by assigning to an
- index currently out of range, though. Furthermore, if you insert \c null
- values into a list of objects, those are converted to \c nullptr entries in
+ You can also declare your own list properties in QML:
+
+ \qml
+ import QtQml
+
+ QtObject {
+ property list<int> intList: [1, 2, 3, 4]
+ property list<QtObject> objectList
+ }
+ \endqml
+
+ Lists can be used much like JavaScript arrays. For example:
+
+ \list
+ \li Values are assigned using the \c[] square bracket syntax with comma-separated values
+ \li The \c length property provides the number of items in the list
+ \li Values in the list are accessed using the \c [index] syntax
+ \li You can use \c{push()} to append entries
+ \li You can set the \c length property of the list to truncate or extend it.
+ \endlist
+
+ However, you can \e{not} automatically extend the list by assigning to an
+ index currently out of range. Furthermore, if you insert \c null values
+ into a list of objects, those are converted to \c nullptr entries in
the underlying QQmlListProperty.
- A list of value types is different from a JavaScript array in one important
- aspect: Growing it by setting its length does not produce undefined entries,
- but rather default-constructed instances of the value type.
+ A list of value types is different from a JavaScript array in one further
+ important aspect: Growing it by setting its length does not produce undefined
+ entries, but rather default-constructed instances of the value type.
+
+ Similarly, growing a list of object types this way produces null entries,
+ rather than undefined entries.
This value type is provided by the QML language.
@@ -461,6 +473,36 @@ property is only invoked when the property is reassigned to a different object v
*/
/*!
+ \qmlvaluetype variant
+ \ingroup qmlvaluetypes
+ \brief a generic property type.
+
+ The \c variant type is the same as the \c var type. Use \c var instead.
+
+ \sa {QML Value Types}
+*/
+
+/*!
+ \qmlvaluetype void
+ \ingroup qmlvaluetypes
+ \brief The empty value type.
+
+ The \c void type is exclusively used to type-annotate JavaScript functions
+ returning \c undefined. For example:
+
+ \qml
+ function doThings() : void { console.log("hello") }
+ \endqml
+
+ This is to help tooling analyze calls to such functions and compile them and
+ their callers to C++.
+
+ You cannot declare \c void properties in QML.
+
+ \sa {QML Value Types}
+*/
+
+/*!
\qmlvaluetype enumeration
\ingroup qmlvaluetypes
\brief a named enumeration value.
diff --git a/src/qml/doc/src/qmltypereference.qdoc b/src/qml/doc/src/qmltypereference.qdoc
index a89f89f9f7..da9d08d4e6 100644
--- a/src/qml/doc/src/qmltypereference.qdoc
+++ b/src/qml/doc/src/qmltypereference.qdoc
@@ -60,8 +60,7 @@ provided:
/*!
\qmlvaluetype date
-\ingroup qtqmlvaluetypes
-\ingroup qtquickvaluetypes
+\ingroup qmlvaluetypes
\brief a date value.
The \c date type refers to a date value, including the time of the day.
@@ -130,7 +129,7 @@ is automatically converted into a QPointF value.
\qmlvaluetype size
\ingroup qtqmlvaluetypes
\ingroup qtquickvaluetypes
-\brief a value with width and height attributes
+\brief a value with width and height attributes.
The \c size type refers to a value with has \c width and \c height attributes.
diff --git a/src/qml/doc/src/qtqml.qdoc b/src/qml/doc/src/qtqml.qdoc
index 9d0a0e67a8..2da6a8c9e0 100644
--- a/src/qml/doc/src/qtqml.qdoc
+++ b/src/qml/doc/src/qtqml.qdoc
@@ -128,6 +128,20 @@ the QML code to interact with C++ code.
\endlist
\endomit
+\section1 Licenses and Attributions
+
+Qt QML is available under commercial licenses from \l{The Qt Company}.
+In addition, it is available under free software licenses. Since Qt 5.4,
+these free software licenses are
+\l{GNU Lesser General Public License, version 3}, or
+the \l{GNU General Public License, version 2}.
+See \l{Qt Licensing} for further details.
+
+Furthermore Qt QML in Qt \QtVersion may contain third party
+modules under following permissive licenses:
+
+\generatelist{groupsbymodule attributions-qtqml}
+
\section1 Related Articles and Guides
Further information for writing QML applications:
@@ -146,30 +160,11 @@ Further information for writing QML applications:
results
\endlist
-\section1 Examples
-
-\list
- \li \l {Qt QML Examples} {Examples}
-\endlist
-
-\section2 Reference
+\section1 Reference
\list
\li \l {Qt QML C++ Classes} {C++ Classes}
\li \l {Qt QML QML Types} {QML Types}
+ \li \l {Qt QML Examples} {Examples}
\endlist
-
-\section1 Licenses and Attributions
-
-Qt QML is available under commercial licenses from \l{The Qt Company}.
-In addition, it is available under free software licenses. Since Qt 5.4,
-these free software licenses are
-\l{GNU Lesser General Public License, version 3}, or
-the \l{GNU General Public License, version 2}.
-See \l{Qt Licensing} for further details.
-
-Furthermore Qt QML in Qt \QtVersion may contain third party
-modules under following permissive licenses:
-
-\generatelist{groupsbymodule attributions-qtqml}
*/
diff --git a/src/qml/jit/qv4baselinejit_p.h b/src/qml/jit/qv4baselinejit_p.h
index 99cdcaa0fc..537a493127 100644
--- a/src/qml/jit/qv4baselinejit_p.h
+++ b/src/qml/jit/qv4baselinejit_p.h
@@ -34,7 +34,7 @@ class BaselineJIT final: public Moth::ByteCodeHandler
{
public:
BaselineJIT(QV4::Function *);
- virtual ~BaselineJIT() Q_DECL_OVERRIDE;
+ ~BaselineJIT() override;
void generate();
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp
index f82c2cba26..7363703544 100644
--- a/src/qml/jsapi/qjsengine.cpp
+++ b/src/qml/jsapi/qjsengine.cpp
@@ -829,7 +829,7 @@ static bool convertString(const QString &string, QMetaType metaType, void *ptr)
{
// have a string based value without engine. Do conversion manually
if (metaType == QMetaType::fromType<bool>()) {
- *reinterpret_cast<bool*>(ptr) = string.length() != 0;
+ *reinterpret_cast<bool*>(ptr) = string.size() != 0;
return true;
}
if (metaType == QMetaType::fromType<QString>()) {
diff --git a/src/qml/jsapi/qjsmanagedvalue.cpp b/src/qml/jsapi/qjsmanagedvalue.cpp
index 8b2f367304..0bb01f1835 100644
--- a/src/qml/jsapi/qjsmanagedvalue.cpp
+++ b/src/qml/jsapi/qjsmanagedvalue.cpp
@@ -958,7 +958,7 @@ QJSValue QJSManagedValue::call(const QJSValueList &arguments) const
QV4::ExecutionEngine *engine = f->engine();
QV4::Scope scope(engine);
- QV4::JSCallArguments jsCallData(scope, arguments.length());
+ QV4::JSCallArguments jsCallData(scope, arguments.size());
*jsCallData.thisObject = engine->globalObject;
int i = 0;
for (const QJSValue &arg : arguments) {
@@ -997,7 +997,7 @@ QJSValue QJSManagedValue::callWithInstance(const QJSValue &instance,
}
QV4::Scope scope(engine);
- QV4::JSCallArguments jsCallData(scope, arguments.length());
+ QV4::JSCallArguments jsCallData(scope, arguments.size());
*jsCallData.thisObject = QJSValuePrivate::convertToReturnedValue(engine, instance);
int i = 0;
for (const QJSValue &arg : arguments) {
@@ -1030,7 +1030,7 @@ QJSValue QJSManagedValue::callAsConstructor(const QJSValueList &arguments) const
QV4::ExecutionEngine *engine = f->engine();
QV4::Scope scope(engine);
- QV4::JSCallArguments jsCallData(scope, arguments.length());
+ QV4::JSCallArguments jsCallData(scope, arguments.size());
int i = 0;
for (const QJSValue &arg : arguments) {
if (Q_UNLIKELY(!QJSValuePrivate::checkEngine(engine, arg))) {
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 388cc1a21a..ea0381e886 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -106,6 +106,16 @@
integers.append(jsArray.property(i).toInt());
}
\endcode
+
+ \section2 Converting to JSON
+
+ It's possible to convert a QJSValue to a JSON type. For example,
+ to convert to an array, use \l QJSEngine::fromScriptValue():
+
+ \code
+ const QJsonValue jsonValue = engine.fromScriptValue<QJsonValue>(jsValue);
+ const QJsonArray jsonArray = jsonValue.toArray();
+ \endcode
*/
/*!
@@ -490,7 +500,7 @@ double QJSValue::toNumber() const
bool QJSValue::toBool() const
{
if (const QString *string = QJSValuePrivate::asQString(this))
- return string->length() > 0;
+ return string->size() > 0;
return caughtResult<bool>(this, &QV4::Value::toBoolean);
}
@@ -664,7 +674,7 @@ QJSValue QJSValue::call(const QJSValueList &args) const
Q_ASSERT(engine);
Scope scope(engine);
- JSCallArguments jsCallData(scope, args.length());
+ JSCallArguments jsCallData(scope, args.size());
*jsCallData.thisObject = engine->globalObject;
for (int i = 0; i < args.size(); ++i) {
if (!QJSValuePrivate::checkEngine(engine, args.at(i))) {
diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h
index 4edfe2a763..dc17ea4e54 100644
--- a/src/qml/jsruntime/qv4argumentsobject_p.h
+++ b/src/qml/jsruntime/qv4argumentsobject_p.h
@@ -30,7 +30,7 @@ namespace Heap {
Member(class, NoMark, quint64, mapped)
DECLARE_HEAP_OBJECT(ArgumentsObject, Object) {
- DECLARE_MARKOBJECTS(ArgumentsObject);
+ DECLARE_MARKOBJECTS(ArgumentsObject)
enum {
LengthPropertyIndex = 0,
SymbolIteratorPropertyIndex = 1,
diff --git a/src/qml/jsruntime/qv4arraybuffer_p.h b/src/qml/jsruntime/qv4arraybuffer_p.h
index cc322b3f01..b955618cbe 100644
--- a/src/qml/jsruntime/qv4arraybuffer_p.h
+++ b/src/qml/jsruntime/qv4arraybuffer_p.h
@@ -60,7 +60,10 @@ private:
return *reinterpret_cast<QArrayDataPointer<char> *>(&arrayDataPointerStorage);
}
- std::aligned_storage_t<sizeof(QArrayDataPointer<char>), alignof(QArrayDataPointer<char>)>
+ template <typename T>
+ struct storage_t { alignas(T) unsigned char data[sizeof(T)]; };
+
+ storage_t<QArrayDataPointer<char>>
arrayDataPointerStorage;
bool isShared;
};
diff --git a/src/qml/jsruntime/qv4arrayiterator_p.h b/src/qml/jsruntime/qv4arrayiterator_p.h
index 2682dc79d0..ff00f99bea 100644
--- a/src/qml/jsruntime/qv4arrayiterator_p.h
+++ b/src/qml/jsruntime/qv4arrayiterator_p.h
@@ -33,7 +33,7 @@ namespace Heap {
Member(class, NoMark, quint32, nextIndex)
DECLARE_HEAP_OBJECT(ArrayIteratorObject, Object) {
- DECLARE_MARKOBJECTS(ArrayIteratorObject);
+ DECLARE_MARKOBJECTS(ArrayIteratorObject)
void init(Object *obj, QV4::ExecutionEngine *engine)
{
Object::init();
diff --git a/src/qml/jsruntime/qv4compilationunitmapper.cpp b/src/qml/jsruntime/qv4compilationunitmapper.cpp
index 0479b8b8f1..61b0f1d497 100644
--- a/src/qml/jsruntime/qv4compilationunitmapper.cpp
+++ b/src/qml/jsruntime/qv4compilationunitmapper.cpp
@@ -29,6 +29,11 @@ public:
s_staticUnits.insert(file, staticUnit);
}
+ void remove(const QString &file)
+ {
+ s_staticUnits.remove(file);
+ }
+
private:
QMutexLocker<QMutex> m_lock;
@@ -69,4 +74,10 @@ CompiledData::Unit *CompilationUnitMapper::get(
return data;
}
+void CompilationUnitMapper::invalidate(const QString &cacheFilePath)
+{
+ StaticUnitCache cache;
+ cache.remove(cacheFilePath);
+}
+
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4compilationunitmapper_p.h b/src/qml/jsruntime/qv4compilationunitmapper_p.h
index 0d3ec4eeee..07952be62c 100644
--- a/src/qml/jsruntime/qv4compilationunitmapper_p.h
+++ b/src/qml/jsruntime/qv4compilationunitmapper_p.h
@@ -33,6 +33,7 @@ public:
CompiledData::Unit *get(
const QString &cacheFilePath, const QDateTime &sourceTimeStamp, QString *errorString);
+ static void invalidate(const QString &cacheFilePath);
private:
CompiledData::Unit *open(
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 66f06ff96a..82a9472223 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -29,7 +29,7 @@ namespace Heap {
Member(class, Pointer, Object *, activation)
DECLARE_HEAP_OBJECT(ExecutionContext, Base) {
- DECLARE_MARKOBJECTS(ExecutionContext);
+ DECLARE_MARKOBJECTS(ExecutionContext)
enum ContextType {
Type_GlobalContext = 0x1,
@@ -68,7 +68,7 @@ Q_STATIC_ASSERT(offsetof(ExecutionContextData, activation) == offsetof(Execution
Member(class, ValueArray, ValueArray, locals)
DECLARE_HEAP_OBJECT(CallContext, ExecutionContext) {
- DECLARE_MARKOBJECTS(CallContext);
+ DECLARE_MARKOBJECTS(CallContext)
void init()
{
diff --git a/src/qml/jsruntime/qv4dataview_p.h b/src/qml/jsruntime/qv4dataview_p.h
index 73f31d8f8c..ab2e1e589a 100644
--- a/src/qml/jsruntime/qv4dataview_p.h
+++ b/src/qml/jsruntime/qv4dataview_p.h
@@ -33,7 +33,7 @@ struct DataViewCtor : FunctionObject {
Member(class, NoMark, uint, byteOffset)
DECLARE_HEAP_OBJECT(DataView, Object) {
- DECLARE_MARKOBJECTS(DataView);
+ DECLARE_MARKOBJECTS(DataView)
void init() { Object::init(); }
};
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 769b8c161a..1fb6d92183 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -343,7 +343,7 @@ static inline double ParseString(const QString &s, double localTZA)
};
const QChar *ch = s.constData();
- const QChar *end = ch + s.length();
+ const QChar *end = ch + s.size();
uint format = Year;
int current = 0;
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 17cea99fd8..30924dd76d 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -324,6 +324,9 @@ void ExecutionEngine::initializeStaticMembers()
#elif defined(Q_OS_ANDROID)
// In experiments, it started crashing at 1059.
s_maxCallDepth = 1000;
+#elif defined(Q_OS_WIN)
+ // We've seen crashes around 750.
+ s_maxCallDepth = 640;
#else
s_maxCallDepth = 1234;
#endif
@@ -391,12 +394,15 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
}
}
+ // We allocate guard pages around our stacks.
+ const size_t guardPages = 2 * WTF::pageSize();
+
memoryManager = new QV4::MemoryManager(this);
// reserve space for the JS stack
// we allow it to grow to a bit more than m_maxJSStackSize, as we can overshoot due to ScopedValues
// allocated outside of JIT'ed methods.
*jsStack = WTF::PageAllocation::allocate(
- s_maxJSStackSize + 256*1024, WTF::OSAllocator::JSVMStackPages,
+ s_maxJSStackSize + 256*1024 + guardPages, WTF::OSAllocator::JSVMStackPages,
/* writable */ true, /* executable */ false, /* includesGuardPages */ true);
jsStackBase = (Value *)jsStack->base();
#ifdef V4_USE_VALGRIND
@@ -405,9 +411,9 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
jsStackTop = jsStackBase;
- *gcStack = WTF::PageAllocation::allocate(s_maxGCStackSize, WTF::OSAllocator::JSVMStackPages,
- /* writable */ true, /* executable */ false,
- /* includesGuardPages */ true);
+ *gcStack = WTF::PageAllocation::allocate(
+ s_maxGCStackSize + guardPages, WTF::OSAllocator::JSVMStackPages,
+ /* writable */ true, /* executable */ false, /* includesGuardPages */ true);
exceptionValue = jsAlloca(1);
*exceptionValue = Encode::undefined();
@@ -949,13 +955,13 @@ Heap::Object *ExecutionEngine::newObject(Heap::InternalClass *internalClass)
Heap::String *ExecutionEngine::newString(const QString &s)
{
- return memoryManager->allocWithStringData<String>(s.length() * sizeof(QChar), s);
+ return memoryManager->allocWithStringData<String>(s.size() * sizeof(QChar), s);
}
Heap::String *ExecutionEngine::newIdentifier(const QString &text)
{
Scope scope(this);
- ScopedString s(scope, memoryManager->allocWithStringData<String>(text.length() * sizeof(QChar), text));
+ ScopedString s(scope, memoryManager->allocWithStringData<String>(text.size() * sizeof(QChar), text));
s->toPropertyKey();
return s->d();
}
@@ -1511,6 +1517,12 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, QMet
if (metaType == QMetaType::fromType<bool>())
return QVariant(value.toBoolean());
+ if (metaType == QMetaType::fromType<double>())
+ return QVariant(value.toNumber());
+
+ if (metaType == QMetaType::fromType<float>())
+ return QVariant(float(value.toNumber()));
+
if (metaType == QMetaType::fromType<QJsonValue>())
return QVariant::fromValue(QV4::JsonObject::toJsonValue(value));
@@ -1842,23 +1854,17 @@ QV4::ReturnedValue ExecutionEngine::fromData(
// directly against QList<QObject*>?
const QList<QObject *> &list = *(const QList<QObject *>*)ptr;
QV4::ScopedArrayObject a(scope, newArrayObject());
- a->arrayReserve(list.count());
+ a->arrayReserve(list.size());
QV4::ScopedValue v(scope);
- for (int ii = 0; ii < list.count(); ++ii)
+ for (int ii = 0; ii < list.size(); ++ii)
a->arrayPut(ii, (v = QV4::QObjectWrapper::wrap(this, list.at(ii))));
- a->setArrayLengthUnchecked(list.count());
+ a->setArrayLengthUnchecked(list.size());
return a.asReturnedValue();
} else if (auto flags = metaType.flags(); flags & QMetaType::PointerToQObject) {
- QV4::ReturnedValue ret = QV4::QObjectWrapper::wrap(this, *reinterpret_cast<QObject* const *>(ptr));
- if (!flags.testFlag(QMetaType::IsConst))
- return ret;
- QV4::ScopedValue v(scope, ret);
- if (auto obj = v->as<Object>()) {
- obj->setInternalClass(obj->internalClass()->cryopreserved());
- return obj->asReturnedValue();
- } else {
- return ret;
- }
+ if (flags.testFlag(QMetaType::IsConst))
+ return QV4::QObjectWrapper::wrapConst(this, *reinterpret_cast<QObject* const *>(ptr));
+ else
+ return QV4::QObjectWrapper::wrap(this, *reinterpret_cast<QObject* const *>(ptr));
}
bool succeeded = false;
@@ -1981,6 +1987,25 @@ int ExecutionEngine::maxGCStackSize() const
return s_maxGCStackSize;
}
+/*!
+ \internal
+ Returns \a length converted to int if its safe to
+ pass to \c Scope::alloc.
+ Otherwise it throws a RangeError, and returns 0.
+ */
+int ExecutionEngine::safeForAllocLength(qint64 len64)
+{
+ if (len64 < 0ll || len64 > qint64(std::numeric_limits<int>::max())) {
+ throwRangeError(QStringLiteral("Invalid array length."));
+ return 0;
+ }
+ if (len64 > qint64(this->jsStackLimit - this->jsStackTop)) {
+ throwRangeError(QStringLiteral("Array too large for apply()."));
+ return 0;
+ }
+ return len64;
+}
+
ReturnedValue ExecutionEngine::global()
{
return globalObject->asReturnedValue();
@@ -2252,7 +2277,7 @@ int ExecutionEngine::consoleCountHelper(const QString &file, quint16 line, quint
void ExecutionEngine::setExtensionData(int index, Deletable *data)
{
- if (m_extensionData.count() <= index)
+ if (m_extensionData.size() <= index)
m_extensionData.resize(index + 1);
if (m_extensionData.at(index))
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index d00495eff0..c6b97273e3 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -650,6 +650,7 @@ public:
int maxGCStackSize() const;
bool checkStackLimits();
+ int safeForAllocLength(qint64 len64);
bool canJIT(Function *f = nullptr)
{
@@ -702,7 +703,7 @@ public:
void setExtensionData(int, Deletable *);
Deletable *extensionData(int index) const
{
- if (index < m_extensionData.count())
+ if (index < m_extensionData.size())
return m_extensionData[index];
else
return nullptr;
@@ -736,6 +737,9 @@ public:
QV4::ExecutionContext *ctxt, int argc, const QV4::Value *argv);
private:
+ template<int Frames>
+ friend struct ExecutionEngineCallDepthRecorder;
+
QV4::ReturnedValue fromData(QMetaType type, const void *ptr, const QVariant *variant = nullptr);
static void initializeStaticMembers();
@@ -772,12 +776,15 @@ private:
#define CHECK_STACK_LIMITS(v4) if ((v4)->checkStackLimits()) return Encode::undefined(); \
ExecutionEngineCallDepthRecorder _executionEngineCallDepthRecorder(v4);
+template<int Frames = 1>
struct ExecutionEngineCallDepthRecorder
{
ExecutionEngine *ee;
- ExecutionEngineCallDepthRecorder(ExecutionEngine *e): ee(e) { ++ee->callDepth; }
- ~ExecutionEngineCallDepthRecorder() { --ee->callDepth; }
+ ExecutionEngineCallDepthRecorder(ExecutionEngine *e): ee(e) { ee->callDepth += Frames; }
+ ~ExecutionEngineCallDepthRecorder() { ee->callDepth -= Frames; }
+
+ bool hasOverflow() const { return ee->callDepth >= ExecutionEngine::s_maxCallDepth; }
};
inline bool ExecutionEngine::checkStackLimits()
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp
index f3adadc887..eb449ba293 100644
--- a/src/qml/jsruntime/qv4errorobject.cpp
+++ b/src/qml/jsruntime/qv4errorobject.cpp
@@ -120,7 +120,7 @@ ReturnedValue ErrorObject::method_get_stack(const FunctionObject *b, const Value
return v4->throwTypeError();
if (!This->d()->stack) {
QString trace;
- for (int i = 0; i < This->d()->stackTrace->count(); ++i) {
+ for (int i = 0; i < This->d()->stackTrace->size(); ++i) {
if (i > 0)
trace += QLatin1Char('\n');
const StackFrame &frame = This->d()->stackTrace->at(i);
diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h
index c8ebe11f30..3d9069b587 100644
--- a/src/qml/jsruntime/qv4errorobject_p.h
+++ b/src/qml/jsruntime/qv4errorobject_p.h
@@ -31,7 +31,7 @@ namespace Heap {
Member(class, Pointer, String *, stack)
DECLARE_HEAP_OBJECT(ErrorObject, Object) {
- DECLARE_MARKOBJECTS(ErrorObject);
+ DECLARE_MARKOBJECTS(ErrorObject)
enum ErrorType {
Error,
EvalError,
diff --git a/src/qml/jsruntime/qv4executableallocator.cpp b/src/qml/jsruntime/qv4executableallocator.cpp
index f8b005e914..5a63230858 100644
--- a/src/qml/jsruntime/qv4executableallocator.cpp
+++ b/src/qml/jsruntime/qv4executableallocator.cpp
@@ -125,7 +125,7 @@ ExecutableAllocator::ExecutableAllocator()
ExecutableAllocator::~ExecutableAllocator()
{
- for (ChunkOfPages *chunk : qAsConst(chunks)) {
+ for (ChunkOfPages *chunk : std::as_const(chunks)) {
for (Allocation *allocation = chunk->firstAllocation; allocation; allocation = allocation->next)
if (!allocation->free)
allocation->invalidate();
diff --git a/src/qml/jsruntime/qv4executableallocator_p.h b/src/qml/jsruntime/qv4executableallocator_p.h
index d6551599e7..7fd8a10cdb 100644
--- a/src/qml/jsruntime/qv4executableallocator_p.h
+++ b/src/qml/jsruntime/qv4executableallocator_p.h
@@ -79,8 +79,8 @@ public:
};
// for debugging / unit-testing
- int freeAllocationCount() const { return freeAllocations.count(); }
- int chunkCount() const { return chunks.count(); }
+ int freeAllocationCount() const { return freeAllocations.size(); }
+ int chunkCount() const { return chunks.size(); }
struct ChunkOfPages
{
diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp
index 3fe031501f..2affa4f6dd 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit.cpp
+++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp
@@ -297,7 +297,7 @@ void ExecutableCompilationUnit::unlink()
delete [] runtimeLookups;
runtimeLookups = nullptr;
- for (QV4::Function *f : qAsConst(runtimeFunctions))
+ for (QV4::Function *f : std::as_const(runtimeFunctions))
f->destroy();
runtimeFunctions.clear();
@@ -325,14 +325,14 @@ void ExecutableCompilationUnit::markObjects(QV4::MarkStack *markStack)
if (runtimeClasses[i])
runtimeClasses[i]->mark(markStack);
}
- for (QV4::Function *f : qAsConst(runtimeFunctions))
+ for (QV4::Function *f : std::as_const(runtimeFunctions))
if (f && f->internalClass)
f->internalClass->mark(markStack);
- for (QV4::Heap::InternalClass *c : qAsConst(runtimeBlocks))
+ for (QV4::Heap::InternalClass *c : std::as_const(runtimeBlocks))
if (c)
c->mark(markStack);
- for (QV4::Heap::Object *o : qAsConst(templateObjects))
+ for (QV4::Heap::Object *o : std::as_const(templateObjects))
if (o)
o->mark(markStack);
@@ -819,8 +819,14 @@ bool ExecutableCompilationUnit::saveToDisk(const QUrl &unitUrl, QString *errorSt
return CompiledData::SaveableUnitPointer(unitData()).saveToDisk<char>(
[&unitUrl, errorString](const char *data, quint32 size) {
- return CompiledData::SaveableUnitPointer::writeDataToFile(localCacheFilePath(unitUrl), data,
- size, errorString);
+ const QString cachePath = localCacheFilePath(unitUrl);
+ if (CompiledData::SaveableUnitPointer::writeDataToFile(
+ cachePath, data, size, errorString)) {
+ CompilationUnitMapper::invalidate(cachePath);
+ return true;
+ }
+
+ return false;
});
}
@@ -832,7 +838,7 @@ bool ExecutableCompilationUnit::saveToDisk(const QUrl &unitUrl, QString *errorSt
bool ResolvedTypeReferenceMap::addToHash(
QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums) const
{
- std::vector<int> keys (count());
+ std::vector<int> keys (size());
int i = 0;
for (auto it = constBegin(), end = constEnd(); it != end; ++it) {
keys[i] = it.key();
@@ -864,7 +870,7 @@ QString ExecutableCompilationUnit::bindingValueAsString(const CompiledData::Bind
// This code must match that in the qsTr() implementation
const QString &path = fileName();
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
- QStringView context = (lastSlash > -1) ? QStringView{path}.mid(lastSlash + 1, path.length() - lastSlash - 5)
+ QStringView context = (lastSlash > -1) ? QStringView{path}.mid(lastSlash + 1, path.size() - lastSlash - 5)
: QStringView();
QByteArray contextUtf8 = context.toUtf8();
QByteArray comment = stringAt(translation.commentIndex).toUtf8();
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 1be093f0a4..f756575ea8 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -111,7 +111,7 @@ Function::Function(ExecutionEngine *engine, const QQmlPrivate::AOTCompiledFuncti
, aotFunction(aotFunction)
{
internalClass = engine->internalClasses(EngineBase::Class_CallContext);
- nFormals = aotFunction->argumentTypes.length();
+ nFormals = aotFunction->argumentTypes.size();
}
Function::~Function()
@@ -127,7 +127,7 @@ void Function::updateInternalClass(ExecutionEngine *engine, const QList<QByteArr
QStringList parameterNames;
// Resolve duplicate parameter names:
- for (int i = 0, ei = parameters.count(); i != ei; ++i) {
+ for (int i = 0, ei = parameters.size(); i != ei; ++i) {
const QByteArray &param = parameters.at(i);
int duplicate = -1;
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 186535cb82..b38c29a6c5 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -351,36 +351,31 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons
if (!arr)
return v4->throwTypeError();
- const qint64 len64 = arr->getLength();
- if (len64 < 0ll || len64 > qint64(std::numeric_limits<int>::max()))
- return v4->throwRangeError(QStringLiteral("Invalid array length."));
- if (len64 > qint64(v4->jsStackLimit - v4->jsStackTop))
- return v4->throwRangeError(QStringLiteral("Array too large for apply()."));
-
- const uint len = uint(len64);
-
Scope scope(v4);
+ const int len = v4->safeForAllocLength(arr->getLength());
+ CHECK_EXCEPTION();
+
Value *arguments = scope.alloc<Scope::Uninitialized>(len);
if (len) {
if (ArgumentsObject::isNonStrictArgumentsObject(arr) && !arr->cast<ArgumentsObject>()->fullyCreated()) {
QV4::ArgumentsObject *a = arr->cast<ArgumentsObject>();
- int l = qMin(len, (uint)a->d()->context->argc());
+ int l = qMin(len, a->d()->context->argc());
memcpy(arguments, a->d()->context->args(), l*sizeof(Value));
- for (quint32 i = l; i < len; ++i)
+ for (int i = l; i < len; ++i)
arguments[i] = Value::undefinedValue();
} else if (arr->arrayType() == Heap::ArrayData::Simple && !arr->protoHasArray()) {
auto sad = static_cast<Heap::SimpleArrayData *>(arr->arrayData());
- uint alen = sad ? sad->values.size : 0;
+ int alen = sad ? sad->values.size : 0;
if (alen > len)
alen = len;
- for (uint i = 0; i < alen; ++i)
+ for (int i = 0; i < alen; ++i)
arguments[i] = sad->data(i);
- for (quint32 i = alen; i < len; ++i)
+ for (int i = alen; i < len; ++i)
arguments[i] = Value::undefinedValue();
} else {
// need to init the arguments array, as the get() calls below can have side effects
memset(arguments, 0, len*sizeof(Value));
- for (quint32 i = 0; i < len; ++i)
+ for (int i = 0; i < len; ++i)
arguments[i] = arr->get(i);
}
}
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index b42c55f5a8..e32fce28ba 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -40,7 +40,7 @@ namespace Heap {
Member(class, NoMark, bool, canBeTailCalled)
DECLARE_HEAP_OBJECT(FunctionObject, Object) {
- DECLARE_MARKOBJECTS(FunctionObject);
+ DECLARE_MARKOBJECTS(FunctionObject)
enum {
Index_ProtoConstructor = 0,
Index_Prototype = 0,
@@ -125,7 +125,7 @@ struct DefaultClassConstructorFunction : FunctionObject
Member(class, Pointer, MemberData *, boundArgs)
DECLARE_HEAP_OBJECT(BoundFunction, FunctionObject) {
- DECLARE_MARKOBJECTS(BoundFunction);
+ DECLARE_MARKOBJECTS(BoundFunction)
void init(QV4::ExecutionContext *scope, QV4::FunctionObject *target, const Value &boundThis, QV4::MemberData *boundArgs);
};
diff --git a/src/qml/jsruntime/qv4generatorobject_p.h b/src/qml/jsruntime/qv4generatorobject_p.h
index 4a84bec748..55ccc133aa 100644
--- a/src/qml/jsruntime/qv4generatorobject_p.h
+++ b/src/qml/jsruntime/qv4generatorobject_p.h
@@ -57,7 +57,7 @@ struct GeneratorPrototype : FunctionObject {
Member(class, Pointer, ArrayObject *, jsFrame)
DECLARE_HEAP_OBJECT(GeneratorObject, Object) {
- DECLARE_MARKOBJECTS(GeneratorObject);
+ DECLARE_MARKOBJECTS(GeneratorObject)
};
}
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp
index 0112347053..7ea90a2ddd 100644
--- a/src/qml/jsruntime/qv4globalobject.cpp
+++ b/src/qml/jsruntime/qv4globalobject.cpp
@@ -32,7 +32,7 @@ static QString escape(const QString &input)
{
QString output;
output.reserve(input.size() * 3);
- const int length = input.length();
+ const int length = input.size();
for (int i = 0; i < length; ++i) {
ushort uc = input.at(i).unicode();
if (uc < 0x100) {
@@ -63,9 +63,9 @@ static QString escape(const QString &input)
static QString unescape(const QString &input)
{
QString result;
- result.reserve(input.length());
+ result.reserve(input.size());
int i = 0;
- const int length = input.length();
+ const int length = input.size();
while (i < length) {
QChar c = input.at(i++);
if ((c == u'%') && (i + 1 < length)) {
@@ -113,7 +113,7 @@ static QString encode(const QString &input, const char *unescapedSet, bool *ok)
{
*ok = true;
QString output;
- const int length = input.length();
+ const int length = input.size();
int i = 0;
while (i < length) {
const QChar c = input.at(i);
@@ -187,8 +187,8 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok)
{
*ok = true;
QString output;
- output.reserve(input.length());
- const int length = input.length();
+ output.reserve(input.size());
+ const int length = input.size();
int i = 0;
const QChar percent = QLatin1Char('%');
while (i < length) {
@@ -381,7 +381,7 @@ ReturnedValue GlobalFunctions::method_parseInt(const FunctionObject *b, const Va
CHECK_EXCEPTION();
const QChar *pos = trimmed.constData();
- const QChar *end = pos + trimmed.length();
+ const QChar *end = pos + trimmed.size();
int sign = 1; // 3
if (pos != end) {
diff --git a/src/qml/jsruntime/qv4identifiertable.cpp b/src/qml/jsruntime/qv4identifiertable.cpp
index 5b0c2f25ee..96aa54018b 100644
--- a/src/qml/jsruntime/qv4identifiertable.cpp
+++ b/src/qml/jsruntime/qv4identifiertable.cpp
@@ -25,7 +25,7 @@ IdentifierTable::~IdentifierTable()
{
free(entriesByHash);
free(entriesById);
- for (const auto &h : qAsConst(idHashes))
+ for (const auto &h : std::as_const(idHashes))
h->identifierTable = nullptr;
}
@@ -100,7 +100,7 @@ void IdentifierTable::addEntry(Heap::StringOrSymbol *str)
Heap::String *IdentifierTable::insertString(const QString &s)
{
uint subtype;
- uint hash = String::createHashValue(s.constData(), s.length(), &subtype);
+ uint hash = String::createHashValue(s.constData(), s.size(), &subtype);
if (subtype == Heap::String::StringType_ArrayIndex) {
Heap::String *str = engine->newString(s);
str->stringHash = hash;
@@ -133,7 +133,7 @@ Heap::Symbol *IdentifierTable::insertSymbol(const QString &s)
Q_ASSERT(s.at(0) == QLatin1Char('@'));
uint subtype;
- uint hash = String::createHashValue(s.constData(), s.length(), &subtype);
+ uint hash = String::createHashValue(s.constData(), s.size(), &subtype);
uint idx = hash % alloc;
while (Heap::StringOrSymbol *e = entriesByHash[idx]) {
if (e->stringHash == hash && e->toQString() == s)
@@ -252,7 +252,7 @@ void IdentifierTable::sweep()
PropertyKey IdentifierTable::asPropertyKey(const QString &s)
{
uint subtype;
- const uint hash = String::createHashValue(s.constData(), s.length(), &subtype);
+ const uint hash = String::createHashValue(s.constData(), s.size(), &subtype);
if (subtype == Heap::String::StringType_ArrayIndex)
return PropertyKey::fromArrayIndex(hash);
return resolveStringEntry(s, hash, subtype)->identifier;
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index 693cc436ef..57ff8c44ec 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -610,10 +610,32 @@ struct Stringify
QString makeMember(const QString &key, const Value &v);
};
+class [[nodiscard]] CallDepthAndCycleChecker
+{
+ Q_DISABLE_COPY_MOVE(CallDepthAndCycleChecker);
+
+public:
+ CallDepthAndCycleChecker(Stringify *stringify, Object *o)
+ : m_callDepthRecorder(stringify->v4)
+ {
+ if (stringify->stackContains(o)) {
+ stringify->v4->throwTypeError(
+ QStringLiteral("Cannot convert circular structure to JSON"));
+ }
+
+ stringify->v4->checkStackLimits();
+ }
+
+ bool foundProblem() const { return m_callDepthRecorder.ee->hasException; }
+
+private:
+ ExecutionEngineCallDepthRecorder<1> m_callDepthRecorder;
+};
+
static QString quote(const QString &str)
{
QString product;
- const int length = str.length();
+ const int length = str.size();
product.reserve(length + 2);
product += u'"';
for (int i = 0; i < length; ++i) {
@@ -740,10 +762,9 @@ QString Stringify::makeMember(const QString &key, const Value &v)
QString Stringify::JO(Object *o)
{
- if (stackContains(o)) {
- v4->throwTypeError();
+ CallDepthAndCycleChecker check(this, o);
+ if (check.foundProblem())
return QString();
- }
Scope scope(v4);
@@ -800,10 +821,9 @@ QString Stringify::JO(Object *o)
QString Stringify::JA(Object *a)
{
- if (stackContains(a)) {
- v4->throwTypeError();
+ CallDepthAndCycleChecker check(this, a);
+ if (check.foundProblem())
return QString();
- }
Scope scope(a->engine());
@@ -865,7 +885,7 @@ ReturnedValue JsonObject::method_parse(const FunctionObject *b, const Value *, c
jtext = argv[0].toQString();
DEBUG << "parsing source = " << jtext;
- JsonParser parser(v4, jtext.constData(), jtext.length());
+ JsonParser parser(v4, jtext.constData(), jtext.size());
QJsonParseError error;
ReturnedValue result = parser.parse(&error);
if (error.error != QJsonParseError::NoError) {
@@ -885,9 +905,10 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value
if (o) {
stringify.replacerFunction = o->as<FunctionObject>();
if (o->isArrayObject()) {
- uint arrayLen = o->getLength();
+ int arrayLen = scope.engine->safeForAllocLength(o->getLength());
+ CHECK_EXCEPTION();
stringify.propertyList = static_cast<QV4::String *>(scope.alloc(arrayLen));
- for (uint i = 0; i < arrayLen; ++i) {
+ for (int i = 0; i < arrayLen; ++i) {
Value *v = stringify.propertyList + i;
*v = o->get(i);
if (v->as<NumberObject>() || v->as<StringObject>() || v->isNumber())
@@ -895,7 +916,7 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value
if (!v->isString()) {
v->setM(nullptr);
} else {
- for (uint j = 0; j <i; ++j) {
+ for (int j = 0; j <i; ++j) {
if (stringify.propertyList[j].m() == v->m()) {
v->setM(nullptr);
break;
diff --git a/src/qml/jsruntime/qv4mapiterator_p.h b/src/qml/jsruntime/qv4mapiterator_p.h
index 2269473d4c..97a72db85c 100644
--- a/src/qml/jsruntime/qv4mapiterator_p.h
+++ b/src/qml/jsruntime/qv4mapiterator_p.h
@@ -30,7 +30,7 @@ namespace Heap {
Member(class, NoMark, quint32, mapNextIndex)
DECLARE_HEAP_OBJECT(MapIteratorObject, Object) {
- DECLARE_MARKOBJECTS(MapIteratorObject);
+ DECLARE_MARKOBJECTS(MapIteratorObject)
void init(Object *obj, QV4::ExecutionEngine *engine)
{
Object::init();
diff --git a/src/qml/jsruntime/qv4memberdata_p.h b/src/qml/jsruntime/qv4memberdata_p.h
index adcd1e8cf9..672b058fef 100644
--- a/src/qml/jsruntime/qv4memberdata_p.h
+++ b/src/qml/jsruntime/qv4memberdata_p.h
@@ -27,7 +27,7 @@ namespace Heap {
Member(class, ValueArray, ValueArray, values)
DECLARE_HEAP_OBJECT(MemberData, Base) {
- DECLARE_MARKOBJECTS(MemberData);
+ DECLARE_MARKOBJECTS(MemberData)
};
Q_STATIC_ASSERT(std::is_trivial_v<MemberData>);
diff --git a/src/qml/jsruntime/qv4module.cpp b/src/qml/jsruntime/qv4module.cpp
index 779eb77a36..1e1a059dfa 100644
--- a/src/qml/jsruntime/qv4module.cpp
+++ b/src/qml/jsruntime/qv4module.cpp
@@ -195,7 +195,7 @@ struct ModuleNamespaceIterator : ObjectOwnPropertyKeyIterator
PropertyKey ModuleNamespaceIterator::next(const Object *o, Property *pd, PropertyAttributes *attrs)
{
const Module *module = static_cast<const Module *>(o);
- if (exportIndex < exportedNames.count()) {
+ if (exportIndex < exportedNames.size()) {
if (attrs)
*attrs = Attr_Data;
Scope scope(module->engine());
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index aec04b167d..6a39b9e27f 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -1104,7 +1104,7 @@ void Heap::ArrayObject::init(const QStringList &list)
// The result is a new Array object with length equal to the length
// of the QStringList, and the elements being the QStringList's
// elements converted to JS Strings.
- int len = list.count();
+ int len = list.size();
a->arrayReserve(len);
ScopedValue v(scope);
for (int ii = 0; ii < len; ++ii)
diff --git a/src/qml/jsruntime/qv4persistent_p.h b/src/qml/jsruntime/qv4persistent_p.h
index e7b653b6f6..7e208bd4fd 100644
--- a/src/qml/jsruntime/qv4persistent_p.h
+++ b/src/qml/jsruntime/qv4persistent_p.h
@@ -69,7 +69,7 @@ public:
PersistentValue(PersistentValue &&other) noexcept : val(std::exchange(other.val, nullptr)) {}
void swap(PersistentValue &other) noexcept { qt_ptr_swap(val, other.val); }
- QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(PersistentValue);
+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(PersistentValue)
~PersistentValue() { PersistentValueStorage::free(val); }
PersistentValue &operator=(const WeakValue &other);
diff --git a/src/qml/jsruntime/qv4profiling.cpp b/src/qml/jsruntime/qv4profiling.cpp
index 19da26989f..db33cd27f9 100644
--- a/src/qml/jsruntime/qv4profiling.cpp
+++ b/src/qml/jsruntime/qv4profiling.cpp
@@ -60,7 +60,7 @@ void Profiler::reportData()
FunctionLocationHash locations;
properties.reserve(m_data.size());
- for (const FunctionCall &call : qAsConst(m_data)) {
+ for (const FunctionCall &call : std::as_const(m_data)) {
properties.append(call.properties());
Function *function = call.function();
SentMarker &marker = m_sentLocations[reinterpret_cast<quintptr>(function)];
diff --git a/src/qml/jsruntime/qv4promiseobject_p.h b/src/qml/jsruntime/qv4promiseobject_p.h
index c0599987e5..1c11ebbfd6 100644
--- a/src/qml/jsruntime/qv4promiseobject_p.h
+++ b/src/qml/jsruntime/qv4promiseobject_p.h
@@ -34,7 +34,7 @@ class ReactionHandler : public QObject
public:
ReactionHandler(QObject *parent = nullptr);
- virtual ~ReactionHandler() override;
+ ~ReactionHandler() override;
void addReaction(ExecutionEngine *e, const Value *reaction, const Value *value);
void addResolveThenable(ExecutionEngine *e, const PromiseObject *promise, const Object *thenable, const FunctionObject *then);
diff --git a/src/qml/jsruntime/qv4propertykey.cpp b/src/qml/jsruntime/qv4propertykey.cpp
index 8a3e1adc65..e07df07543 100644
--- a/src/qml/jsruntime/qv4propertykey.cpp
+++ b/src/qml/jsruntime/qv4propertykey.cpp
@@ -66,7 +66,7 @@ QV4::Heap::String *QV4::PropertyKey::asFunctionName(ExecutionEngine *engine, Fun
QString str = s->toQString();
if (s->internalClass->vtable->isString)
n += s->toQString();
- else if (str.length() > 1)
+ else if (str.size() > 1)
n += QChar::fromLatin1('[') + QStringView{str}.mid(1) + QChar::fromLatin1(']');
}
return engine->newString(n);
diff --git a/src/qml/jsruntime/qv4qmlcontext_p.h b/src/qml/jsruntime/qv4qmlcontext_p.h
index a89e7f6f2f..bd4b5c2585 100644
--- a/src/qml/jsruntime/qv4qmlcontext_p.h
+++ b/src/qml/jsruntime/qv4qmlcontext_p.h
@@ -34,7 +34,7 @@ namespace Heap {
Member(class, Pointer, Module *, module)
DECLARE_HEAP_OBJECT(QQmlContextWrapper, Object) {
- DECLARE_MARKOBJECTS(QQmlContextWrapper);
+ DECLARE_MARKOBJECTS(QQmlContextWrapper)
void init(QQmlRefPointer<QQmlContextData> context, QObject *scopeObject);
void destroy();
@@ -47,7 +47,7 @@ DECLARE_HEAP_OBJECT(QQmlContextWrapper, Object) {
#define QmlContextMembers(class, Member)
DECLARE_HEAP_OBJECT(QmlContext, ExecutionContext) {
- DECLARE_MARKOBJECTS(QmlContext);
+ DECLARE_MARKOBJECTS(QmlContext)
QQmlContextWrapper *qml() { return static_cast<QQmlContextWrapper *>(activation.get()); }
void init(QV4::ExecutionContext *outerContext, QV4::QQmlContextWrapper *qml);
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index d5e6c1b84a..b9b552576c 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -99,15 +99,10 @@ static ReturnedValue loadProperty(ExecutionEngine *v4, QObject *object,
if (property.isQObject()) {
QObject *rv = nullptr;
property.readProperty(object, &rv);
- ReturnedValue ret = QObjectWrapper::wrap(v4, rv);
- if (propMetaType.flags().testFlag(QMetaType::IsConst)) {
- ScopedValue v(scope, ret);
- if (auto obj = v->as<Object>()) {
- obj->setInternalClass(obj->internalClass()->cryopreserved());
- return obj->asReturnedValue();
- }
- }
- return ret;
+ if (propMetaType.flags().testFlag(QMetaType::IsConst))
+ return QObjectWrapper::wrapConst(v4, rv);
+ else
+ return QObjectWrapper::wrap(v4, rv);
}
if (property.isQList() && propMetaType.flags().testFlag(QMetaType::IsQmlList))
@@ -669,6 +664,29 @@ ReturnedValue QObjectWrapper::wrap_slowPath(ExecutionEngine *engine, QObject *ob
}
}
+ReturnedValue QObjectWrapper::wrapConst_slowPath(ExecutionEngine *engine, QObject *object)
+{
+ const QObject *constObject = object;
+
+ QQmlData *ddata = QQmlData::get(object, true);
+
+ Scope scope(engine);
+ ScopedObject constWrapper(scope);
+ if (engine->m_multiplyWrappedQObjects && ddata->hasConstWrapper)
+ constWrapper = engine->m_multiplyWrappedQObjects->value(constObject);
+
+ if (!constWrapper) {
+ constWrapper = create(engine, object);
+ constWrapper->setInternalClass(constWrapper->internalClass()->cryopreserved());
+ if (!engine->m_multiplyWrappedQObjects)
+ engine->m_multiplyWrappedQObjects = new MultiplyWrappedQObjectMap;
+ engine->m_multiplyWrappedQObjects->insert(constObject, constWrapper->d());
+ ddata->hasConstWrapper = true;
+ }
+
+ return constWrapper.asReturnedValue();
+}
+
void QObjectWrapper::markWrapper(QObject *object, MarkStack *markStack)
{
if (QQmlData::wasDeleted(object))
@@ -683,6 +701,8 @@ void QObjectWrapper::markWrapper(QObject *object, MarkStack *markStack)
ddata->jsWrapper.markOnce(markStack);
else if (engine->m_multiplyWrappedQObjects && ddata->hasTaintedV4Object)
engine->m_multiplyWrappedQObjects->mark(object, markStack);
+ if (ddata->hasConstWrapper)
+ engine->m_multiplyWrappedQObjects->mark(static_cast<const QObject *>(object), markStack);
}
void QObjectWrapper::setProperty(ExecutionEngine *engine, int propertyIndex, const Value &value)
@@ -710,14 +730,13 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, int p
bool QObjectWrapper::virtualIsEqualTo(Managed *a, Managed *b)
{
Q_ASSERT(a->as<QObjectWrapper>());
- QObjectWrapper *qobjectWrapper = static_cast<QObjectWrapper *>(a);
- Object *o = b->as<Object>();
- if (o) {
- if (QQmlTypeWrapper *qmlTypeWrapper = o->as<QQmlTypeWrapper>())
- return qmlTypeWrapper->toVariant().value<QObject*>() == qobjectWrapper->object();
- }
+ const QObjectWrapper *aobjectWrapper = static_cast<QObjectWrapper *>(a);
+ if (const QQmlTypeWrapper *qmlTypeWrapper = b->as<QQmlTypeWrapper>())
+ return qmlTypeWrapper->object() == aobjectWrapper->object();
- return false;
+ // We can have a const and a non-const wrapper for the same object.
+ const QObjectWrapper *bobjectWrapper = b->as<QObjectWrapper>();
+ return bobjectWrapper && aobjectWrapper->object() == bobjectWrapper->object();
}
ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object)
@@ -1176,7 +1195,7 @@ ReturnedValue QObjectWrapper::method_disconnect(const FunctionObject *b, const V
static void markChildQObjectsRecursively(QObject *parent, MarkStack *markStack)
{
const QObjectList &children = parent->children();
- for (int i = 0; i < children.count(); ++i) {
+ for (int i = 0; i < children.size(); ++i) {
QObject *child = children.at(i);
if (!child)
continue;
@@ -1350,8 +1369,8 @@ static ReturnedValue CallMethod(const QQmlObjectOrGadget &object, int index, QMe
}
}
}
- QVarLengthArray<void *, 9> argData(args.count());
- for (int ii = 0; ii < args.count(); ++ii)
+ QVarLengthArray<void *, 9> argData(args.size());
+ for (int ii = 0; ii < args.size(); ++ii)
argData[ii] = args[ii].dataPtr();
object.metacall(callType, index, argData.data());
@@ -1903,14 +1922,16 @@ bool CallArgument::fromValue(QMetaType metaType, ExecutionEngine *engine, const
// Convert via QVariant below.
// TODO: Can't we just do qobjectPtr = qmlTypeWrapper->object() instead?
break;
+ } else if (QObject *obj = qmlTypeWrapper->object()) {
+ // attached object case
+ qobjectPtr = obj;
+ return true;
}
// If this is a plain type wrapper without an instance,
- // then indeed it's an undefined parameter.
- // (although we might interpret that as const QMetaObject *).
- // TODO: But what if it's an attached object?
+ // then we got a namespace, and that's a type error
type = QMetaType::UnknownType;
- return true;
+ return false;
}
qobjectPtr = nullptr;
@@ -2025,7 +2046,7 @@ bool CallArgument::fromValue(QMetaType metaType, ExecutionEngine *engine, const
}
const QQmlMetaObject mo = QQmlMetaType::rawMetaObjectForType(metaType);
- if (!mo.isNull()) {
+ if (!mo.isNull() && v.metaType().flags().testFlag(QMetaType::PointerToQObject)) {
QObject *obj = QQmlMetaType::toQObject(v);
if (obj != nullptr && !QQmlMetaObject::canConvert(obj, mo)) {
@@ -2095,11 +2116,11 @@ ReturnedValue CallArgument::toValue(ExecutionEngine *engine)
QList<QObject *> &list = *qlistPtr;
Scope scope(engine);
ScopedArrayObject array(scope, engine->newArrayObject());
- array->arrayReserve(list.count());
+ array->arrayReserve(list.size());
ScopedValue v(scope);
- for (int ii = 0; ii < list.count(); ++ii)
+ for (int ii = 0; ii < list.size(); ++ii)
array->arrayPut(ii, (v = QObjectWrapper::wrap(engine, list.at(ii))));
- array->setArrayLengthUnchecked(list.count());
+ array->setArrayLengthUnchecked(list.size());
return array.asReturnedValue();
}
@@ -2429,39 +2450,20 @@ void QmlSignalHandler::initProto(ExecutionEngine *engine)
engine->jsObjects[ExecutionEngine::SignalHandlerProto] = o->d();
}
-void MultiplyWrappedQObjectMap::insert(QObject *key, Heap::Object *value)
-{
- QHash<QObject*, WeakValue>::operator[](key).set(value->internalClass->engine, value);
- connect(key, SIGNAL(destroyed(QObject*)), this, SLOT(removeDestroyedObject(QObject*)));
-}
-
-
-MultiplyWrappedQObjectMap::Iterator MultiplyWrappedQObjectMap::erase(MultiplyWrappedQObjectMap::Iterator it)
+MultiplyWrappedQObjectMap::Iterator MultiplyWrappedQObjectMap::erase(
+ MultiplyWrappedQObjectMap::Iterator it)
{
- disconnect(it.key(), SIGNAL(destroyed(QObject*)), this, SLOT(removeDestroyedObject(QObject*)));
- return QHash<QObject*, WeakValue>::erase(it);
-}
-
-void MultiplyWrappedQObjectMap::remove(QObject *key)
-{
- Iterator it = find(key);
- if (it == end())
- return;
- erase(it);
-}
-
-void MultiplyWrappedQObjectMap::mark(QObject *key, MarkStack *markStack)
-{
- Iterator it = find(key);
- if (it == end())
- return;
- it->markOnce(markStack);
+ const QObjectBiPointer key = it.key();
+ const QObject *obj = key.isT1() ? key.asT1() : key.asT2();
+ disconnect(obj, &QObject::destroyed, this, &MultiplyWrappedQObjectMap::removeDestroyedObject);
+ return QHash<QObjectBiPointer, WeakValue>::erase(it);
}
void MultiplyWrappedQObjectMap::removeDestroyedObject(QObject *object)
{
- QHash<QObject*, WeakValue>::remove(object);
+ QHash<QObjectBiPointer, WeakValue>::remove(object);
+ QHash<QObjectBiPointer, WeakValue>::remove(static_cast<const QObject *>(object));
}
} // namespace QV4
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h
index 4477c3c836..5a0d837746 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper_p.h
+++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h
@@ -65,7 +65,7 @@ private:
Member(class, NoMark, int, index)
DECLARE_HEAP_OBJECT(QObjectMethod, FunctionObject) {
- DECLARE_MARKOBJECTS(QObjectMethod);
+ DECLARE_MARKOBJECTS(QObjectMethod)
QQmlPropertyData *methods;
int methodCount;
@@ -140,6 +140,7 @@ struct Q_QML_EXPORT QObjectWrapper : public Object
QObject *object, String *name, RevisionMode revisionMode, const Value &value);
static ReturnedValue wrap(ExecutionEngine *engine, QObject *object);
+ static ReturnedValue wrapConst(ExecutionEngine *engine, QObject *object);
static void markWrapper(QObject *object, MarkStack *markStack);
using Object::get;
@@ -181,6 +182,7 @@ protected:
private:
Q_NEVER_INLINE static ReturnedValue wrap_slowPath(ExecutionEngine *engine, QObject *object);
+ Q_NEVER_INLINE static ReturnedValue wrapConst_slowPath(ExecutionEngine *engine, QObject *object);
};
inline ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object)
@@ -197,6 +199,15 @@ inline ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *obje
return wrap_slowPath(engine, object);
}
+// Unfortunately we still need a non-const QObject* here because QQmlData needs to register itself in QObjectPrivate.
+inline ReturnedValue QObjectWrapper::wrapConst(ExecutionEngine *engine, QObject *object)
+{
+ if (Q_UNLIKELY(QQmlData::wasDeleted(object)))
+ return QV4::Encode::null();
+
+ return wrapConst_slowPath(engine, object);
+}
+
template <typename ReversalFunctor>
inline ReturnedValue QObjectWrapper::lookupGetterImpl(Lookup *lookup, ExecutionEngine *engine, const Value &object, bool useOriginalProperty, ReversalFunctor revertLookup)
{
@@ -292,23 +303,32 @@ struct Q_QML_EXPORT QmlSignalHandler : public QV4::Object
static void initProto(ExecutionEngine *v4);
};
+using QObjectBiPointer = QBiPointer<QObject, const QObject>;
+
class MultiplyWrappedQObjectMap : public QObject,
- private QHash<QObject*, QV4::WeakValue>
+ private QHash<QObjectBiPointer, QV4::WeakValue>
{
Q_OBJECT
public:
- typedef QHash<QObject*, QV4::WeakValue>::ConstIterator ConstIterator;
- typedef QHash<QObject*, QV4::WeakValue>::Iterator Iterator;
+ typedef QHash<QObjectBiPointer, QV4::WeakValue>::ConstIterator ConstIterator;
+ typedef QHash<QObjectBiPointer, QV4::WeakValue>::Iterator Iterator;
+
+ using value_type = QHash<QObjectBiPointer, QV4::WeakValue>::value_type;
- using value_type = QHash<QObject*, QV4::WeakValue>::value_type;
+ ConstIterator begin() const { return QHash<QObjectBiPointer, QV4::WeakValue>::constBegin(); }
+ Iterator begin() { return QHash<QObjectBiPointer, QV4::WeakValue>::begin(); }
+ ConstIterator end() const { return QHash<QObjectBiPointer, QV4::WeakValue>::constEnd(); }
+ Iterator end() { return QHash<QObjectBiPointer, QV4::WeakValue>::end(); }
- ConstIterator begin() const { return QHash<QObject*, QV4::WeakValue>::constBegin(); }
- Iterator begin() { return QHash<QObject*, QV4::WeakValue>::begin(); }
- ConstIterator end() const { return QHash<QObject*, QV4::WeakValue>::constEnd(); }
- Iterator end() { return QHash<QObject*, QV4::WeakValue>::end(); }
+ template<typename Pointer>
+ void insert(Pointer key, Heap::Object *value)
+ {
+ QHash<QObjectBiPointer, WeakValue>::operator[](key).set(value->internalClass->engine, value);
+ connect(key, SIGNAL(destroyed(QObject*)), this, SLOT(removeDestroyedObject(QObject*)));
+ }
- void insert(QObject *key, Heap::Object *value);
- ReturnedValue value(QObject *key) const
+ template<typename Pointer>
+ ReturnedValue value(Pointer key) const
{
ConstIterator it = find(key);
return it == end()
@@ -317,8 +337,24 @@ public:
}
Iterator erase(Iterator it);
- void remove(QObject *key);
- void mark(QObject *key, MarkStack *markStack);
+
+ template<typename Pointer>
+ void remove(Pointer key)
+ {
+ Iterator it = find(key);
+ if (it == end())
+ return;
+ erase(it);
+ }
+
+ template<typename Pointer>
+ void mark(Pointer key, MarkStack *markStack)
+ {
+ Iterator it = find(key);
+ if (it == end())
+ return;
+ it->markOnce(markStack);
+ }
private Q_SLOTS:
void removeDestroyedObject(QObject*);
diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp
index abcc60726a..179663a0e1 100644
--- a/src/qml/jsruntime/qv4reflect.cpp
+++ b/src/qml/jsruntime/qv4reflect.cpp
@@ -40,7 +40,10 @@ struct CallArgs {
static CallArgs createListFromArrayLike(Scope &scope, const Object *o)
{
- int len = o->getLength();
+ int len = scope.engine->safeForAllocLength(o->getLength());
+ if (scope.engine->hasException)
+ return {nullptr, 0};
+
Value *arguments = scope.alloc(len);
for (int i = 0; i < len; ++i) {
diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp
index 0c039967ba..be7ff77603 100644
--- a/src/qml/jsruntime/qv4regexp.cpp
+++ b/src/qml/jsruntime/qv4regexp.cpp
@@ -49,7 +49,7 @@ uint RegExp::match(const QString &string, int start, uint *matchOffsets)
uint ret = JSC::Yarr::offsetNoMatch;
#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
char buffer[8192];
- ret = uint(priv->jitCode->execute(s.characters16(), start, s.length(),
+ ret = uint(priv->jitCode->execute(s.characters16(), start, s.size(),
(int*)matchOffsets, buffer, 8192).start);
#else
ret = uint(priv->jitCode->execute(s.characters16(), start, s.length(),
@@ -74,18 +74,18 @@ uint RegExp::match(const QString &string, int start, uint *matchOffsets)
}
#endif // ENABLE(YARR_JIT)
- return JSC::Yarr::interpret(byteCode(), s.characters16(), string.length(), start, matchOffsets);
+ return JSC::Yarr::interpret(byteCode(), s.characters16(), string.size(), start, matchOffsets);
}
QString RegExp::getSubstitution(const QString &matched, const QString &str, int position, const Value *captures, int nCaptures, const QString &replacement)
{
QString result;
- int matchedLength = matched.length();
- Q_ASSERT(position >= 0 && position <= str.length());
+ int matchedLength = matched.size();
+ Q_ASSERT(position >= 0 && position <= str.size());
int tailPos = position + matchedLength;
int seenDollar = -1;
- for (int i = 0; i < replacement.length(); ++i) {
+ for (int i = 0; i < replacement.size(); ++i) {
QChar ch = replacement.at(i);
if (seenDollar >= 0) {
if (ch.unicode() == '$') {
@@ -98,7 +98,7 @@ QString RegExp::getSubstitution(const QString &matched, const QString &str, int
result += str.mid(tailPos);
} else if (ch.unicode() >= '0' && ch.unicode() <= '9') {
int n = ch.unicode() - '0';
- if (i + 1 < replacement.length()) {
+ if (i + 1 < replacement.size()) {
ch = replacement.at(i + 1);
if (ch.unicode() >= '0' && ch.unicode() <= '9') {
n = n*10 + (ch.unicode() - '0');
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index 365593e207..0fab40a281 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -48,7 +48,7 @@ void Heap::RegExpObject::init(QV4::RegExp *value)
static QString minimalPattern(const QString &pattern)
{
QString ecmaPattern;
- int len = pattern.length();
+ int len = pattern.size();
ecmaPattern.reserve(len);
int i = 0;
const QChar *wc = pattern.unicode();
@@ -146,7 +146,7 @@ ReturnedValue RegExpObject::builtinExec(ExecutionEngine *engine, const String *s
Scope scope(engine);
int offset = (global() || sticky()) ? lastIndex() : 0;
- if (offset < 0 || offset > s.length()) {
+ if (offset < 0 || offset > s.size()) {
setLastIndex(0);
RETURN_RESULT(Encode::null());
}
@@ -170,7 +170,7 @@ ReturnedValue RegExpObject::builtinExec(ExecutionEngine *engine, const String *s
int len = value()->captureCount();
array->arrayReserve(len);
ScopedValue v(scope);
- int strlen = s.length();
+ int strlen = s.size();
for (int i = 0; i < len; ++i) {
int start = matchOffsets[i * 2];
int end = matchOffsets[i * 2 + 1];
@@ -232,7 +232,7 @@ uint parseFlags(Scope &scope, const QV4::Value *f)
if (scope.hasException())
return flags;
QString str = s->toQString();
- for (int i = 0; i < str.length(); ++i) {
+ for (int i = 0; i < str.size(); ++i) {
if (str.at(i) == QLatin1Char('g') && !(flags & CompiledData::RegExp::RegExp_Global)) {
flags |= CompiledData::RegExp::RegExp_Global;
} else if (str.at(i) == QLatin1Char('i') && !(flags & CompiledData::RegExp::RegExp_IgnoreCase)) {
@@ -382,7 +382,7 @@ ReturnedValue RegExpPrototype::execFirstMatch(const FunctionObject *b, const Val
QString s = str->toQString();
int offset = r->lastIndex();
- if (offset < 0 || offset > s.length()) {
+ if (offset < 0 || offset > s.size()) {
r->setLastIndex(0);
RETURN_RESULT(Encode::null());
}
@@ -518,7 +518,7 @@ ReturnedValue RegExpPrototype::method_get_ignoreCase(const FunctionObject *f, co
static int advanceStringIndex(int index, const QString &str, bool unicode)
{
if (unicode) {
- if (index < str.length() - 1 &&
+ if (index < str.size() - 1 &&
str.at(index).isHighSurrogate() &&
str.at(index + 1).isLowSurrogate())
++index;
@@ -607,7 +607,7 @@ ReturnedValue RegExpPrototype::method_replace(const FunctionObject *f, const Val
if (scope.hasException())
return Encode::undefined();
- int lengthS = s->toQString().length();
+ int lengthS = s->toQString().size();
ScopedString replaceValue(scope);
ScopedFunctionObject replaceFunction(scope, (argc > 1 ? argv[1] : Value::undefinedValue()));
@@ -659,7 +659,7 @@ ReturnedValue RegExpPrototype::method_replace(const FunctionObject *f, const Val
if (scope.hasException())
return Encode::undefined();
QString m = matchString->toQString();
- int matchLength = m.length();
+ int matchLength = m.size();
v = resultObject->get(scope.engine->id_index());
int position = v->toInt32();
position = qMax(qMin(position, lengthS), 0);
@@ -786,7 +786,7 @@ ReturnedValue RegExpPrototype::method_split(const FunctionObject *f, const Value
return A->asReturnedValue();
QString S = s->toQString();
- int size = S.length();
+ int size = S.size();
if (size == 0) {
ScopedValue z(scope, exec(scope.engine, splitter, s));
if (z->isNull())
diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h
index 2f278f70a7..3171367351 100644
--- a/src/qml/jsruntime/qv4regexpobject_p.h
+++ b/src/qml/jsruntime/qv4regexpobject_p.h
@@ -56,7 +56,7 @@ DECLARE_HEAP_OBJECT(RegExpObject, Object) {
Member(class, NoMark, int, lastMatchEnd)
DECLARE_HEAP_OBJECT(RegExpCtor, FunctionObject) {
- DECLARE_MARKOBJECTS(RegExpCtor);
+ DECLARE_MARKOBJECTS(RegExpCtor)
void init(QV4::ExecutionContext *scope);
void clearLastMatch();
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index bd81c56bbd..f07f7e38a1 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -144,7 +144,7 @@ struct RuntimeCounters::Data {
}
std::sort(lines.begin(), lines.end(), Line::less);
outs << lines.size() << " counters:" << endl;
- for (const Line &line : qAsConst(lines))
+ for (const Line &line : std::as_const(lines))
outs << qSetFieldWidth(10) << line.count << qSetFieldWidth(0)
<< " | " << line.func
<< " | " << pretty(line.tag1)
@@ -217,7 +217,7 @@ void RuntimeHelpers::numberToString(QString *result, double num, int radix)
*result = qdtoa(num, &decpt, &sign);
if (decpt <= ecma_shortest_low || decpt > ecma_shortest_high) {
- if (result->length() > 1)
+ if (result->size() > 1)
result->insert(1, dot);
result->append(QLatin1Char('e'));
if (decpt > 0)
@@ -225,10 +225,10 @@ void RuntimeHelpers::numberToString(QString *result, double num, int radix)
result->append(QString::number(decpt - 1));
} else if (decpt <= 0) {
result->prepend(QLatin1String("0.") + QString(-decpt, zero));
- } else if (decpt < result->length()) {
+ } else if (decpt < result->size()) {
result->insert(decpt, dot);
} else {
- result->append(QString(decpt - result->length(), zero));
+ result->append(QString(decpt - result->size(), zero));
}
if (sign && num)
@@ -392,7 +392,7 @@ double RuntimeHelpers::stringToNumber(const QString &string)
// libdoubleconversion sources. The same maximum value would be represented by roughly 3.5 times
// as many binary digits.
const int excessiveLength = 16 * 1024;
- if (string.length() > excessiveLength)
+ if (string.size() > excessiveLength)
return qQNaN();
const QStringView s = QStringView(string).trimmed();
@@ -642,7 +642,7 @@ static Q_NEVER_INLINE ReturnedValue getElementIntFallback(ExecutionEngine *engin
ScopedObject o(scope, object);
if (!o) {
if (const String *str = object.as<String>()) {
- if (idx >= (uint)str->toQString().length()) {
+ if (idx >= (uint)str->toQString().size()) {
return Encode::undefined();
}
const QString s = str->toQString().mid(idx, 1);
@@ -1561,6 +1561,11 @@ static CallArgs createSpreadArguments(Scope &scope, Value *argv, int argc)
if (done->booleanValue())
break;
++argCount;
+ constexpr auto safetyMargin = 100; // leave some space on the stack for actual work with the elements
+ if (qint64(scope.engine->jsStackLimit - scope.engine->jsStackTop) < safetyMargin) {
+ scope.engine->throwRangeError(QLatin1String("Too many elements in array to use it with the spread operator"));
+ return { nullptr, 0 };
+ }
v = scope.alloc<Scope::Uninitialized>();
}
}
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index 09e8b60c91..eee7fd8414 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -88,6 +88,10 @@ struct Scope {
/* Be careful when using Uninitialized, the stack has to be fully initialized before calling into the memory manager again */
Uninitialized
};
+
+ template <AllocMode mode = Undefined>
+ Value *alloc(qint64 nValues) const = delete; // use safeForAllocLength
+
template <AllocMode mode = Undefined>
QML_NEARLY_ALWAYS_INLINE Value *alloc(int nValues) const
{
@@ -408,7 +412,7 @@ struct ScopedProperty
{
ScopedProperty(Scope &scope)
{
- property = reinterpret_cast<Property*>(scope.alloc(sizeof(Property) / sizeof(Value)));
+ property = reinterpret_cast<Property*>(scope.alloc(int(sizeof(Property) / sizeof(Value))));
}
Property *operator->() { return property; }
diff --git a/src/qml/jsruntime/qv4setiterator_p.h b/src/qml/jsruntime/qv4setiterator_p.h
index e7ab85accb..37f912e01a 100644
--- a/src/qml/jsruntime/qv4setiterator_p.h
+++ b/src/qml/jsruntime/qv4setiterator_p.h
@@ -30,7 +30,7 @@ namespace Heap {
Member(class, NoMark, quint32, setNextIndex)
DECLARE_HEAP_OBJECT(SetIteratorObject, Object) {
- DECLARE_MARKOBJECTS(SetIteratorObject);
+ DECLARE_MARKOBJECTS(SetIteratorObject)
void init(Object *obj, QV4::ExecutionEngine *engine)
{
Object::init();
diff --git a/src/qml/jsruntime/qv4stringiterator.cpp b/src/qml/jsruntime/qv4stringiterator.cpp
index 99f10c55b4..9cb2711efb 100644
--- a/src/qml/jsruntime/qv4stringiterator.cpp
+++ b/src/qml/jsruntime/qv4stringiterator.cpp
@@ -35,7 +35,7 @@ ReturnedValue StringIteratorPrototype::method_next(const FunctionObject *b, cons
quint32 index = thisObject->d()->nextIndex;
QString str = s->toQString();
- quint32 len = str.length();
+ quint32 len = str.size();
if (index >= len) {
thisObject->d()->iteratedString.set(scope.engine, nullptr);
diff --git a/src/qml/jsruntime/qv4stringiterator_p.h b/src/qml/jsruntime/qv4stringiterator_p.h
index a445381ba6..742b8a895d 100644
--- a/src/qml/jsruntime/qv4stringiterator_p.h
+++ b/src/qml/jsruntime/qv4stringiterator_p.h
@@ -30,7 +30,7 @@ namespace Heap {
Member(class, NoMark, quint32, nextIndex)
DECLARE_HEAP_OBJECT(StringIteratorObject, Object) {
- DECLARE_MARKOBJECTS(StringIteratorObject);
+ DECLARE_MARKOBJECTS(StringIteratorObject)
void init(String *str, QV4::ExecutionEngine *engine)
{
Object::init();
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 5e1d764aed..bec4132b5f 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -51,7 +51,7 @@ void Heap::StringObject::init(const QV4::String *str)
Heap::String *Heap::StringObject::getIndex(uint index) const
{
QString str = string->toQString();
- if (index >= (uint)str.length())
+ if (index >= (uint)str.size())
return nullptr;
return internalClass->engine->newString(str.mid(index, 1));
}
@@ -67,7 +67,7 @@ bool StringObject::virtualDeleteProperty(Managed *m, PropertyKey id)
if (id.isArrayIndex()) {
StringObject *o = static_cast<StringObject *>(m);
uint index = id.asArrayIndex();
- if (index < static_cast<uint>(o->d()->string->toQString().length()))
+ if (index < static_cast<uint>(o->d()->string->toQString().size()))
return false;
}
return Object::virtualDeleteProperty(m, id);
@@ -83,7 +83,7 @@ struct StringObjectOwnPropertyKeyIterator : ObjectOwnPropertyKeyIterator
PropertyKey StringObjectOwnPropertyKeyIterator::next(const QV4::Object *o, Property *pd, PropertyAttributes *attrs)
{
const StringObject *s = static_cast<const StringObject *>(o);
- uint slen = s->d()->string->toQString().length();
+ uint slen = s->d()->string->toQString().size();
if (arrayIndex < slen) {
uint index = arrayIndex;
++arrayIndex;
@@ -119,7 +119,7 @@ PropertyAttributes StringObject::virtualGetOwnProperty(const Managed *m, Propert
if (id.isArrayIndex()) {
const uint index = id.asArrayIndex();
const auto s = static_cast<const StringObject *>(m);
- if (index < uint(s->d()->string->toQString().length())) {
+ if (index < uint(s->d()->string->toQString().size())) {
if (p)
p->value = s->getIndex(index);
return Attr_NotConfigurable|Attr_NotWritable;
@@ -338,7 +338,7 @@ ReturnedValue StringPrototype::method_charAt(const FunctionObject *b, const Valu
pos = (int) argv[0].toInteger();
QString result;
- if (pos >= 0 && pos < str.length())
+ if (pos >= 0 && pos < str.size())
result += str.at(pos);
return Encode(v4->newString(result));
@@ -356,7 +356,7 @@ ReturnedValue StringPrototype::method_charCodeAt(const FunctionObject *b, const
pos = (int) argv[0].toInteger();
- if (pos >= 0 && pos < str.length())
+ if (pos >= 0 && pos < str.size())
RETURN_RESULT(Encode(str.at(pos).unicode()));
return Encode(qt_qnan());
@@ -419,11 +419,11 @@ ReturnedValue StringPrototype::method_endsWith(const FunctionObject *b, const Va
if (v4->hasException)
return Encode::undefined();
- int pos = value.length();
+ int pos = value.size();
if (argc > 1)
pos = (int) argv[1].toInteger();
- if (pos == value.length())
+ if (pos == value.size())
RETURN_RESULT(Encode(value.endsWith(searchString)));
QStringView stringToSearch = QStringView{value}.left(pos);
@@ -447,7 +447,7 @@ ReturnedValue StringPrototype::method_indexOf(const FunctionObject *b, const Val
int index = -1;
if (! value.isEmpty())
- index = value.indexOf(searchString, qMin(qMax(pos, 0), value.length()));
+ index = value.indexOf(searchString, qMin(qMax(pos, 0), value.size()));
return Encode(index);
}
@@ -470,7 +470,7 @@ ReturnedValue StringPrototype::method_includes(const FunctionObject *b, const Va
const Value &posArg = argv[1];
pos = (int) posArg.toInteger();
if (!posArg.isInteger() && posArg.isNumber() && qIsInf(posArg.toNumber()))
- pos = value.length();
+ pos = value.size();
}
if (pos == 0)
@@ -497,8 +497,8 @@ ReturnedValue StringPrototype::method_lastIndexOf(const FunctionObject *b, const
else
position = std::trunc(position);
- int pos = std::trunc(qMin(qMax(position, 0.0), double(value.length())));
- if (!searchString.isEmpty() && pos == value.length())
+ int pos = std::trunc(qMin(qMax(position, 0.0), double(value.size())));
+ if (!searchString.isEmpty() && pos == value.size())
--pos;
if (searchString.isNull() && pos == 0)
RETURN_RESULT(Encode(-1));
@@ -607,12 +607,12 @@ ReturnedValue StringPrototype::method_padEnd(const FunctionObject *f, const Valu
return s->asReturnedValue();
QString padded = s->toQString();
- int oldLength = padded.length();
+ int oldLength = padded.size();
int toFill = maxLen - oldLength;
padded.resize(maxLen);
QChar *ch = padded.data() + oldLength;
while (toFill) {
- int copy = qMin(fillString.length(), toFill);
+ int copy = qMin(fillString.size(), toFill);
memcpy(ch, fillString.constData(), copy*sizeof(QChar));
toFill -= copy;
ch += copy;
@@ -646,13 +646,13 @@ ReturnedValue StringPrototype::method_padStart(const FunctionObject *f, const Va
return s->asReturnedValue();
QString original = s->toQString();
- int oldLength = original.length();
+ int oldLength = original.size();
int toFill = maxLen - oldLength;
QString padded;
padded.resize(maxLen);
QChar *ch = padded.data();
while (toFill) {
- int copy = qMin(fillString.length(), toFill);
+ int copy = qMin(fillString.size(), toFill);
memcpy(ch, fillString.constData(), copy*sizeof(QChar));
toFill -= copy;
ch += copy;
@@ -682,9 +682,9 @@ ReturnedValue StringPrototype::method_repeat(const FunctionObject *b, const Valu
static void appendReplacementString(QString *result, const QString &input, const QString& replaceValue, uint* matchOffsets, int captureCount)
{
- result->reserve(result->length() + replaceValue.length());
- for (int i = 0; i < replaceValue.length(); ++i) {
- if (replaceValue.at(i) == QLatin1Char('$') && i < replaceValue.length() - 1) {
+ result->reserve(result->size() + replaceValue.size());
+ for (int i = 0; i < replaceValue.size(); ++i) {
+ if (replaceValue.at(i) == QLatin1Char('$') && i < replaceValue.size() - 1) {
ushort ch = replaceValue.at(i + 1).unicode();
uint substStart = JSC::Yarr::offsetNoMatch;
uint substEnd = JSC::Yarr::offsetNoMatch;
@@ -703,12 +703,12 @@ static void appendReplacementString(QString *result, const QString &input, const
skip = 1;
} else if (ch == '\'') {
substStart = matchOffsets[1];
- substEnd = input.length();
+ substEnd = input.size();
skip = 1;
} else if (ch >= '0' && ch <= '9') {
uint capture = ch - '0';
skip = 1;
- if (i < replaceValue.length() - 2) {
+ if (i < replaceValue.size() - 2) {
ch = replaceValue.at(i + 2).unicode();
if (ch >= '0' && ch <= '9') {
uint c = capture*10 + ch - '0';
@@ -793,7 +793,7 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
if (idx != -1) {
numStringMatches = 1;
matchOffsets[0] = idx;
- matchOffsets[1] = idx + searchString.length();
+ matchOffsets[1] = idx + searchString.size();
}
}
@@ -802,7 +802,7 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
ScopedValue replaceValue(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedFunctionObject searchCallback(scope, replaceValue);
if (!!searchCallback) {
- result.reserve(string.length() + 10*numStringMatches);
+ result.reserve(string.size() + 10*numStringMatches);
ScopedValue entry(scope);
Value *arguments = scope.alloc(numCaptures + 2);
int lastEnd = 0;
@@ -832,7 +832,7 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
result += QStringView{string}.mid(lastEnd);
} else {
QString newString = replaceValue->toQString();
- result.reserve(string.length() + numStringMatches*newString.size());
+ result.reserve(string.size() + numStringMatches*newString.size());
int lastEnd = 0;
for (int i = 0; i < numStringMatches; ++i) {
@@ -975,7 +975,7 @@ ReturnedValue StringPrototype::method_split(const FunctionObject *b, const Value
} else {
QString separator = separatorValue->toQString();
if (separator.isEmpty()) {
- for (uint i = 0; i < qMin(limit, uint(text.length())); ++i)
+ for (uint i = 0; i < qMin(limit, uint(text.size())); ++i)
array->push_back((s = scope.engine->newString(text.mid(i, 1))));
return array.asReturnedValue();
}
@@ -1033,7 +1033,7 @@ ReturnedValue StringPrototype::method_substr(const FunctionObject *b, const Valu
if (argc > 1)
length = argv[1].toInteger();
- double count = value.length();
+ double count = value.size();
if (start < 0)
start = qMax(count + start, 0.0);
@@ -1051,7 +1051,7 @@ ReturnedValue StringPrototype::method_substring(const FunctionObject *b, const V
if (v4->hasException)
return QV4::Encode::undefined();
- int length = value.length();
+ int length = value.size();
double start = 0;
double end = length;
@@ -1124,11 +1124,11 @@ ReturnedValue StringPrototype::method_trim(const FunctionObject *b, const Value
const QChar *chars = s.constData();
int start, end;
- for (start = 0; start < s.length(); ++start) {
+ for (start = 0; start < s.size(); ++start) {
if (!chars[start].isSpace() && chars[start].unicode() != 0xfeff)
break;
}
- for (end = s.length() - 1; end >= start; --end) {
+ for (end = s.size() - 1; end >= start; --end) {
if (!chars[end].isSpace() && chars[end].unicode() != 0xfeff)
break;
}
diff --git a/src/qml/jsruntime/qv4stringobject_p.h b/src/qml/jsruntime/qv4stringobject_p.h
index e0c0e37815..451a989ef4 100644
--- a/src/qml/jsruntime/qv4stringobject_p.h
+++ b/src/qml/jsruntime/qv4stringobject_p.h
@@ -28,7 +28,7 @@ namespace Heap {
Member(class, Pointer, String *, string)
DECLARE_HEAP_OBJECT(StringObject, Object) {
- DECLARE_MARKOBJECTS(StringObject);
+ DECLARE_MARKOBJECTS(StringObject)
enum {
LengthPropertyIndex = 0
diff --git a/src/qml/jsruntime/qv4symbol_p.h b/src/qml/jsruntime/qv4symbol_p.h
index b85ddb3b36..e56510bd69 100644
--- a/src/qml/jsruntime/qv4symbol_p.h
+++ b/src/qml/jsruntime/qv4symbol_p.h
@@ -36,7 +36,7 @@ struct Symbol : StringOrSymbol {
Member(class, Pointer, Symbol *, symbol)
DECLARE_HEAP_OBJECT(SymbolObject, Object) {
- DECLARE_MARKOBJECTS(SymbolObject);
+ DECLARE_MARKOBJECTS(SymbolObject)
void init(const QV4::Symbol *s);
};
diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h
index d7e9d7466c..0284dceb7b 100644
--- a/src/qml/jsruntime/qv4typedarray_p.h
+++ b/src/qml/jsruntime/qv4typedarray_p.h
@@ -80,7 +80,7 @@ namespace Heap {
Member(class, NoMark, uint, arrayType)
DECLARE_HEAP_OBJECT(TypedArray, Object) {
- DECLARE_MARKOBJECTS(TypedArray);
+ DECLARE_MARKOBJECTS(TypedArray)
using Type = TypedArrayType;
void init(Type t);
diff --git a/src/qml/jsruntime/qv4urlobject.cpp b/src/qml/jsruntime/qv4urlobject.cpp
index bc59b7a839..7f4a078d13 100644
--- a/src/qml/jsruntime/qv4urlobject.cpp
+++ b/src/qml/jsruntime/qv4urlobject.cpp
@@ -131,7 +131,7 @@ void UrlObject::setUrl(const QUrl &url)
d()->port.set(engine(),
engine()->newString(url.port() == -1 ? QLatin1String("")
: QString::number(url.port())));
- d()->protocol.set(engine(), engine()->newString(url.scheme()));
+ d()->protocol.set(engine(), engine()->newString(url.scheme() + QLatin1Char(':')));
d()->search.set(engine(), engine()->newString(url.query()));
d()->username.set(engine(), engine()->newString(url.userName()));
@@ -186,15 +186,23 @@ bool UrlObject::setPort(QString port)
return true;
}
-bool UrlObject::setProtocol(QString protocol)
+bool UrlObject::setProtocol(QString protocolOrScheme)
{
QUrl url = toQUrl();
- url.setScheme(protocol);
+ // If there is one or several ':' in the protocolOrScheme,
+ // everything from the first colon is removed.
+
+ qsizetype firstColonPos = protocolOrScheme.indexOf(QLatin1Char(':'));
+
+ if (firstColonPos != -1)
+ protocolOrScheme.truncate(firstColonPos);
+
+ url.setScheme(protocolOrScheme);
if (!url.isValid())
return false;
- d()->protocol.set(engine(), engine()->newString(url.scheme()));
+ d()->protocol.set(engine(), engine()->newString(url.scheme() + QLatin1Char(':')));
d()->href.set(engine(), engine()->newString(url.toString()));
updateOrigin();
diff --git a/src/qml/jsruntime/qv4urlobject_p.h b/src/qml/jsruntime/qv4urlobject_p.h
index 3b210547b3..e4a3ba073b 100644
--- a/src/qml/jsruntime/qv4urlobject_p.h
+++ b/src/qml/jsruntime/qv4urlobject_p.h
@@ -41,7 +41,7 @@ namespace Heap {
DECLARE_HEAP_OBJECT(UrlObject, Object)
{
- DECLARE_MARKOBJECTS(UrlObject);
+ DECLARE_MARKOBJECTS(UrlObject)
void init() { Object::init(); }
};
@@ -59,7 +59,7 @@ struct UrlCtor : FunctionObject
DECLARE_HEAP_OBJECT(UrlSearchParamsObject, Object)
{
- DECLARE_MARKOBJECTS(UrlSearchParamsObject);
+ DECLARE_MARKOBJECTS(UrlSearchParamsObject)
void init() { Object::init(); }
};
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index c41c6fafad..aaace7e9f6 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -943,7 +943,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
}
// Now it is time to free QV4::QObjectWrapper Value, we must check the Value's tag to make sure its object has been destroyed
- const int pendingCount = m_pendingFreedObjectWrapperValue.count();
+ const int pendingCount = m_pendingFreedObjectWrapperValue.size();
if (pendingCount) {
QVector<Value *> remainingWeakQObjectWrappers;
remainingWeakQObjectWrappers.reserve(pendingCount);
@@ -1078,7 +1078,7 @@ void MemoryManager::runGC()
std::swap(freedObjectStats, *freedObjectStatsGlobal());
typedef std::pair<const char*, int> ObjectStatInfo;
std::vector<ObjectStatInfo> freedObjectsSorted;
- freedObjectsSorted.reserve(freedObjectStats.count());
+ freedObjectsSorted.reserve(freedObjectStats.size());
for (auto it = freedObjectStats.constBegin(); it != freedObjectStats.constEnd(); ++it) {
freedObjectsSorted.push_back(std::make_pair(it.key(), it.value()));
}
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 93d110c19f..8c694af082 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -368,6 +368,7 @@ protected:
SavedToken *last_token = nullptr;
int functionNestingLevel = 0;
+ int classNestingLevel = 0;
enum CoverExpressionType {
CE_Invalid,
@@ -4278,16 +4279,16 @@ ClassDeclaration_Default: ClassDeclaration;
ClassLBrace: T_LBRACE;
/.
case $rule_number: {
- lexer->setStaticIsKeyword(true);
+ if (++classNestingLevel == 1)
+ lexer->setStaticIsKeyword(true);
} break;
./
ClassRBrace: T_RBRACE;
-/. case $rule_number: ./
-ClassStaticQualifier: T_STATIC;
/.
case $rule_number: {
- lexer->setStaticIsKeyword(false);
+ if (--classNestingLevel == 0)
+ lexer->setStaticIsKeyword(false);
} break;
./
@@ -4342,10 +4343,9 @@ ClassElement: MethodDefinition;
} break;
./
-ClassElement: ClassStaticQualifier MethodDefinition;
+ClassElement: T_STATIC MethodDefinition;
/.
case $rule_number: {
- lexer->setStaticIsKeyword(true);
AST::ClassElementList *node = new (pool) AST::ClassElementList(sym(2).PatternProperty, true);
sym(1).Node = node;
} break;
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index e764ebfb06..c2aa8f2aaa 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -367,7 +367,7 @@ public:
TypeArgumentList(Type *typeId)
: typeId(typeId)
- , next(nullptr)
+ , next(this)
{ kind = K; }
TypeArgumentList(TypeArgumentList *previous, Type *typeId)
diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp
index d44b5a29da..db5f1b92dd 100644
--- a/src/qml/parser/qqmljslexer.cpp
+++ b/src/qml/parser/qqmljslexer.cpp
@@ -75,7 +75,7 @@ void Lexer::setCode(const QString &code, int lineno, bool qmlMode)
_state.rawString = QStringView();
_state.codePtr = code.unicode();
- _endPtr = _state.codePtr + code.length();
+ _endPtr = _state.codePtr + code.size();
_state.tokenStartPtr = _state.codePtr;
_state.currentChar = u'\n';
diff --git a/src/qml/qml/ftw/qbipointer_p.h b/src/qml/qml/ftw/qbipointer_p.h
index 79a6676ebd..4039d6b60d 100644
--- a/src/qml/qml/ftw/qbipointer_p.h
+++ b/src/qml/qml/ftw/qbipointer_p.h
@@ -87,6 +87,11 @@ public:
inline T *asT1() const;
inline T2 *asT2() const;
+ friend size_t qHash(const QBiPointer<T, T2> &ptr, size_t seed = 0)
+ {
+ return qHash(ptr.isNull() ? quintptr(0) : ptr.ptr_value, seed);
+ }
+
private:
quintptr ptr_value = 0;
diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h
index 9beaffc2ae..5e002fcbee 100644
--- a/src/qml/qml/ftw/qhashedstring_p.h
+++ b/src/qml/qml/ftw/qhashedstring_p.h
@@ -200,12 +200,12 @@ QHashedStringRef::QHashedStringRef()
}
QHashedStringRef::QHashedStringRef(const QString &str)
-: m_data(str.constData()), m_length(str.length()), m_hash(0)
+: m_data(str.constData()), m_length(str.size()), m_hash(0)
{
}
QHashedStringRef::QHashedStringRef(QStringView str)
-: m_data(str.constData()), m_length(str.length()), m_hash(0)
+: m_data(str.constData()), m_length(str.size()), m_hash(0)
{
}
@@ -220,7 +220,7 @@ QHashedStringRef::QHashedStringRef(const QChar *data, int length, quint32 hash)
}
QHashedStringRef::QHashedStringRef(const QHashedString &string)
-: m_data(string.constData()), m_length(string.length()), m_hash(string.m_hash)
+: m_data(string.constData()), m_length(string.size()), m_hash(string.m_hash)
{
}
@@ -248,7 +248,7 @@ bool QHashedStringRef::operator==(const QHashedString &string) const
if (m_hash && string.m_hash && m_hash != string.m_hash)
return false;
QStringView view {m_data, m_length};
- QStringView otherView {string.constData(), string.length()};
+ QStringView otherView {string.constData(), string.size()};
return view == otherView;
}
@@ -424,7 +424,7 @@ quint32 QHashedString::stringHash(const char *data, int length)
void QHashedString::computeHash() const
{
- m_hash = stringHash(constData(), length());
+ m_hash = stringHash(constData(), size());
}
namespace QtPrivate {
diff --git a/src/qml/qml/ftw/qstringhash_p.h b/src/qml/qml/ftw/qstringhash_p.h
index 1d0e7d6e97..ee2928ee59 100644
--- a/src/qml/qml/ftw/qstringhash_p.h
+++ b/src/qml/qml/ftw/qstringhash_p.h
@@ -38,7 +38,7 @@ public:
}
QStringHashNode(const QHashedString &key)
- : length(key.length()), hash(key.hash()), symbolId(0)
+ : length(key.size()), hash(key.hash()), symbolId(0)
, arrayData(mutableStringData(key).d_ptr())
, strData(mutableStringData(key).data())
{
@@ -491,7 +491,7 @@ int QStringHash<T>::numBuckets() const
template<class T>
void QStringHash<T>::initializeNode(Node *node, const QHashedString &key)
{
- node->length = key.length();
+ node->length = key.size();
node->hash = key.hash();
node->arrayData = mutableStringData(key).d_ptr();
node->strData = mutableStringData(key).data();
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp
index 72a287c318..f0435ede45 100644
--- a/src/qml/qml/qqml.cpp
+++ b/src/qml/qml/qqml.cpp
@@ -581,7 +581,7 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data)
auto revisions = prepareRevisions(type.instanceMetaObject, added) + furtherRevisions;
uniqueRevisions(&revisions, type.version, added);
- for (QTypeRevision revision : qAsConst(revisions)) {
+ for (QTypeRevision revision : std::as_const(revisions)) {
if (revision.hasMajorVersion() && revision.majorVersion() > type.version.majorVersion())
break;
@@ -624,7 +624,7 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data)
revisions.append(added);
uniqueRevisions(&revisions, type.version, added);
- for (QTypeRevision revision : qAsConst(revisions)) {
+ for (QTypeRevision revision : std::as_const(revisions)) {
if (revision < added)
continue;
if (revision.hasMajorVersion() && revision.majorVersion() > type.version.majorVersion())
@@ -976,7 +976,8 @@ static ObjectLookupResult initObjectLookup(
// & 1 to tell the gc that this is not heap allocated; see markObjects in qv4lookup_p.h
l->qobjectFallbackLookup.metaObject = quintptr(metaObject) + 1;
l->qobjectFallbackLookup.coreIndex = coreIndex;
- l->qobjectFallbackLookup.notifyIndex = property.notifySignalIndex();
+ l->qobjectFallbackLookup.notifyIndex =
+ QMetaObjectPrivate::signalIndex(property.notifySignal());
l->qobjectFallbackLookup.isConstant = property.isConstant() ? 1 : 0;
return ObjectLookupResult::Fallback;
}
@@ -997,7 +998,7 @@ static bool initValueLookup(QV4::Lookup *l, QV4::ExecutableCompilationUnit *comp
const QByteArray name = compilationUnit->runtimeStrings[l->nameIndex]->toQString().toUtf8();
const int coreIndex = metaObject->indexOfProperty(name.constData());
QMetaType lookupType = metaObject->property(coreIndex).metaType();
- if (type.isValid() && lookupType != type)
+ if (!isTypeCompatible(type, lookupType))
return false;
l->qgadgetLookup.metaObject = quintptr(metaObject) + 1;
l->qgadgetLookup.coreIndex = coreIndex;
@@ -1587,7 +1588,12 @@ void AOTCompiledContext::initGetEnumLookup(
{
Q_ASSERT(!engine->hasError());
QV4::Lookup *l = compilationUnit->runtimeLookups + index;
- Q_ASSERT(metaObject);
+ if (!metaObject) {
+ engine->handle()->throwTypeError(
+ QStringLiteral("Cannot read property '%1' of undefined")
+ .arg(QString::fromUtf8(enumValue)));
+ return;
+ }
const int enumIndex = metaObject->indexOfEnumerator(enumerator);
const int value = metaObject->enumerator(enumIndex).keyToValue(enumValue);
l->qmlEnumValueLookup.encodedEnumValue = value;
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp
index df8c64dab0..2b94da14a5 100644
--- a/src/qml/qml/qqmlapplicationengine.cpp
+++ b/src/qml/qml/qqmlapplicationengine.cpp
@@ -26,7 +26,7 @@ QQmlApplicationEnginePrivate::~QQmlApplicationEnginePrivate()
void QQmlApplicationEnginePrivate::cleanUp()
{
Q_Q(QQmlApplicationEngine);
- for (auto obj : qAsConst(objects))
+ for (auto obj : std::as_const(objects))
obj->disconnect(q);
qDeleteAll(objects);
@@ -214,7 +214,7 @@ void QQmlApplicationEnginePrivate::finishLoad(QQmlComponent *c)
QQmlApplicationEngine engine;
// quit on error
- QObject::connect(&app, QQmlApplicationEngine::objectCreationFailed,
+ QObject::connect(&engine, QQmlApplicationEngine::objectCreationFailed,
QCoreApplication::instance(), QCoreApplication::quit,
Qt::QueuedConnection);
engine.load(QUrl());
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 49a72c17e9..10a9e60819 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -339,7 +339,7 @@ protected:
break;
default:
if (const QV4::QQmlValueTypeWrapper *vtw = result.as<const QV4::QQmlValueTypeWrapper>()) {
- if (vtw->d()->valueType()->metaType == pd->propType()) {
+ if (vtw->d()->valueType()->metaType() == pd->propType()) {
return vtw->write(m_target.data(), pd->coreIndex());
}
}
diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h
index 4c8c0f4e61..9b468f3f17 100644
--- a/src/qml/qml/qqmlbinding_p.h
+++ b/src/qml/qml/qqmlbinding_p.h
@@ -76,6 +76,10 @@ public:
};
QVariant evaluate();
+ bool evaluate(void *result, QMetaType type)
+ {
+ return QQmlJavaScriptExpression::evaluate(&result, &type, 0);
+ }
void expressionChanged() override;
@@ -110,10 +114,6 @@ protected:
QQmlPropertyData::WriteFlags flags);
QV4::ReturnedValue evaluate(bool *isUndefined);
- bool evaluate(void *result, QMetaType type)
- {
- return QQmlJavaScriptExpression::evaluate(&result, &type, 0);
- }
private:
static QQmlBinding *newBinding(const QQmlPropertyData *property);
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 8c74272457..8f1ed8b31c 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -350,7 +350,7 @@ bool QQmlComponentPrivate::setInitialProperty(
QV4::ScopedObject object(scope, QV4::QObjectWrapper::wrap(scope.engine, base));
QV4::ScopedString segment(scope);
- for (int i = 0; i < properties.length() - 1; ++i) {
+ for (int i = 0; i < properties.size() - 1; ++i) {
segment = scope.engine->newString(properties.at(i));
object = object->get(segment);
if (scope.engine->hasException)
@@ -408,7 +408,7 @@ QQmlComponent::~QQmlComponent()
if (isError()) {
qWarning() << "This may have been caused by one of the following errors:";
- for (const QQmlError &error : qAsConst(d->state.errors))
+ for (const QQmlError &error : std::as_const(d->state.errors))
qWarning().nospace().noquote() << QLatin1String(" ") << error;
}
@@ -489,6 +489,16 @@ bool QQmlComponent::isLoading() const
}
/*!
+ Returns true if the component was created in a QML files that specifies
+ \c{pragma ComponentBehavior: Bound}, otherwise returns false.
+ */
+bool QQmlComponent::isBound() const
+{
+ Q_D(const QQmlComponent);
+ return d->isBound();
+}
+
+/*!
\qmlproperty real Component::progress
The progress of loading the component, from 0.0 (nothing loaded)
to 1.0 (finished).
@@ -914,7 +924,7 @@ QObject *QQmlComponentPrivate::beginCreate(QQmlRefPointer<QQmlContextData> conte
Q_Q(QQmlComponent);
auto cleanup = qScopeGuard([this] {
if (!state.errors.isEmpty() && lcQmlComponentGeneral().isDebugEnabled()) {
- for (const auto &e : qAsConst(state.errors)) {
+ for (const auto &e : std::as_const(state.errors)) {
qCDebug(lcQmlComponentGeneral) << "QQmlComponent: " << e.toString();
}
}
@@ -986,7 +996,7 @@ void QQmlComponentPrivate::beginDeferred(QQmlEnginePrivate *enginePriv,
deferredState->reserve(ddata->deferredData.size());
- for (QQmlData::DeferredData *deferredData : qAsConst(ddata->deferredData)) {
+ for (QQmlData::DeferredData *deferredData : std::as_const(ddata->deferredData)) {
enginePriv->inProgressCreations++;
ConstructionState state;
@@ -1270,7 +1280,7 @@ namespace Heap {
Member(class, NoMark, QV4QPointer<QObject>, parent)
DECLARE_HEAP_OBJECT(QmlIncubatorObject, Object) {
- DECLARE_MARKOBJECTS(QmlIncubatorObject);
+ DECLARE_MARKOBJECTS(QmlIncubatorObject)
void init(QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous);
inline void destroy();
@@ -1331,7 +1341,7 @@ static void QQmlComponent_setQmlParent(QObject *me, QObject *parent)
QList<APF> functions = QQmlMetaType::parentFunctions();
bool needParent = false;
- for (int ii = 0; ii < functions.count(); ++ii) {
+ for (int ii = 0; ii < functions.size(); ++ii) {
QQmlPrivate::AutoParentResult res = functions.at(ii)(me, parent);
if (res == QQmlPrivate::Parented) {
needParent = false;
@@ -1375,12 +1385,12 @@ static void QQmlComponent_setQmlParent(QObject *me, QObject *parent)
The \a properties argument is specified as a map of property-value items. For example, the code
below creates an object with initial \c x and \c y values of 100 and 100, respectively:
- \js
+ \qml
const component = Qt.createComponent("Button.qml");
if (component.status === Component.Ready) {
component.createObject(parent, { x: 100, y: 100 });
}
- \endjs
+ \endqml
Dynamically created instances can be deleted with the \c destroy() method.
See \l {Dynamic QML Object Creation from JavaScript} for more information.
@@ -1410,17 +1420,25 @@ void QQmlComponentPrivate::setInitialProperties(QV4::ExecutionEngine *engine, QV
object = o;
const QStringList properties = name->toQString().split(QLatin1Char('.'));
bool isTopLevelProperty = properties.size() == 1;
- for (int i = 0; i < properties.length() - 1; ++i) {
+ for (int i = 0; i < properties.size() - 1; ++i) {
name = engine->newString(properties.at(i));
object = object->get(name);
if (engine->hasException || !object) {
break;
}
}
- if (engine->hasException || !object) {
+ if (engine->hasException) {
qmlWarning(createdComponent, engine->catchExceptionAsQmlError());
continue;
}
+ if (!object) {
+ QQmlError error;
+ error.setUrl(qmlContext ? qmlContext->qmlContext()->url() : QUrl());
+ error.setDescription(QLatin1String("Cannot resolve property \"%1\".")
+ .arg(properties.join(u'.')));
+ qmlWarning(createdComponent, error);
+ continue;
+ }
name = engine->newString(properties.last());
object->put(name, val);
if (engine->hasException) {
@@ -1568,7 +1586,7 @@ QObject *QQmlComponent::createObject(QObject *parent, const QVariantMap &propert
if (!d->requiredProperties().empty()) {
QList<QQmlError> errors;
- for (const auto &requiredProperty: qAsConst(d->requiredProperties())) {
+ for (const auto &requiredProperty: std::as_const(d->requiredProperties())) {
errors.push_back(QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(
requiredProperty));
}
@@ -1622,7 +1640,7 @@ QObject *QQmlComponent::createObject(QObject *parent, const QVariantMap &propert
The following example demonstrates how to use an incubator:
- \js
+ \qml
const component = Qt.createComponent("Button.qml");
const incubator = component.incubateObject(parent, { x: 10, y: 10 });
@@ -1635,7 +1653,7 @@ QObject *QQmlComponent::createObject(QObject *parent, const QVariantMap &propert
} else {
print("Object", incubator.object, "is ready immediately!");
}
- \endjs
+ \endqml
Dynamically created instances can be deleted with the \c destroy() method.
See \l {Dynamic QML Object Creation from JavaScript} for more information.
diff --git a/src/qml/qml/qqmlcomponent.h b/src/qml/qml/qqmlcomponent.h
index ccfece00f9..ca95d756a5 100644
--- a/src/qml/qml/qqmlcomponent.h
+++ b/src/qml/qml/qqmlcomponent.h
@@ -63,6 +63,8 @@ public:
bool isError() const;
bool isLoading() const;
+ bool isBound() const;
+
QList<QQmlError> errors() const;
Q_INVOKABLE QString errorString() const;
diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp
index baa8d6133e..0c9286693f 100644
--- a/src/qml/qml/qqmlcontext.cpp
+++ b/src/qml/qml/qqmlcontext.cpp
@@ -481,7 +481,7 @@ qsizetype QQmlContextPrivate::context_count(QQmlListProperty<QObject> *prop)
if (d->propertyValue(contextProperty).userType() != qMetaTypeId<QList<QObject*> >())
return 0;
else
- return ((const QList<QObject> *)d->propertyValue(contextProperty).constData())->count();
+ return ((const QList<QObject> *)d->propertyValue(contextProperty).constData())->size();
}
QObject *QQmlContextPrivate::context_at(QQmlListProperty<QObject> *prop, qsizetype index)
diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h
index aa50485a00..5489afb892 100644
--- a/src/qml/qml/qqmlcontext_p.h
+++ b/src/qml/qml/qqmlcontext_p.h
@@ -50,7 +50,7 @@ public:
int notifyIndex() const { return m_notifyIndex; }
void setNotifyIndex(int notifyIndex) { m_notifyIndex = notifyIndex; }
- int numPropertyValues() const { return m_propertyValues.count(); }
+ int numPropertyValues() const { return m_propertyValues.size(); }
void appendPropertyValue(const QVariant &value) { m_propertyValues.append(value); }
void setPropertyValue(int index, const QVariant &value) { m_propertyValues[index] = value; }
QVariant propertyValue(int index) const { return m_propertyValues[index]; }
diff --git a/src/qml/qml/qqmlcustomparser.cpp b/src/qml/qml/qqmlcustomparser.cpp
index fba805f084..f284a82dbe 100644
--- a/src/qml/qml/qqmlcustomparser.cpp
+++ b/src/qml/qml/qqmlcustomparser.cpp
@@ -1,6 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+#include "qml/qqmlpropertyvalidator_p.h"
#include "qqmlcustomparser_p.h"
#include <private/qv4compileddata_p.h>
@@ -81,7 +82,7 @@ void QQmlCustomParser::error(const QV4::CompiledData::Location &location, const
A valid \a ok must be provided, or the function will assert.
*/
-int QQmlCustomParser::evaluateEnum(const QByteArray& script, bool *ok) const
+int QQmlCustomParser::evaluateEnum(const QString &script, bool *ok) const
{
Q_ASSERT_X(ok, "QQmlCustomParser::evaluateEnum", "ok must not be a null pointer");
*ok = false;
@@ -91,15 +92,15 @@ int QQmlCustomParser::evaluateEnum(const QByteArray& script, bool *ok) const
// * <TypeName>.<ScopedEnumName>.<EnumValue>
auto nextDot = [&](int dot) {
- const int nextDot = script.indexOf('.', dot + 1);
- return (nextDot == script.length() - 1) ? -1 : nextDot;
+ const int nextDot = script.indexOf(u'.', dot + 1);
+ return (nextDot == script.size() - 1) ? -1 : nextDot;
};
int dot = nextDot(-1);
if (dot == -1)
return -1;
- QString scope = QString::fromUtf8(script.left(dot));
+ const QString scope = script.left(dot);
if (scope != QLatin1String("Qt")) {
if (imports.isNull())
@@ -108,23 +109,35 @@ int QQmlCustomParser::evaluateEnum(const QByteArray& script, bool *ok) const
if (imports.isT1()) {
QQmlImportNamespace *ns = nullptr;
- if (!imports.asT1()->resolveType(scope, &type, nullptr, &ns))
+
+ // Pass &recursionDetected to resolveType because that implicitly allows recursion.
+ // This way we can find the QQmlType of the document we're currently validating.
+ bool recursionDetected = false;
+
+ if (!imports.asT1()->resolveType(
+ scope, &type, nullptr, &ns, nullptr,
+ QQmlType::AnyRegistrationType, &recursionDetected)) {
return -1;
+ }
+
if (!type.isValid() && ns != nullptr) {
dot = nextDot(dot);
- if (dot == -1 || !imports.asT1()->resolveType(QString::fromUtf8(script.left(dot)),
- &type, nullptr, nullptr)) {
+ if (dot == -1 || !imports.asT1()->resolveType(
+ script.left(dot), &type, nullptr, nullptr, nullptr,
+ QQmlType::AnyRegistrationType, &recursionDetected)) {
return -1;
}
}
} else {
- QQmlTypeNameCache::Result result = imports.asT2()->query(scope);
+ // Allow recursion so that we can find enums from the same document.
+ const QQmlTypeNameCache::Result result
+ = imports.asT2()->query<QQmlImport::AllowRecursion>(scope);
if (result.isValid()) {
type = result.type;
} else if (result.importNamespace) {
dot = nextDot(dot);
if (dot != -1)
- type = imports.asT2()->query(QString::fromUtf8(script.left(dot))).type;
+ type = imports.asT2()->query<QQmlImport::AllowRecursion>(script.left(dot)).type;
}
}
@@ -133,19 +146,43 @@ int QQmlCustomParser::evaluateEnum(const QByteArray& script, bool *ok) const
const int dot2 = nextDot(dot);
const bool dot2Valid = (dot2 != -1);
- QByteArray enumValue = script.mid(dot2Valid ? dot2 + 1 : dot + 1);
- QByteArray scopedEnumName = (dot2Valid ? script.mid(dot + 1, dot2 - dot - 1) : QByteArray());
+ const QString enumValue = script.mid(dot2Valid ? dot2 + 1 : dot + 1);
+ const QString scopedEnumName = dot2Valid ? script.mid(dot + 1, dot2 - dot - 1) : QString();
+
+ // If we're currently validating the same document, we won't be able to find its enums using
+ // the QQmlType. However, we do have the property cache already, and that one contains the
+ // enums.
+ const QUrl documentUrl = validator ? validator->documentSourceUrl() : QUrl();
+ if (documentUrl.isValid() && documentUrl == type.sourceUrl()) {
+ const QQmlPropertyCache::ConstPtr rootCache = validator->rootPropertyCache();
+ const int count = rootCache->qmlEnumCount();
+ for (int ii = 0; ii < count; ++ii) {
+ const QQmlEnumData *enumData = rootCache->qmlEnum(ii);
+ if (!scopedEnumName.isEmpty() && scopedEnumName != enumData->name)
+ continue;
+
+ for (int jj = 0; jj < enumData->values.size(); ++jj) {
+ const QQmlEnumValue value = enumData->values.at(jj);
+ if (value.namedValue == enumValue) {
+ *ok = true;
+ return value.value;
+ }
+ }
+ }
+ return -1;
+ }
+
if (!scopedEnumName.isEmpty())
return type.scopedEnumValue(engine, scopedEnumName, enumValue, ok);
else
- return type.enumValue(engine, QHashedCStringRef(enumValue.constData(), enumValue.length()), ok);
+ return type.enumValue(engine, enumValue, ok);
}
- QByteArray enumValue = script.mid(dot + 1);
+ const QString enumValue = script.mid(dot + 1);
const QMetaObject *mo = &Qt::staticMetaObject;
int i = mo->enumeratorCount();
while (i--) {
- int v = mo->enumerator(i).keyToValue(enumValue.constData(), ok);
+ int v = mo->enumerator(i).keyToValue(enumValue.toUtf8().constData(), ok);
if (*ok)
return v;
}
diff --git a/src/qml/qml/qqmlcustomparser_p.h b/src/qml/qml/qqmlcustomparser_p.h
index afb5b810c2..98a9f21ae9 100644
--- a/src/qml/qml/qqmlcustomparser_p.h
+++ b/src/qml/qml/qqmlcustomparser_p.h
@@ -56,7 +56,7 @@ protected:
{ error(object->location, description); }
void error(const QV4::CompiledData::Location &location, const QString& description);
- int evaluateEnum(const QByteArray&, bool *ok) const;
+ int evaluateEnum(const QString &, bool *ok) const;
const QMetaObject *resolveType(const QString&) const;
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h
index f72feb2ce6..5b7c05c61e 100644
--- a/src/qml/qml/qqmldata_p.h
+++ b/src/qml/qml/qqmldata_p.h
@@ -103,7 +103,9 @@ public:
// set when at least one of the object's properties is intercepted
quint32 hasInterceptorMetaObject:1;
quint32 hasVMEMetaObject:1;
- quint32 dummy:8;
+ // If we have another wrapper for a const QObject * in the multiply wrapped QObjects.
+ quint32 hasConstWrapper: 1;
+ quint32 dummy:7;
// When bindingBitsSize < sizeof(ptr), we store the binding bit flags inside
// bindingBitsValue. When we need more than sizeof(ptr) bits, we allocated
diff --git a/src/qml/qml/qqmldatablob.cpp b/src/qml/qml/qqmldatablob.cpp
index 6114c2846a..a8a4537844 100644
--- a/src/qml/qml/qqmldatablob.cpp
+++ b/src/qml/qml/qqmldatablob.cpp
@@ -254,7 +254,7 @@ void QQmlDataBlob::setError(const QList<QQmlError> &errors)
Q_ASSERT(m_errors.isEmpty());
// m_errors must be set before the m_data fence
- m_errors.reserve(errors.count());
+ m_errors.reserve(errors.size());
for (const QQmlError &error : errors) {
if (error.url().isEmpty()) {
QQmlError mutableError = error;
@@ -269,7 +269,7 @@ void QQmlDataBlob::setError(const QList<QQmlError> &errors)
if (dumpErrors()) {
qWarning().nospace() << "Errors for " << urlString();
- for (int ii = 0; ii < errors.count(); ++ii)
+ for (int ii = 0; ii < errors.size(); ++ii)
qWarning().nospace() << " " << qPrintable(errors.at(ii).toString());
}
cancelAllWaitingFor();
@@ -313,7 +313,7 @@ void QQmlDataBlob::addDependency(QQmlDataBlob *blob)
status() == Error || status() == Complete || m_isDone)
return;
- for (const auto &existingDep: qAsConst(m_waitingFor))
+ for (const auto &existingDep: std::as_const(m_waitingFor))
if (existingDep.data() == blob)
return;
@@ -503,7 +503,7 @@ void QQmlDataBlob::tryDone()
void QQmlDataBlob::cancelAllWaitingFor()
{
- while (m_waitingFor.count()) {
+ while (m_waitingFor.size()) {
QQmlRefPointer<QQmlDataBlob> blob = m_waitingFor.takeLast();
Q_ASSERT(blob->m_waitingOnMe.contains(this));
@@ -514,7 +514,7 @@ void QQmlDataBlob::cancelAllWaitingFor()
void QQmlDataBlob::notifyAllWaitingOnMe()
{
- while (m_waitingOnMe.count()) {
+ while (m_waitingOnMe.size()) {
QQmlDataBlob *blob = m_waitingOnMe.takeLast();
Q_ASSERT(std::any_of(blob->m_waitingFor.constBegin(), blob->m_waitingFor.constEnd(),
@@ -533,7 +533,7 @@ void QQmlDataBlob::notifyComplete(QQmlDataBlob *blob)
m_inCallback = true;
QQmlRefPointer<QQmlDataBlob> blobRef;
- for (int i = 0; i < m_waitingFor.count(); ++i) {
+ for (int i = 0; i < m_waitingFor.size(); ++i) {
if (m_waitingFor.at(i).data() == blob) {
blobRef = m_waitingFor.takeAt(i);
break;
@@ -576,7 +576,7 @@ QString QQmlDataBlob::SourceCodeData::readAll(QString *error) const
}
QByteArray data(fileSize, Qt::Uninitialized);
- if (f.read(data.data(), data.length()) != data.length()) {
+ if (f.read(data.data(), data.size()) != data.size()) {
*error = f.errorString();
return QString();
}
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 57df383257..4e12ab93d8 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -245,7 +245,7 @@ void QQmlPrivate::qdeclarativeelement_destructor(QObject *o)
QQmlData::QQmlData()
: ownMemory(true), indestructible(true), explicitIndestructibleSet(false),
hasTaintedV4Object(false), isQueuedForDeletion(false), rootObjectInCreation(false),
- hasInterceptorMetaObject(false), hasVMEMetaObject(false),
+ hasInterceptorMetaObject(false), hasVMEMetaObject(false), hasConstWrapper(false),
bindingBitsArraySize(InlineBindingArraySize), notifyList(nullptr),
bindings(nullptr), signalHandlers(nullptr), nextContextObject(nullptr), prevContextObject(nullptr),
lineNumber(0), columnNumber(0), jsEngineId(0),
diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp
index 66192ff06c..a0b6440e7d 100644
--- a/src/qml/qml/qqmlerror.cpp
+++ b/src/qml/qml/qqmlerror.cpp
@@ -295,13 +295,13 @@ QDebug operator<<(QDebug debug, const QQmlError &error)
const QString code = stream.readAll();
const auto lines = QStringView{code}.split(QLatin1Char('\n'));
- if (lines.count() >= error.line()) {
+ if (lines.size() >= error.line()) {
const QStringView &line = lines.at(error.line() - 1);
debug << "\n " << line.toLocal8Bit().constData();
if(error.column() > 0) {
int column = qMax(0, error.column() - 1);
- column = qMin(column, line.length());
+ column = qMin(column, line.size());
QByteArray ind;
ind.reserve(column);
diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp
index 6229c0a0e4..319accb768 100644
--- a/src/qml/qml/qqmlextensionplugin.cpp
+++ b/src/qml/qml/qqmlextensionplugin.cpp
@@ -7,6 +7,21 @@
QT_BEGIN_NAMESPACE
/*!
+ \since 5.0
+ \inmodule QtQml
+ \class QQmlExtensionPlugin
+ \brief The QQmlExtensionPlugin class provides an abstract base for custom QML extension plugins
+ with custom type registration functions.
+
+ \ingroup plugins
+
+ \note If you need to write a plugin manually (which is rare) you should always use
+ \l{QQmlEngineExtensionPlugin}. QQmlExtensionPlugin only provides the registerTypes() and
+ unregisterTypes() functions in addition. You should not use them, but rather declare your
+ types with \l{QML_ELEMENT} and friends and have the build system take care of the registration.
+*/
+
+/*!
\since 5.14
\inmodule QtQml
\class QQmlEngineExtensionPlugin
@@ -25,7 +40,6 @@ QT_BEGIN_NAMESPACE
/*!
\fn void QQmlExtensionPlugin::registerTypes(const char *uri)
- \internal
Registers the QML types in the given \a uri. Subclasses should implement
this to call qmlRegisterType() for all types which are provided by the extension
@@ -107,9 +121,10 @@ void QQmlExtensionPlugin::unregisterTypes()
}
/*!
- \internal
-*/
-
+ Initializes the extension from the \a uri using the \a engine. Here an application
+ plugin might, for example, expose some data or objects to QML,
+ as context properties on the engine's root context.
+ */
void QQmlExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
Q_UNUSED(engine);
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp
index af2f4d8510..d616616ebd 100644
--- a/src/qml/qml/qqmlfile.cpp
+++ b/src/qml/qml/qqmlfile.cpp
@@ -29,6 +29,9 @@ static char file_string[] = "file";
#if defined(Q_OS_ANDROID)
static char assets_string[] = "assets";
static char content_string[] = "content";
+static char authority_externalstorage[] = "com.android.externalstorage.documents";
+static char authority_downloads_documents[] = "com.android.providers.downloads.documents";
+static char authority_media_documents[] = "com.android.providers.media.documents";
#endif
class QQmlFilePrivate;
@@ -410,8 +413,8 @@ bool QQmlFile::isSynchronous(const QUrl &url)
{
QString scheme = url.scheme();
- if ((scheme.length() == 4 && 0 == scheme.compare(QLatin1String(file_string), Qt::CaseInsensitive)) ||
- (scheme.length() == 3 && 0 == scheme.compare(QLatin1String(qrc_string), Qt::CaseInsensitive))) {
+ if ((scheme.size() == 4 && 0 == scheme.compare(QLatin1String(file_string), Qt::CaseInsensitive)) ||
+ (scheme.size() == 3 && 0 == scheme.compare(QLatin1String(qrc_string), Qt::CaseInsensitive))) {
return true;
#if defined(Q_OS_ANDROID)
@@ -435,20 +438,20 @@ Synchronous urls have a qrc:/ or file:// scheme.
*/
bool QQmlFile::isSynchronous(const QString &url)
{
- if (url.length() < 5 /* qrc:/ */)
+ if (url.size() < 5 /* qrc:/ */)
return false;
QChar f = url[0];
if (f == QLatin1Char('f') || f == QLatin1Char('F')) {
- return url.length() >= 7 /* file:// */ &&
+ return url.size() >= 7 /* file:// */ &&
url.startsWith(QLatin1String(file_string), Qt::CaseInsensitive) &&
url[4] == QLatin1Char(':') && url[5] == QLatin1Char('/') && url[6] == QLatin1Char('/');
} else if (f == QLatin1Char('q') || f == QLatin1Char('Q')) {
- return url.length() >= 5 /* qrc:/ */ &&
+ return url.size() >= 5 /* qrc:/ */ &&
url.startsWith(QLatin1String(qrc_string), Qt::CaseInsensitive) &&
url[3] == QLatin1Char(':') && url[4] == QLatin1Char('/');
@@ -469,6 +472,17 @@ bool QQmlFile::isSynchronous(const QString &url)
return false;
}
+#if defined(Q_OS_ANDROID)
+static bool hasLocalContentAuthority(const QUrl &url)
+{
+ const QString authority = url.authority();
+ return authority.isEmpty()
+ || authority == QLatin1String(authority_externalstorage)
+ || authority == QLatin1String(authority_downloads_documents)
+ || authority == QLatin1String(authority_media_documents);
+}
+#endif
+
/*!
Returns true if \a url is a local file that can be opened with QFile.
@@ -483,27 +497,27 @@ bool QQmlFile::isLocalFile(const QUrl &url)
// file: URLs with two slashes following the scheme can be interpreted as local files
// where the slashes are part of the path. Therefore, disregard the authority.
// See QUrl::toLocalFile().
- if (scheme.length() == 4 && scheme.startsWith(QLatin1String(file_string), Qt::CaseInsensitive))
+ if (scheme.size() == 4 && scheme.startsWith(QLatin1String(file_string), Qt::CaseInsensitive))
return true;
- if (scheme.length() == 3 && scheme.startsWith(QLatin1String(qrc_string), Qt::CaseInsensitive))
+ if (scheme.size() == 3 && scheme.startsWith(QLatin1String(qrc_string), Qt::CaseInsensitive))
return url.authority().isEmpty();
#if defined(Q_OS_ANDROID)
- if ((scheme.length() == 6
+ if (scheme.length() == 6
&& scheme.startsWith(QLatin1String(assets_string), Qt::CaseInsensitive))
- || (scheme.length() == 7
- && scheme.startsWith(QLatin1String(content_string), Qt::CaseInsensitive))) {
return url.authority().isEmpty();
- }
+ if (scheme.length() == 7
+ && scheme.startsWith(QLatin1String(content_string), Qt::CaseInsensitive))
+ return hasLocalContentAuthority(url);
#endif
return false;
}
-static bool hasSchemeAndNoAuthority(const QString &url, const char *scheme, qsizetype schemeLength)
+static bool hasScheme(const QString &url, const char *scheme, qsizetype schemeLength)
{
- const qsizetype urlLength = url.length();
+ const qsizetype urlLength = url.size();
if (urlLength < schemeLength + 1)
return false;
@@ -514,19 +528,41 @@ static bool hasSchemeAndNoAuthority(const QString &url, const char *scheme, qsiz
if (url[schemeLength] != QLatin1Char(':'))
return false;
+ return true;
+}
+
+static qsizetype authorityOffset(const QString &url, qsizetype schemeLength)
+{
+ const qsizetype urlLength = url.size();
+
if (urlLength < schemeLength + 3)
- return true;
+ return -1;
const QLatin1Char slash('/');
if (url[schemeLength + 1] == slash && url[schemeLength + 2] == slash) {
- // Exactly two slashes denote an authority. We don't want that.
+ // Exactly two slashes denote an authority.
if (urlLength < schemeLength + 4 || url[schemeLength + 3] != slash)
- return false;
+ return schemeLength + 3;
}
- return true;
+ return -1;
+}
+
+#if defined(Q_OS_ANDROID)
+static bool hasLocalContentAuthority(const QString &url, qsizetype schemeLength)
+{
+ const qsizetype offset = authorityOffset(url, schemeLength);
+ if (offset == -1)
+ return true; // no authority is a local authority.
+
+ const QString authorityAndPath = url.sliced(offset);
+ return authorityAndPath.startsWith(QLatin1String(authority_externalstorage))
+ || authorityAndPath.startsWith(QLatin1String(authority_downloads_documents))
+ || authorityAndPath.startsWith(QLatin1String(authority_media_documents));
}
+#endif
+
/*!
Returns true if \a url is a local file that can be opened with QFile.
@@ -536,7 +572,7 @@ Local file urls have either a qrc: or file: scheme.
*/
bool QQmlFile::isLocalFile(const QString &url)
{
- if (url.length() < 4 /* qrc: */)
+ if (url.size() < 4 /* qrc: */)
return false;
switch (url[0].toLatin1()) {
@@ -548,19 +584,22 @@ bool QQmlFile::isLocalFile(const QString &url)
const qsizetype fileLength = strlen(file_string);
return url.startsWith(QLatin1String(file_string, file_string + fileLength),
Qt::CaseInsensitive)
- && url.length() > fileLength
+ && url.size() > fileLength
&& url[fileLength] == QLatin1Char(':');
}
case 'q':
case 'Q':
- return hasSchemeAndNoAuthority(url, qrc_string, strlen(qrc_string));
+ return hasScheme(url, qrc_string, strlen(qrc_string))
+ && authorityOffset(url, strlen(qrc_string)) == -1;
#if defined(Q_OS_ANDROID)
case 'a':
case 'A':
- return hasSchemeAndNoAuthority(url, assets_string, strlen(assets_string));
+ return hasScheme(url, assets_string, strlen(assets_string))
+ && authorityOffset(url, strlen(assets_string)) == -1;
case 'c':
case 'C':
- return hasSchemeAndNoAuthority(url, content_string, strlen(content_string));
+ return hasScheme(url, content_string, strlen(content_string))
+ && hasLocalContentAuthority(url, strlen(content_string));
#endif
default:
break;
@@ -584,10 +623,12 @@ QString QQmlFile::urlToLocalFileOrQrc(const QUrl& url)
#if defined(Q_OS_ANDROID)
if (url.scheme().compare(QLatin1String("assets"), Qt::CaseInsensitive) == 0)
return url.authority().isEmpty() ? url.toString() : QString();
- if (url.scheme().compare(QLatin1String("content"), Qt::CaseInsensitive) == 0)
- return url.authority().isEmpty() ? url.toString() : QString();
+ if (url.scheme().compare(QLatin1String("content"), Qt::CaseInsensitive) == 0) {
+ if (hasLocalContentAuthority(url))
+ return url.toString();
+ return QString();
+ }
#endif
-
return url.toLocalFile();
}
@@ -605,7 +646,7 @@ static QString toLocalFile(const QString &url)
static bool isDoubleSlashed(const QString &url, qsizetype offset)
{
- const qsizetype urlLength = url.length();
+ const qsizetype urlLength = url.size();
if (urlLength < offset + 2)
return false;
@@ -628,7 +669,7 @@ QString QQmlFile::urlToLocalFileOrQrc(const QString& url)
if (url.startsWith(QLatin1String("qrc://"), Qt::CaseInsensitive)) {
// Exactly two slashes are bad because that's a URL authority.
// One slash is fine and >= 3 slashes are file.
- if (url.length() == 6 || url[6] != QLatin1Char('/')) {
+ if (url.size() == 6 || url[6] != QLatin1Char('/')) {
Q_ASSERT(isDoubleSlashed(url, strlen("qrc:")));
return QString();
}
@@ -638,7 +679,7 @@ QString QQmlFile::urlToLocalFileOrQrc(const QString& url)
if (url.startsWith(QLatin1String("qrc:"), Qt::CaseInsensitive)) {
Q_ASSERT(!isDoubleSlashed(url, strlen("qrc:")));
- if (url.length() > 4)
+ if (url.size() > 4)
return QLatin1Char(':') + QStringView{url}.mid(4);
return QStringLiteral(":");
}
@@ -646,8 +687,8 @@ QString QQmlFile::urlToLocalFileOrQrc(const QString& url)
#if defined(Q_OS_ANDROID)
if (url.startsWith(QLatin1String("assets:"), Qt::CaseInsensitive))
return isDoubleSlashed(url, strlen("assets:")) ? QString() : url;
- if (url.startsWith(QLatin1String("content:"), Qt::CaseInsensitive))
- return isDoubleSlashed(url, strlen("content:")) ? QString() : url;
+ if (hasScheme(url, content_string, strlen(content_string)))
+ return hasLocalContentAuthority(url, strlen(content_string)) ? url : QString();
#endif
return toLocalFile(url);
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index a7af7cedd6..e09b254f46 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -32,6 +32,8 @@
#include <algorithm>
#include <functional>
+using namespace Qt::Literals::StringLiterals;
+
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE)
@@ -123,7 +125,7 @@ QString resolveLocalUrl(const QString &url, const QString &relative)
QString base = baseRef + relative;
// Remove any relative directory elements in the path
- int length = base.length();
+ int length = base.size();
int index = 0;
while ((index = base.indexOf(QLatin1String("/."), index)) != -1) {
if ((length > (index + 2)) && (base.at(index + 2) == Dot) &&
@@ -235,7 +237,7 @@ void QQmlImports::populateCache(QQmlTypeNameCache *cache) const
{
const QQmlImportNamespace &set = m_unqualifiedset;
- for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
+ for (int ii = set.imports.size() - 1; ii >= 0; --ii) {
const QQmlImportInstance *import = set.imports.at(ii);
QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->version);
if (module) {
@@ -251,7 +253,7 @@ void QQmlImports::populateCache(QQmlTypeNameCache *cache) const
QQmlImportRef &typeimport = cache->m_namedImports[set.prefix];
typeimport.m_qualifier = set.prefix;
- for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
+ for (int ii = set.imports.size() - 1; ii >= 0; --ii) {
const QQmlImportInstance *import = set.imports.at(ii);
QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->version);
if (module) {
@@ -283,7 +285,7 @@ void findCompositeSingletons(const QQmlImportNamespace &set, QList<QQmlImports::
{
typedef QQmlDirComponents::const_iterator ConstIterator;
- for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
+ for (int ii = set.imports.size() - 1; ii >= 0; --ii) {
const QQmlImportInstance *import = set.imports.at(ii);
const QQmlDirComponents &components = import->qmlDirComponents;
@@ -373,7 +375,7 @@ QList<QQmlImports::ScriptReference> QQmlImports::resolvedScripts() const
const QQmlImportNamespace &set = m_unqualifiedset;
- for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
+ for (int ii = set.imports.size() - 1; ii >= 0; --ii) {
const QQmlImportInstance *import = set.imports.at(ii);
for (const QQmlDirParser::Script &script : import->qmlDirScripts) {
@@ -387,7 +389,7 @@ QList<QQmlImports::ScriptReference> QQmlImports::resolvedScripts() const
for (QQmlImportNamespace *ns = m_qualifiedSets.first(); ns; ns = m_qualifiedSets.next(ns)) {
const QQmlImportNamespace &set = *ns;
- for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
+ for (int ii = set.imports.size() - 1; ii >= 0; --ii) {
const QQmlImportInstance *import = set.imports.at(ii);
for (const QQmlDirParser::Script &script : import->qmlDirScripts) {
@@ -736,7 +738,7 @@ bool QQmlImports::resolveType(
m_typeLoader, unqualifiedtype, version_return, type_return, &m_base, errors,
registrationType, typeRecursionDetected))
return true;
- if (nameSpace->imports.count() == 1
+ if (nameSpace->imports.size() == 1
&& !nameSpace->imports.at(0)->isLibrary
&& type_return
&& nameSpace != &m_unqualifiedset) {
@@ -868,13 +870,13 @@ bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedS
});
setNeedsSorting(false);
}
- for (int i=0; i<imports.count(); ++i) {
+ for (int i=0; i<imports.size(); ++i) {
const QQmlImportInstance *import = imports.at(i);
if (import->resolveType(typeLoader, type, version_return, type_return, base,
typeRecursionDetected, registrationType, recursionRestriction, errors)) {
if (qmlCheckTypes()) {
// check for type clashes
- for (int j = i+1; j<imports.count(); ++j) {
+ for (int j = i+1; j<imports.size(); ++j) {
const QQmlImportInstance *import2 = imports.at(j);
if (import2->resolveType(typeLoader, type, version_return, nullptr, base,
nullptr, registrationType)) {
@@ -1010,9 +1012,9 @@ QString QQmlImports::resolvedUri(const QString &dir_arg, QQmlImportDatabase *dat
std::sort(paths.begin(), paths.end(), std::greater<QString>()); // Ensure subdirs preceed their parents.
QString stableRelativePath = dir;
- for (const QString &path : qAsConst(paths)) {
+ for (const QString &path : std::as_const(paths)) {
if (dir.startsWith(path)) {
- stableRelativePath = dir.mid(path.length()+1);
+ stableRelativePath = dir.mid(path.size()+1);
break;
}
}
@@ -1034,6 +1036,26 @@ QString QQmlImports::resolvedUri(const QString &dir_arg, QQmlImportDatabase *dat
return stableRelativePath;
}
+/* removes all file selector occurrences in path
+ firstPlus is the position of the initial '+' in the path
+ which we always have as we check for '+' to decide whether
+ we need to do some work at all
+*/
+static QString pathWithoutFileSelectors(QString path, // we want a copy of path
+ qsizetype firstPlus)
+{
+ do {
+ Q_ASSERT(path.at(firstPlus) == u'+');
+ const auto eos = path.size();
+ qsizetype terminatingSlashPos = firstPlus + 1;
+ while (terminatingSlashPos != eos && path.at(terminatingSlashPos) != u'/')
+ ++terminatingSlashPos;
+ path.remove(firstPlus, terminatingSlashPos - firstPlus + 1);
+ firstPlus = path.indexOf(u'+', firstPlus);
+ } while (firstPlus != -1);
+ return path;
+}
+
/*!
\internal
@@ -1080,10 +1102,42 @@ QTypeRevision QQmlImports::matchingQmldirVersion(
typedef QQmlDirComponents::const_iterator ConstIterator;
const QQmlDirComponents &components = qmldir.components();
+ QMultiHash<QString, ConstIterator> baseFileName2ConflictingComponents;
+
ConstIterator cend = components.constEnd();
for (ConstIterator cit = components.constBegin(); cit != cend; ++cit) {
for (ConstIterator cit2 = components.constBegin(); cit2 != cit; ++cit2) {
if (cit2->typeName == cit->typeName && cit2->version == cit->version) {
+ // ugly heuristic to deal with file selectors
+ const auto comp2PotentialFileSelectorPos = cit2->fileName.indexOf(u'+');
+ const bool comp2MightHaveFileSelector = comp2PotentialFileSelectorPos != -1;
+ /* If we detect conflicting paths, we check if they agree when we remove anything looking like a
+ file selector.
+ We need to create copies of the filenames, otherwise QString::replace would modify the
+ existing file-names
+ */
+ QString compFileName1 = cit->fileName;
+ QString compFileName2 = cit2->fileName;
+ if (auto fileSelectorPos1 = compFileName1.indexOf(u'+'); fileSelectorPos1 != -1) {
+ // existing entry was file selector entry, fix it up
+ // it could also be the case that _both_ are using file selectors
+ QString baseName = comp2MightHaveFileSelector ? pathWithoutFileSelectors(compFileName2,
+ comp2PotentialFileSelectorPos)
+ : compFileName2;
+ if (pathWithoutFileSelectors(compFileName1, fileSelectorPos1) == baseName) {
+ baseFileName2ConflictingComponents.insert(baseName, cit);
+ baseFileName2ConflictingComponents.insert(baseName, cit2);
+ continue;
+ }
+ // fall through to error case
+ } else if (comp2MightHaveFileSelector) {
+ // new entry contains file selector (and we now that cit did not)
+ if (pathWithoutFileSelectors(compFileName2, comp2PotentialFileSelectorPos) == compFileName1) {
+ baseFileName2ConflictingComponents.insert(compFileName1, cit2);
+ continue;
+ }
+ // fall through to error case
+ }
// This entry clashes with a predecessor
QQmlError error;
error.setDescription(QQmlImportDatabase::tr("\"%1\" version %2.%3 is defined more than once in module \"%4\"")
@@ -1097,6 +1151,14 @@ QTypeRevision QQmlImports::matchingQmldirVersion(
addVersion(cit->version);
}
+ // ensure that all components point to the actual base URL, and let the file selectors resolve them correctly during URL resolution
+ for (auto keyIt = baseFileName2ConflictingComponents.keyBegin(); keyIt != baseFileName2ConflictingComponents.keyEnd(); ++keyIt) {
+ const QString& baseFileName = *keyIt;
+ const auto conflictingComponents = baseFileName2ConflictingComponents.values(baseFileName);
+ for (ConstIterator component: conflictingComponents)
+ component->fileName = baseFileName;
+ }
+
typedef QList<QQmlDirParser::Script>::const_iterator SConstIterator;
const QQmlDirScripts &scripts = qmldir.scripts();
@@ -1496,7 +1558,7 @@ QUrl QQmlImports::urlFromLocalFileOrQrcOrUrl(const QString &file)
QUrl url(QLatin1String(file.at(0) == Colon ? "qrc" : "") + file);
// We don't support single character schemes as those conflict with windows drive letters.
- if (url.scheme().length() < 2)
+ if (url.scheme().size() < 2)
return QUrl::fromLocalFile(file);
return url;
}
@@ -1547,7 +1609,7 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
auto addEnvImportPath = [this](const char *var) {
if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty(var))) {
const QStringList paths = parseEnvPath(qEnvironmentVariable(var));
- for (int ii = paths.count() - 1; ii >= 0; --ii)
+ for (int ii = paths.size() - 1; ii >= 0; --ii)
addImportPath(paths.at(ii));
}
};
@@ -1562,7 +1624,7 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
auto addEnvPluginPath = [this](const char *var) {
if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty(var))) {
const QStringList paths = parseEnvPath(qEnvironmentVariable(var));
- for (int ii = paths.count() - 1; ii >= 0; --ii)
+ for (int ii = paths.size() - 1; ii >= 0; --ii)
addPluginPath(paths.at(ii));
}
};
@@ -1609,7 +1671,7 @@ void QQmlImportDatabase::addPluginPath(const QString& path)
QUrl url = QUrl(path);
if (url.isRelative() || url.scheme() == QLatin1String("file")
- || (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path
+ || (url.scheme().size() == 1 && QFile::exists(path)) ) { // windows path
QDir dir = QDir(path);
filePluginPath.prepend(dir.canonicalPath());
} else {
@@ -1643,7 +1705,7 @@ void QQmlImportDatabase::addImportPath(const QString& path)
cPath = QLatin1String("qrc") + path;
cPath.replace(Backslash, Slash);
} else if (url.isRelative() ||
- (url.scheme().length() == 1 && QFile::exists(path)) ) { // windows path
+ (url.scheme().size() == 1 && QFile::exists(path)) ) { // windows path
QDir dir = QDir(path);
cPath = dir.canonicalPath();
} else {
diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp
index 31dc1b449f..5e6afe25c6 100644
--- a/src/qml/qml/qqmlincubator.cpp
+++ b/src/qml/qml/qqmlincubator.cpp
@@ -233,6 +233,7 @@ void QQmlIncubatorPrivate::forceCompletion(QQmlInstantiationInterrupt &i)
}
}
+
void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i)
{
if (!compilationUnit)
@@ -244,6 +245,20 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i)
// get a copy of the engine pointer as it might get reset;
QQmlEnginePrivate *enginePriv = this->enginePriv;
+ // Incubating objects takes quite a bit more stack space than our usual V4 function
+ enum { EstimatedSizeInV4Frames = 2 };
+ QV4::ExecutionEngineCallDepthRecorder<EstimatedSizeInV4Frames> callDepthRecorder(
+ compilationUnit->engine);
+ if (callDepthRecorder.hasOverflow()) {
+ QQmlError error;
+ error.setMessageType(QtCriticalMsg);
+ error.setUrl(compilationUnit->url());
+ error.setDescription(QQmlComponent::tr("Maximum call stack size exceeded."));
+ errors << error;
+ progress = QQmlIncubatorPrivate::Completed;
+ goto finishIncubate;
+ }
+
if (!vmeGuard.isOK()) {
QQmlError error;
error.setMessageType(QtInfoMsg);
diff --git a/src/qml/qml/qqmlirloader.cpp b/src/qml/qml/qqmlirloader.cpp
index 4ead4d05cb..5c322ab021 100644
--- a/src/qml/qml/qqmlirloader.cpp
+++ b/src/qml/qml/qqmlirloader.cpp
@@ -98,7 +98,7 @@ QmlIR::Object *QQmlIRLoader::loadObject(const QV4::CompiledData::Object *seriali
object->bindings->append(b);
if (b->type() == QV4::CompiledData::Binding::Type_Script) {
functionIndices.append(b->value.compiledScriptIndex);
- b->value.compiledScriptIndex = functionIndices.count() - 1;
+ b->value.compiledScriptIndex = functionIndices.size() - 1;
QmlIR::CompiledFunctionOrExpression *foe = pool->New<QmlIR::CompiledFunctionOrExpression>();
foe->nameIndex = 0;
@@ -106,9 +106,9 @@ QmlIR::Object *QQmlIRLoader::loadObject(const QV4::CompiledData::Object *seriali
QQmlJS::AST::ExpressionNode *expr;
if (b->stringIndex != quint32(0)) {
- const int start = output->code.length();
+ const int start = output->code.size();
const QString script = output->stringAt(b->stringIndex);
- const int length = script.length();
+ const int length = script.size();
output->code.append(script);
expr = new (pool) FakeExpression(start, length);
} else
@@ -118,7 +118,7 @@ QmlIR::Object *QQmlIRLoader::loadObject(const QV4::CompiledData::Object *seriali
}
}
- Q_ASSERT(object->functionsAndExpressions->count == functionIndices.count());
+ Q_ASSERT(object->functionsAndExpressions->count == functionIndices.size());
for (uint i = 0; i < serializedObject->nSignals; ++i) {
const QV4::CompiledData::Signal *serializedSignal = serializedObject->signalAt(i);
@@ -174,7 +174,7 @@ QmlIR::Object *QQmlIRLoader::loadObject(const QV4::CompiledData::Object *seriali
const QV4::CompiledData::Function *compiledFunction = unit->functionAt(*functionIdx);
functionIndices.append(*functionIdx);
- f->index = functionIndices.count() - 1;
+ f->index = functionIndices.size() - 1;
f->location = compiledFunction->location;
f->nameIndex = compiledFunction->nameIndex;
f->returnType = compiledFunction->returnType;
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 3fb1bd45cd..304c5da29a 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -176,7 +176,7 @@ public:
~QQmlJavaScriptExpressionCapture()
{
if (capture.errorString) {
- for (int ii = 0; ii < capture.errorString->count(); ++ii)
+ for (int ii = 0; ii < capture.errorString->size(); ++ii)
qWarning("%s", qPrintable(capture.errorString->at(ii)));
delete capture.errorString;
capture.errorString = nullptr;
diff --git a/src/qml/qml/qqmllist.h b/src/qml/qml/qqmllist.h
index 051f3d67ff..4c1455b2e2 100644
--- a/src/qml/qml/qqmllist.h
+++ b/src/qml/qml/qqmllist.h
@@ -91,7 +91,7 @@ private:
reinterpret_cast<QList<T *> *>(p->data)->append(v);
}
static qsizetype qlist_count(QQmlListProperty *p) {
- return reinterpret_cast<QList<T *> *>(p->data)->count();
+ return reinterpret_cast<QList<T *> *>(p->data)->size();
}
static T *qlist_at(QQmlListProperty *p, qsizetype idx) {
return reinterpret_cast<QList<T *> *>(p->data)->at(idx);
@@ -118,7 +118,7 @@ private:
for (qsizetype i = 0; i < length; ++i)
stash.append(i == idx ? v : list->at(list, i));
list->clear(list);
- for (T *item : qAsConst(stash))
+ for (T *item : std::as_const(stash))
list->append(list, item);
} else {
stash.reserve(length - idx - 1);
@@ -149,7 +149,7 @@ private:
for (qsizetype i = 0; i < length; ++i)
stash.append(list->at(list, i));
list->clear(list);
- for (T *item : qAsConst(stash))
+ for (T *item : std::as_const(stash))
list->append(list, item);
}
};
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index cd356271a9..3ee8fee5c3 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -353,7 +353,7 @@ QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(const QV4::Functio
if (!argv[1].isString())
THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
QString fs = argv[1].toQString();
- if (fs.length())
+ if (fs.size())
format = fs.at(0).unicode();
}
int prec = 2;
@@ -415,7 +415,7 @@ ReturnedValue QQmlNumberExtension::method_fromLocaleString(const QV4::FunctionOb
}
QString ns = argv[numberIdx].toQString();
- if (!ns.length())
+ if (!ns.size())
RETURN_RESULT(QV4::Encode(Q_QNAN));
bool ok = false;
@@ -667,7 +667,9 @@ ReturnedValue QQmlLocaleData::method_get_ ## VARIABLE (const QV4::FunctionObject
LOCALE_STRING_PROPERTY(name)
LOCALE_STRING_PROPERTY(nativeLanguageName)
+#if QT_DEPRECATED_SINCE(6, 6)
QT_IGNORE_DEPRECATIONS(LOCALE_STRING_PROPERTY(nativeCountryName))
+#endif
LOCALE_STRING_PROPERTY(nativeTerritoryName)
LOCALE_STRING_PROPERTY(decimalPoint)
LOCALE_STRING_PROPERTY(groupSeparator)
@@ -714,7 +716,9 @@ QV4LocaleDataDeletable::QV4LocaleDataDeletable(QV4::ExecutionEngine *engine)
o->defineAccessorProperty(QStringLiteral("groupSeparator"), QQmlLocaleData::method_get_groupSeparator, nullptr);
o->defineAccessorProperty(QStringLiteral("decimalPoint"), QQmlLocaleData::method_get_decimalPoint, nullptr);
o->defineAccessorProperty(QStringLiteral("nativeLanguageName"), QQmlLocaleData::method_get_nativeLanguageName, nullptr);
+#if QT_DEPRECATED_SINCE(6, 6)
o->defineAccessorProperty(QStringLiteral("nativeCountryName"), QQmlLocaleData::method_get_nativeCountryName, nullptr);
+#endif
o->defineAccessorProperty(QStringLiteral("nativeTerritoryName"), QQmlLocaleData::method_get_nativeTerritoryName, nullptr);
o->defineAccessorProperty(QStringLiteral("zeroDigit"), QQmlLocaleData::method_get_zeroDigit, nullptr);
o->defineAccessorProperty(QStringLiteral("amText"), QQmlLocaleData::method_get_amText, nullptr);
@@ -866,10 +870,10 @@ ReturnedValue QQmlLocale::method_localeCompare(const QV4::FunctionObject *b, con
/*!
\qmlproperty string QtQml::Locale::name
- Holds the language and country of this locale as a
- string of the form "language_country", where
+ Holds the language and territory of this locale as a
+ string of the form "language_territory", where
language is a lowercase, two-letter ISO 639 language code,
- and country is an uppercase, two- or three-letter ISO 3166 country code.
+ and territory is an uppercase, two- or three-letter ISO 3166 territory code.
*/
/*!
@@ -1096,7 +1100,7 @@ ReturnedValue QQmlLocale::method_localeCompare(const QV4::FunctionObject *b, con
Holds a native name of the language for the locale. For example
"Schwiizertüütsch" for Swiss-German locale.
- \sa nativeCountryName
+ \sa nativeTerritoryName
*/
/*!
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index 598b8c0bd1..8d9718ffb8 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -165,7 +165,9 @@ struct QQmlLocaleData : public QV4::Object
static QV4::ReturnedValue method_get_name(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_get_nativeLanguageName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
+#if QT_DEPRECATED_SINCE(6, 6)
static QV4::ReturnedValue method_get_nativeCountryName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
+#endif
static QV4::ReturnedValue method_get_nativeTerritoryName(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_get_decimalPoint(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_get_groupSeparator(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index e87eed27bc..10f0a6f438 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -311,6 +311,7 @@ void QQmlMetaType::clearTypeRegistrations()
data->urlToNonFileImportType.clear();
data->metaObjectToType.clear();
data->undeletableTypes.clear();
+ data->propertyCaches.clear();
}
int QQmlMetaType::registerAutoParentFunction(const QQmlPrivate::RegisterAutoParent &function)
@@ -322,7 +323,7 @@ int QQmlMetaType::registerAutoParentFunction(const QQmlPrivate::RegisterAutoPare
data->parentFunctions.append(function.function);
- return data->parentFunctions.count() - 1;
+ return data->parentFunctions.size() - 1;
}
void QQmlMetaType::unregisterAutoParentFunction(const QQmlPrivate::AutoParentFunction &function)
@@ -390,7 +391,7 @@ static bool checkRegistration(
// There can also be types that aren't even gadgets, and there can be types for namespaces.
// We cannot check those, but namespaces should be uppercase.
- int typeNameLen = typeName.length();
+ int typeNameLen = typeName.size();
for (int ii = 0; ii < typeNameLen; ++ii) {
if (!(typeName.at(ii).isLetterOrNumber() || typeName.at(ii) == u'_')) {
QString failure(QCoreApplication::translate("qmlRegisterType", "Invalid QML %1 name \"%2\""));
@@ -834,7 +835,7 @@ QQmlMetaType::RegistrationResult QQmlMetaType::registerPluginTypes(
if (!failures.isEmpty()) {
if (errors) {
- for (const QString &failure : qAsConst(failures)) {
+ for (const QString &failure : std::as_const(failures)) {
QQmlError error;
error.setDescription(failure);
errors->prepend(error);
@@ -1148,7 +1149,7 @@ QQmlType QQmlMetaType::qmlType(const QString &qualifiedName, QTypeRevision versi
return QQmlType();
QHashedStringRef module(qualifiedName.constData(), slash);
- QHashedStringRef name(qualifiedName.constData() + slash + 1, qualifiedName.length() - slash - 1);
+ QHashedStringRef name(qualifiedName.constData() + slash + 1, qualifiedName.size() - slash - 1);
return qmlType(name, module, version);
}
@@ -1406,7 +1407,7 @@ void QQmlMetaType::registerMetaObjectForType(const QMetaObject *metaobject, QQml
static bool hasActiveInlineComponents(const QQmlTypePrivate *d)
{
- for (const QQmlType &ic : qAsConst(d->objectIdToICType)) {
+ for (const QQmlType &ic : std::as_const(d->objectIdToICType)) {
const QQmlTypePrivate *icPriv = ic.priv();
if (icPriv && icPriv->count() > 1)
return true;
@@ -1471,7 +1472,7 @@ QList<QString> QQmlMetaType::qmlTypeNames()
const QQmlMetaTypeDataPtr data;
QList<QString> names;
- names.reserve(data->nameToType.count());
+ names.reserve(data->nameToType.size());
QQmlMetaTypeData::Names::ConstIterator it = data->nameToType.cbegin();
while (it != data->nameToType.cend()) {
QQmlType t(*it);
@@ -1513,7 +1514,7 @@ QList<QQmlType> QQmlMetaType::qmlSingletonTypes()
const QQmlMetaTypeDataPtr data;
QList<QQmlType> retn;
- for (const auto t : qAsConst(data->nameToType)) {
+ for (const auto t : std::as_const(data->nameToType)) {
QQmlType type(t);
if (type.isSingleton())
retn.append(type);
@@ -1525,7 +1526,7 @@ const QQmlPrivate::CachedQmlUnit *QQmlMetaType::findCachedCompilationUnit(const
{
const QQmlMetaTypeDataPtr data;
- for (const auto lookup : qAsConst(data->lookupCachedQmlUnit)) {
+ for (const auto lookup : std::as_const(data->lookupCachedQmlUnit)) {
if (const QQmlPrivate::CachedQmlUnit *unit = lookup(uri)) {
QString error;
if (!QV4::ExecutableCompilationUnit::verifyHeader(unit->qmlData, QDateTime(), &error)) {
diff --git a/src/qml/qml/qqmlmetatypedata.cpp b/src/qml/qml/qqmlmetatypedata.cpp
index 2dd86c1c2a..ab6054349a 100644
--- a/src/qml/qml/qqmlmetatypedata.cpp
+++ b/src/qml/qml/qqmlmetatypedata.cpp
@@ -28,7 +28,7 @@ QQmlMetaTypeData::~QQmlMetaTypeData()
// This expects a "fresh" QQmlTypePrivate and adopts its reference.
void QQmlMetaTypeData::registerType(QQmlTypePrivate *priv)
{
- for (int i = 0; i < types.count(); ++i) {
+ for (int i = 0; i < types.size(); ++i) {
if (!types.at(i).isValid()) {
types[i] = QQmlType(priv);
priv->index = i;
@@ -37,7 +37,7 @@ void QQmlMetaTypeData::registerType(QQmlTypePrivate *priv)
}
}
types.append(QQmlType(priv));
- priv->index = types.count() - 1;
+ priv->index = types.size() - 1;
priv->release();
}
@@ -86,7 +86,7 @@ bool QQmlMetaTypeData::registerModuleTypes(const QString &uri)
QQmlPropertyCache::ConstPtr QQmlMetaTypeData::propertyCacheForVersion(
int index, QTypeRevision version) const
{
- return (index < typePropertyCaches.length())
+ return (index < typePropertyCaches.size())
? typePropertyCaches.at(index).value(version)
: QQmlPropertyCache::ConstPtr();
}
@@ -94,14 +94,14 @@ QQmlPropertyCache::ConstPtr QQmlMetaTypeData::propertyCacheForVersion(
void QQmlMetaTypeData::setPropertyCacheForVersion(int index, QTypeRevision version,
const QQmlPropertyCache::ConstPtr &cache)
{
- if (index >= typePropertyCaches.length())
+ if (index >= typePropertyCaches.size())
typePropertyCaches.resize(index + 1);
typePropertyCaches[index][version] = cache;
}
void QQmlMetaTypeData::clearPropertyCachesForVersion(int index)
{
- if (index < typePropertyCaches.length())
+ if (index < typePropertyCaches.size())
typePropertyCaches[index].clear();
}
@@ -167,13 +167,13 @@ QQmlPropertyCache::ConstPtr QQmlMetaTypeData::propertyCache(
QQmlPropertyCache::ConstPtr raw = propertyCache(type.metaObject(), combinedVersion);
QQmlPropertyCache::Ptr copied;
- for (int ii = 0; ii < types.count(); ++ii) {
+ for (int ii = 0; ii < types.size(); ++ii) {
const QQmlType &currentType = types.at(ii);
if (!currentType.isValid())
continue;
QTypeRevision rev = currentType.metaObjectRevision();
- int moIndex = types.count() - 1 - ii;
+ int moIndex = types.size() - 1 - ii;
if (raw->allowedRevision(moIndex) != rev) {
if (copied.isNull()) {
diff --git a/src/qml/qml/qqmlnotifier.cpp b/src/qml/qml/qqmlnotifier.cpp
index e36be3840e..e7b8799f82 100644
--- a/src/qml/qml/qqmlnotifier.cpp
+++ b/src/qml/qml/qqmlnotifier.cpp
@@ -89,10 +89,10 @@ void QQmlNotifierEndpoint::connect(QObject *source, int sourceSignal, QQmlEngine
QString sourceName;
QDebug(&sourceName) << source;
- sourceName = sourceName.left(sourceName.length() - 1);
+ sourceName = sourceName.left(sourceName.size() - 1);
QString engineName;
QDebug(&engineName).nospace() << engine;
- engineName = engineName.left(engineName.length() - 1);
+ engineName = engineName.left(engineName.size() - 1);
qFatal("QQmlEngine: Illegal attempt to connect to %s that is in"
" a different thread than the QML engine %s.", qPrintable(sourceName),
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 05951edfbc..64d1f79044 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -1408,16 +1408,24 @@ bool QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interrupt)
void *argv[] = { &bindable };
// allow interception
target->metaObject()->metacall(target, QMetaObject::BindableProperty, index, argv);
- bindable.setBinding(qmlBinding);
+ const bool success = bindable.setBinding(qmlBinding);
+
+ // Only pop_front after setting the binding as the bindings are refcounted.
sharedState->allQPropertyBindings.pop_front();
- if (auto priv = QPropertyBindingPrivate::get(qmlBinding); priv->hasCustomVTable()) {
- auto qmlBindingPriv = static_cast<QQmlPropertyBinding *>(priv);
- auto jsExpression = qmlBindingPriv->jsExpression();
- const bool canRemove = !qmlBinding.error().hasError() && !qmlBindingPriv->hasDependencies()
- && !jsExpression->hasUnresolvedNames();
- if (canRemove)
- bindable.takeBinding();
+
+ // If the binding was actually not set, it's deleted now.
+ if (success) {
+ if (auto priv = QPropertyBindingPrivate::get(qmlBinding); priv->hasCustomVTable()) {
+ auto qmlBindingPriv = static_cast<QQmlPropertyBinding *>(priv);
+ auto jsExpression = qmlBindingPriv->jsExpression();
+ const bool canRemove = !qmlBinding.error().hasError()
+ && !qmlBindingPriv->hasDependencies()
+ && !jsExpression->hasUnresolvedNames();
+ if (canRemove)
+ bindable.takeBinding();
+ }
}
+
if (watcher.hasRecursed() || interrupt.shouldInterrupt())
return false;
}
diff --git a/src/qml/qml/qqmlopenmetaobject.cpp b/src/qml/qml/qqmlopenmetaobject.cpp
index b6ea0ee2e6..cf51286677 100644
--- a/src/qml/qml/qqmlopenmetaobject.cpp
+++ b/src/qml/qml/qqmlopenmetaobject.cpp
@@ -59,19 +59,19 @@ int QQmlOpenMetaObjectType::signalOffset() const
int QQmlOpenMetaObjectType::propertyCount() const
{
- return d->names.count();
+ return d->names.size();
}
QByteArray QQmlOpenMetaObjectType::propertyName(int idx) const
{
- Q_ASSERT(idx >= 0 && idx < d->names.count());
+ Q_ASSERT(idx >= 0 && idx < d->names.size());
return d->mob.property(idx).name();
}
void QQmlOpenMetaObjectType::createProperties(const QVector<QByteArray> &names)
{
- for (int i = 0; i < names.count(); ++i) {
+ for (int i = 0; i < names.size(); ++i) {
const QByteArray &name = names.at(i);
const int id = d->mob.propertyCount();
d->mob.addSignal("__" + QByteArray::number(id) + "()");
@@ -114,7 +114,7 @@ int QQmlOpenMetaObjectType::createProperty(const QByteArray &name)
void QQmlOpenMetaObjectType::propertyCreated(int id, QMetaPropertyBuilder &builder)
{
- if (d->referers.count())
+ if (d->referers.size())
(*d->referers.begin())->propertyCreated(id, builder);
}
@@ -163,13 +163,13 @@ public:
};
inline void setPropertyValue(int idx, const QVariant &value) {
- if (data.count() <= idx)
+ if (data.size() <= idx)
data.resize(idx + 1);
data[idx].setValue(value);
}
inline Property &propertyRef(int idx) {
- if (data.count() <= idx)
+ if (data.size() <= idx)
data.resize(idx + 1);
Property &prop = data[idx];
if (!prop.valueSet)
@@ -188,7 +188,7 @@ public:
}
inline bool hasProperty(int idx) const {
- if (idx >= data.count())
+ if (idx >= data.size())
return false;
return data[idx].valueSet;
}
@@ -270,7 +270,7 @@ int QQmlOpenMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void *
propertyRead(propId);
*reinterpret_cast<QVariant *>(a[0]) = d->propertyValue(propId);
} else if (c == QMetaObject::WriteProperty) {
- if (propId >= d->data.count() || d->data.at(propId).value() != *reinterpret_cast<QVariant *>(a[0])) {
+ if (propId >= d->data.size() || d->data.at(propId).value() != *reinterpret_cast<QVariant *>(a[0])) {
propertyWrite(propId);
d->setPropertyValue(propId, propertyWriteValue(propId, *reinterpret_cast<QVariant *>(a[0])));
propertyWritten(propId);
@@ -375,7 +375,7 @@ void QQmlOpenMetaObject::setValues(const QHash<QByteArray, QVariant> &values, bo
d->type->createProperties(missingProperties);
d->dropPropertyCache();
- for (const QByteArray &name : qAsConst(missingProperties))
+ for (const QByteArray &name : std::as_const(missingProperties))
checkedSetValue(names[name], values[name], force);
}
@@ -461,12 +461,12 @@ QVariant QQmlOpenMetaObject::initialValue(int)
int QQmlOpenMetaObject::count() const
{
- return d->type->d->names.count();
+ return d->type->d->names.size();
}
QByteArray QQmlOpenMetaObject::name(int idx) const
{
- Q_ASSERT(idx >= 0 && idx < d->type->d->names.count());
+ Q_ASSERT(idx >= 0 && idx < d->type->d->names.size());
return d->type->d->mob.property(idx).name();
}
diff --git a/src/qml/qml/qqmlpluginimporter.cpp b/src/qml/qml/qqmlpluginimporter.cpp
index 62b3a4b4a4..0b14d1f561 100644
--- a/src/qml/qml/qqmlpluginimporter.cpp
+++ b/src/qml/qml/qqmlpluginimporter.cpp
@@ -91,7 +91,7 @@ static QStringList versionUriList(const QString &uri, QTypeRevision version)
{
QStringList result;
for (int mode = QQmlImports::FullyVersioned; mode <= QQmlImports::Unversioned; ++mode) {
- int index = uri.length();
+ int index = uri.size();
do {
QString versionUri = uri;
versionUri.insert(index, QQmlImports::versionString(
@@ -129,7 +129,7 @@ static bool unloadPlugin(const std::pair<const QString, QmlPlugin> &plugin)
void qmlClearEnginePlugins()
{
PluginMapPtr plugins(qmlPluginsById());
- for (const auto &plugin : qAsConst(*plugins))
+ for (const auto &plugin : std::as_const(*plugins))
unloadPlugin(plugin);
plugins->clear();
}
@@ -395,7 +395,7 @@ QString QQmlPluginImporter::resolvePlugin(const QString &qmldirPluginPath, const
if (!qmldirPluginPathIsRelative)
searchPaths.prepend(qmldirPluginPath);
- for (const QString &pluginPath : qAsConst(searchPaths)) {
+ for (const QString &pluginPath : std::as_const(searchPaths)) {
QString resolvedBasePath;
if (pluginPath == QLatin1String(".")) {
if (qmldirPluginPathIsRelative && !qmldirPluginPath.isEmpty()
@@ -501,7 +501,7 @@ bool QQmlPluginImporter::populatePluginDataVector(QVector<StaticPluginData> &res
QTypeRevision QQmlPluginImporter::importPlugins() {
const auto qmldirPlugins = qmldir->plugins();
- const int qmldirPluginCount = qmldirPlugins.count();
+ const int qmldirPluginCount = qmldirPlugins.size();
QTypeRevision importVersion = version;
// If the path contains a version marker or if we have more than one plugin,
@@ -550,7 +550,7 @@ QTypeRevision QQmlPluginImporter::importPlugins() {
return QTypeRevision();
for (const QString &versionUri : versionUris) {
- for (const StaticPluginData &pair : qAsConst(pluginPairs)) {
+ for (const StaticPluginData &pair : std::as_const(pluginPairs)) {
for (const QJsonValueConstRef metaTagUri : pair.uriList) {
if (versionUri == metaTagUri.toString()) {
staticPluginsFound++;
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index f2b4cc85ed..4cf57a9ae9 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -32,6 +32,7 @@
#include <cmath>
#include <QtQml/QQmlPropertyMap>
#include <QtCore/private/qproperty_p.h>
+#include <QtCore/qsequentialiterable.h>
Q_DECLARE_METATYPE(QList<int>)
Q_DECLARE_METATYPE(QList<qreal>)
@@ -248,7 +249,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name,
if (path.isEmpty()) return;
// Everything up to the last property must be an "object type" property
- for (int ii = 0; ii < path.count() - 1; ++ii) {
+ for (int ii = 0; ii < path.size() - 1; ++ii) {
const QStringView &pathName = path.at(ii);
// Types must begin with an uppercase letter (see checkRegistration()
@@ -264,7 +265,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name,
currentObject = qmlAttachedPropertiesObject(currentObject, func);
if (!currentObject) return; // Something is broken with the attachable type
} else if (r.importNamespace) {
- if (++ii == path.count())
+ if (++ii == path.size())
return; // No type following the namespace
// TODO: Do we really _not_ want to query the namespaced types here?
@@ -320,7 +321,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name,
return; // Not an object property
}
- if (ii == (path.count() - 2) && QQmlMetaType::isValueType(property->propType())) {
+ if (ii == (path.size() - 2) && QQmlMetaType::isValueType(property->propType())) {
// We're now at a value type property
const QMetaObject *valueTypeMetaObject = QQmlMetaType::metaObjectForValueType(property->propType());
if (!valueTypeMetaObject) return; // Not a value type
@@ -374,7 +375,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name,
auto findChangeSignal = [&](QStringView signalName) {
const QString changed = QStringLiteral("Changed");
if (signalName.endsWith(changed)) {
- const QStringView propName = signalName.first(signalName.length() - changed.length());
+ const QStringView propName = signalName.first(signalName.size() - changed.size());
const QQmlPropertyData *d = ddata->propertyCache->property(propName, currentObject, context);
while (d && d->isFunction())
d = ddata->propertyCache->overrideData(d);
@@ -392,7 +393,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name,
if (QmlIR::IRBuilder::isSignalPropertyName(terminalString)) {
QString signalName = terminalString.mid(2);
int firstNon_;
- int length = signalName.length();
+ int length = signalName.size();
for (firstNon_ = 0; firstNon_ < length; ++firstNon_)
if (signalName.at(firstNon_) != u'_')
break;
@@ -753,7 +754,7 @@ QString QQmlProperty::name() const
} else if (type() & SignalProperty) {
// ### Qt7: Return the original signal name here. Do not prepend "on"
QString name = QStringLiteral("on") + d->core.name(d->object);
- for (int i = 2, end = name.length(); i != end; ++i) {
+ for (int i = 2, end = name.size(); i != end; ++i) {
const QChar c = name.at(i);
if (c != u'_') {
name[i] = c.toUpper();
@@ -1451,7 +1452,7 @@ bool QQmlPropertyPrivate::write(
} else if (variantMetaType == QMetaType::fromType<QList<QObject *>>()) {
const QList<QObject *> &list = qvariant_cast<QList<QObject *> >(value);
- for (qsizetype ii = 0; ii < list.count(); ++ii) {
+ for (qsizetype ii = 0; ii < list.size(); ++ii) {
QObject *o = list.at(ii);
if (o && !QQmlMetaObject::canConvert(o, valueMetaObject))
o = nullptr;
@@ -1505,40 +1506,46 @@ bool QQmlPropertyPrivate::write(
}
if (!ok) {
// the only other options are that they are assigning a single value
- // to a sequence type property (eg, an int to a QList<int> property).
- // or that we encountered an interface type
+ // or a QVariantList to a sequence type property (eg, an int to a
+ // QList<int> property) or that we encountered an interface type.
// Note that we've already handled single-value assignment to QList<QUrl> properties.
- if (variantMetaType == QMetaType::fromType<int>()
- && propertyMetaType == QMetaType::fromType<QList<int>>()) {
- QList<int> list;
- list << value.toInt();
- v = QVariant::fromValue<QList<int> >(list);
- ok = true;
- } else if ((variantMetaType == QMetaType::fromType<double>()
- || variantMetaType == QMetaType::fromType<int>())
- && (propertyMetaType == QMetaType::fromType<QList<qreal>>())) {
- QList<qreal> list;
- list << value.toReal();
- v = QVariant::fromValue<QList<qreal> >(list);
- ok = true;
- } else if (variantMetaType == QMetaType::fromType<bool>()
- && propertyMetaType == QMetaType::fromType<QList<bool>>()) {
- QList<bool> list;
- list << value.toBool();
- v = QVariant::fromValue<QList<bool> >(list);
- ok = true;
- } else if (variantMetaType == QMetaType::fromType<QString>()
- && propertyMetaType == QMetaType::fromType<QList<QString>>()) {
- QList<QString> list;
- list << value.toString();
- v = QVariant::fromValue<QList<QString> >(list);
- ok = true;
- } else if (variantMetaType == QMetaType::fromType<QString>()
- && propertyMetaType == QMetaType::fromType<QStringList>()) {
- QStringList list;
- list << value.toString();
- v = QVariant::fromValue<QStringList>(list);
- ok = true;
+ QSequentialIterable iterable;
+ v = QVariant(propertyMetaType);
+ if (QMetaType::view(
+ propertyMetaType, v.data(),
+ QMetaType::fromType<QSequentialIterable>(),
+ &iterable)) {
+ const QMetaSequence metaContainer = iterable.metaContainer();
+ if (metaContainer.canAddValueAtEnd()) {
+ const QMetaType elementMetaType = iterable.valueMetaType();
+ void *container = iterable.mutableIterable();
+ if (variantMetaType == elementMetaType) {
+ metaContainer.addValueAtEnd(container, value.constData());
+ ok = true;
+ } else if (variantMetaType == QMetaType::fromType<QVariantList>()) {
+ const QVariantList list = value.value<QVariantList>();
+ for (const QVariant &valueElement : list) {
+ if (valueElement.metaType() == elementMetaType) {
+ metaContainer.addValueAtEnd(
+ container, valueElement.constData());
+ } else {
+ QVariant converted(elementMetaType);
+ QMetaType::convert(
+ valueElement.metaType(), valueElement.constData(),
+ elementMetaType, converted.data());
+ metaContainer.addValueAtEnd(
+ container, converted.constData());
+ }
+ }
+ ok = true;
+ } else {
+ QVariant converted = value;
+ if (converted.convert(elementMetaType)) {
+ metaContainer.addValueAtEnd(container, converted.constData());
+ ok = true;
+ }
+ }
+ }
}
}
@@ -1788,7 +1795,7 @@ QMetaMethod QQmlPropertyPrivate::findSignalByName(const QMetaObject *mo, const Q
// If no signal is found, but the signal is of the form "onBlahChanged",
// return the notify signal for the property "Blah"
if (name.endsWith("Changed")) {
- QByteArray propName = name.mid(0, name.length() - 7);
+ QByteArray propName = name.mid(0, name.size() - 7);
int propIdx = mo->indexOfProperty(propName.constData());
if (propIdx >= 0) {
QMetaProperty prop = mo->property(propIdx);
diff --git a/src/qml/qml/qqmlproperty.h b/src/qml/qml/qqmlproperty.h
index 4d4e1d0ebf..0878034bab 100644
--- a/src/qml/qml/qqmlproperty.h
+++ b/src/qml/qml/qqmlproperty.h
@@ -56,7 +56,7 @@ public:
QQmlProperty &operator=(const QQmlProperty &);
QQmlProperty(QQmlProperty &&other) noexcept : d(std::exchange(other.d, nullptr)) {}
- QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QQmlProperty);
+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QQmlProperty)
void swap(QQmlProperty &other) noexcept { qt_ptr_swap(d, other.d); }
bool operator==(const QQmlProperty &) const;
diff --git a/src/qml/qml/qqmlpropertybinding.cpp b/src/qml/qml/qqmlpropertybinding.cpp
index d55f1021f2..24fd48ffae 100644
--- a/src/qml/qml/qqmlpropertybinding.cpp
+++ b/src/qml/qml/qqmlpropertybinding.cpp
@@ -131,7 +131,8 @@ QUntypedPropertyBinding QQmlPropertyBinding::createFromBoundFunction(const QQmlP
void QQmlPropertyBindingJS::expressionChanged()
{
- if (!asBinding()->propertyDataPtr)
+ auto binding = asBinding();
+ if (!binding->propertyDataPtr)
return;
const auto currentTag = m_error.tag();
if (currentTag == InEvaluationLoop) {
@@ -151,8 +152,9 @@ void QQmlPropertyBindingJS::expressionChanged()
return;
}
m_error.setTag(InEvaluationLoop);
- asBinding()->evaluateRecursive();
- asBinding()->notifyRecursive();
+ PendingBindingObserverList bindingObservers;
+ binding->evaluateRecursive(bindingObservers);
+ binding->notifyNonRecursive(bindingObservers);
m_error.setTag(NoTag);
}
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index c61254ae56..cd6ca93356 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -15,8 +15,8 @@
#include <QtCore/qdebug.h>
#include <QtCore/QCryptographicHash>
+#include <QtCore/private/qtools_p.h>
-#include <ctype.h> // for toupper
#include <limits.h>
#include <algorithm>
@@ -166,9 +166,9 @@ QQmlPropertyCache::Ptr QQmlPropertyCache::copy(const QQmlMetaObjectPointer &mo,
QQmlPropertyCache::Ptr cache = QQmlPropertyCache::Ptr(
new QQmlPropertyCache(mo), QQmlPropertyCache::Ptr::Adopt);
cache->_parent.reset(this);
- cache->propertyIndexCacheStart = propertyIndexCache.count() + propertyIndexCacheStart;
- cache->methodIndexCacheStart = methodIndexCache.count() + methodIndexCacheStart;
- cache->signalHandlerIndexCacheStart = signalHandlerIndexCache.count() + signalHandlerIndexCacheStart;
+ cache->propertyIndexCacheStart = propertyIndexCache.size() + propertyIndexCacheStart;
+ cache->methodIndexCacheStart = methodIndexCache.size() + methodIndexCacheStart;
+ cache->signalHandlerIndexCacheStart = signalHandlerIndexCache.size() + signalHandlerIndexCacheStart;
cache->stringCache.linkAndReserve(stringCache, reserve);
cache->allowedRevisionCache = allowedRevisionCache;
cache->_defaultPropertyName = _defaultPropertyName;
@@ -214,7 +214,7 @@ void QQmlPropertyCache::appendProperty(const QString &name, QQmlPropertyData::Fl
if (overrideResult == InvalidOverride)
return;
- int index = propertyIndexCache.count();
+ int index = propertyIndexCache.size();
propertyIndexCache.append(data);
setNamedProperty(name, index + propertyOffset(), propertyIndexCache.data() + index,
@@ -235,7 +235,7 @@ void QQmlPropertyCache::appendSignal(const QString &name, QQmlPropertyData::Flag
handler.m_flags.setIsSignalHandler(true);
if (types) {
- const auto argumentCount = names.length();
+ const auto argumentCount = names.size();
QQmlPropertyCacheMethodArguments *args = createArgumentsObject(argumentCount, names);
new (args->types) QMetaType; // Invalid return type
::memcpy(args->types + 1, types, argumentCount * sizeof(QMetaType));
@@ -246,10 +246,10 @@ void QQmlPropertyCache::appendSignal(const QString &name, QQmlPropertyData::Flag
if (overrideResult == InvalidOverride)
return;
- int methodIndex = methodIndexCache.count();
+ int methodIndex = methodIndexCache.size();
methodIndexCache.append(data);
- int signalHandlerIndex = signalHandlerIndexCache.count();
+ int signalHandlerIndex = signalHandlerIndexCache.size();
signalHandlerIndexCache.append(handler);
QString handlerName = QLatin1String("on") + name;
@@ -267,7 +267,7 @@ void QQmlPropertyCache::appendMethod(const QString &name, QQmlPropertyData::Flag
const QList<QByteArray> &names,
const QVector<QMetaType> &parameterTypes)
{
- int argumentCount = names.count();
+ int argumentCount = names.size();
QQmlPropertyData data;
data.setPropType(returnType);
@@ -283,7 +283,7 @@ void QQmlPropertyCache::appendMethod(const QString &name, QQmlPropertyData::Flag
new (args->types + ii + 1) QMetaType(parameterTypes.at(ii));
data.setArguments(args);
- int methodIndex = methodIndexCache.count();
+ int methodIndex = methodIndexCache.size();
methodIndexCache.append(data);
setNamedProperty(name, methodIndex + methodOffset(), methodIndexCache.data() + methodIndex,
@@ -435,8 +435,8 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject,
data->load(m);
- Q_ASSERT((allowedRevisionCache.count() - 1) < Q_INT16_MAX);
- data->setMetaObjectOffset(allowedRevisionCache.count() - 1);
+ Q_ASSERT((allowedRevisionCache.size() - 1) < Q_INT16_MAX);
+ data->setMetaObjectOffset(allowedRevisionCache.size() - 1);
if (data->isSignal()) {
sigdata = &signalHandlerIndexCache[signalHandlerIndex - signalHandlerIndexCacheStart];
@@ -473,7 +473,7 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject,
QVarLengthArray<char, 128> str(length+3);
str[0] = 'o';
str[1] = 'n';
- str[2] = toupper(rawName[0]);
+ str[2] = QtMiscUtils::toAsciiUpper(rawName[0]);
if (length > 1)
memcpy(&str[3], &rawName[1], length - 1);
str[length + 2] = '\0';
@@ -516,8 +516,8 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject,
data->load(p);
data->setTypeVersion(typeVersion);
- Q_ASSERT((allowedRevisionCache.count() - 1) < Q_INT16_MAX);
- data->setMetaObjectOffset(allowedRevisionCache.count() - 1);
+ Q_ASSERT((allowedRevisionCache.size() - 1) < Q_INT16_MAX);
+ data->setMetaObjectOffset(allowedRevisionCache.size() - 1);
QQmlPropertyData *old = nullptr;
@@ -591,9 +591,9 @@ void QQmlPropertyCache::invalidate(const QMetaObject *metaObject)
int reserve = pc + mc + sc;
if (parent()) {
- propertyIndexCacheStart = parent()->propertyIndexCache.count() + parent()->propertyIndexCacheStart;
- methodIndexCacheStart = parent()->methodIndexCache.count() + parent()->methodIndexCacheStart;
- signalHandlerIndexCacheStart = parent()->signalHandlerIndexCache.count() + parent()->signalHandlerIndexCacheStart;
+ propertyIndexCacheStart = parent()->propertyIndexCache.size() + parent()->propertyIndexCacheStart;
+ methodIndexCacheStart = parent()->methodIndexCache.size() + parent()->methodIndexCacheStart;
+ signalHandlerIndexCacheStart = parent()->signalHandlerIndexCache.size() + parent()->signalHandlerIndexCacheStart;
stringCache.linkAndReserve(parent()->stringCache, reserve);
append(metaObject, QTypeRevision());
} else {
@@ -743,7 +743,7 @@ QString QQmlPropertyCache::signalParameterStringForJS(QV4::ExecutionEngine *engi
const QSet<QString> &illegalNames = engine->illegalNames();
QString parameters;
- for (int i = 0; i < parameterNameList.count(); ++i) {
+ for (int i = 0; i < parameterNameList.size(); ++i) {
if (i > 0)
parameters += QLatin1Char(',');
const QByteArray &param = parameterNameList.at(i);
@@ -976,13 +976,13 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) const
for (StringCache::ConstIterator iter = stringCache.begin(), cend = stringCache.end(); iter != cend; ++iter)
Insert::in(this, properties, methods, iter, iter.value().second);
- Q_ASSERT(properties.count() == propertyIndexCache.count());
- Q_ASSERT(methods.count() == methodIndexCache.count());
+ Q_ASSERT(properties.size() == propertyIndexCache.size());
+ Q_ASSERT(methods.size() == methodIndexCache.size());
std::sort(properties.begin(), properties.end(), Sort::lt);
std::sort(methods.begin(), methods.end(), Sort::lt);
- for (int ii = 0; ii < properties.count(); ++ii) {
+ for (int ii = 0; ii < properties.size(); ++ii) {
const QQmlPropertyData *data = properties.at(ii).second;
int notifierId = -1;
@@ -998,9 +998,10 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) const
property.setWritable(data->isWritable());
property.setResettable(data->isResettable());
property.setBindable(data->isBindable());
+ property.setAlias(data->isAlias());
}
- for (int ii = 0; ii < methods.count(); ++ii) {
+ for (int ii = 0; ii < methods.size(); ++ii) {
const QQmlPropertyData *data = methods.at(ii).second;
QByteArray returnType;
@@ -1014,7 +1015,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) const
QQmlPropertyCacheMethodArguments *arguments = nullptr;
if (data->hasArguments()) {
arguments = data->arguments();
- for (int ii = 0, end = arguments->names ? arguments->names->length() : 0;
+ for (int ii = 0, end = arguments->names ? arguments->names->size() : 0;
ii < end; ++ii) {
if (ii != 0)
signature.append(',');
@@ -1039,11 +1040,11 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) const
method.setReturnType(returnType);
}
- for (int ii = 0; ii < enumCache.count(); ++ii) {
+ for (int ii = 0; ii < enumCache.size(); ++ii) {
const QQmlEnumData &enumData = enumCache.at(ii);
QMetaEnumBuilder enumeration = builder.addEnumerator(enumData.name.toUtf8());
enumeration.setIsScoped(true);
- for (int jj = 0; jj < enumData.values.count(); ++jj) {
+ for (int jj = 0; jj < enumData.values.size(); ++jj) {
const QQmlEnumValue &value = enumData.values.at(jj);
enumeration.addKey(value.namedValue.toUtf8(), value.value);
}
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 681945d5f8..1ba23a15e3 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -343,7 +343,7 @@ inline const QQmlPropertyData *QQmlPropertyCache::property(int index) const
inline const QQmlPropertyData *QQmlPropertyCache::method(int index) const
{
- if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.count()))
+ if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.size()))
return nullptr;
if (index < methodIndexCacheStart)
@@ -358,7 +358,7 @@ inline const QQmlPropertyData *QQmlPropertyCache::method(int index) const
*/
inline const QQmlPropertyData *QQmlPropertyCache::signal(int index) const
{
- if (index < 0 || index >= (signalHandlerIndexCacheStart + signalHandlerIndexCache.count()))
+ if (index < 0 || index >= (signalHandlerIndexCacheStart + signalHandlerIndexCache.size()))
return nullptr;
if (index < signalHandlerIndexCacheStart)
@@ -371,7 +371,7 @@ inline const QQmlPropertyData *QQmlPropertyCache::signal(int index) const
inline QQmlEnumData *QQmlPropertyCache::qmlEnum(int index) const
{
- if (index < 0 || index >= enumCache.count())
+ if (index < 0 || index >= enumCache.size())
return nullptr;
return const_cast<QQmlEnumData *>(&enumCache.at(index));
@@ -379,7 +379,7 @@ inline QQmlEnumData *QQmlPropertyCache::qmlEnum(int index) const
inline int QQmlPropertyCache::methodIndexToSignalIndex(int index) const
{
- if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.count()))
+ if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.size()))
return index;
if (index < methodIndexCacheStart)
@@ -419,7 +419,7 @@ bool QQmlPropertyCache::isAllowedInRevision(const QQmlPropertyData *data) const
return true;
Q_ASSERT(offset >= 0);
- Q_ASSERT(offset < allowedRevisionCache.length());
+ Q_ASSERT(offset < allowedRevisionCache.size());
const QTypeRevision allowed = allowedRevisionCache[offset];
if (requested.hasMajorVersion()) {
@@ -434,7 +434,7 @@ bool QQmlPropertyCache::isAllowedInRevision(const QQmlPropertyData *data) const
int QQmlPropertyCache::propertyCount() const
{
- return propertyIndexCacheStart + propertyIndexCache.count();
+ return propertyIndexCacheStart + propertyIndexCache.size();
}
int QQmlPropertyCache::propertyOffset() const
@@ -444,7 +444,7 @@ int QQmlPropertyCache::propertyOffset() const
int QQmlPropertyCache::methodCount() const
{
- return methodIndexCacheStart + methodIndexCache.count();
+ return methodIndexCacheStart + methodIndexCache.size();
}
int QQmlPropertyCache::methodOffset() const
@@ -454,7 +454,7 @@ int QQmlPropertyCache::methodOffset() const
int QQmlPropertyCache::signalCount() const
{
- return signalHandlerIndexCacheStart + signalHandlerIndexCache.count();
+ return signalHandlerIndexCacheStart + signalHandlerIndexCache.size();
}
int QQmlPropertyCache::signalOffset() const
@@ -464,7 +464,7 @@ int QQmlPropertyCache::signalOffset() const
int QQmlPropertyCache::qmlEnumCount() const
{
- return enumCache.count();
+ return enumCache.size();
}
bool QQmlPropertyCache::callJSFactoryMethod(QObject *object, void **args) const
diff --git a/src/qml/qml/qqmlpropertycachecreator.cpp b/src/qml/qml/qqmlpropertycachecreator.cpp
index c6e628e02f..4bc903c22e 100644
--- a/src/qml/qml/qqmlpropertycachecreator.cpp
+++ b/src/qml/qml/qqmlpropertycachecreator.cpp
@@ -58,7 +58,7 @@ QByteArray QQmlPropertyCacheCreatorBase::createClassNameTypeByUrl(const QUrl &ur
if (lastSlash <= -1)
return QByteArray();
// ### this might not be correct for .ui.qml files
- const QStringView nameBase = QStringView{path}.mid(lastSlash + 1, path.length() - lastSlash - 5);
+ const QStringView nameBase = QStringView{path}.mid(lastSlash + 1, path.size() - lastSlash - 5);
// Not a reusable type if it doesn't start with a upper case letter.
if (nameBase.isEmpty() || !nameBase.at(0).isUpper())
return QByteArray();
@@ -94,8 +94,10 @@ bool QQmlBindingInstantiationContext::resolveInstantiatingProperty()
return true;
}
+ if (!referencingObjectPropertyCache)
+ return false;
+
Q_ASSERT(referencingObjectIndex >= 0);
- Q_ASSERT(referencingObjectPropertyCache);
Q_ASSERT(instantiatingBinding->propertyNameIndex != 0);
bool notInRevision = false;
diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h
index 6d0e5925a8..1901688174 100644
--- a/src/qml/qml/qqmlpropertycachecreator_p.h
+++ b/src/qml/qml/qqmlpropertycachecreator_p.h
@@ -720,8 +720,15 @@ inline QMetaType QQmlPropertyCacheCreator<ObjectContainer>::metaTypeForParameter
QQmlType::AnyRegistrationType, &selfReference))
return QMetaType();
- if (!qmltype.isComposite())
- return qmltype.typeId();
+ if (!qmltype.isComposite()) {
+ const QMetaType typeId = qmltype.typeId();
+ if (!typeId.isValid() && qmltype.isInlineComponentType()) {
+ const int objectId = qmltype.inlineComponentId();
+ return objectContainer->typeIdsForComponent(objectId).id;
+ } else {
+ return typeId;
+ }
+ }
if (selfReference)
return objectContainer->typeIdsForComponent().id;
@@ -823,7 +830,7 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasPropertie
do {
QVector<int> pendingObjects;
- for (int objectIndex: qAsConst(objectsWithAliases)) {
+ for (int objectIndex: std::as_const(objectsWithAliases)) {
const CompiledObject &object = *objectContainer->objectAt(objectIndex);
if (allAliasTargetsExist(object)) {
@@ -919,10 +926,16 @@ inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataFor
}
const auto referencedType = typeRef->type();
- if (referencedType.isValid())
+ if (referencedType.isValid()) {
*type = referencedType.typeId();
- else
+ if (!type->isValid() && referencedType.isInlineComponentType()) {
+ int objectId = referencedType.inlineComponentId();
+ *type = objectContainer->typeIdsForComponent(objectId).id;
+ Q_ASSERT(type->isValid());
+ }
+ } else {
*type = typeRef->compilationUnit()->typeIds.id;
+ }
*version = typeRef->version();
@@ -1000,8 +1013,8 @@ inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasesTo
QQmlPropertyCache::Ptr propertyCache = propertyCaches->ownAt(objectIndex);
Q_ASSERT(propertyCache);
- int effectiveSignalIndex = propertyCache->signalHandlerIndexCacheStart + propertyCache->propertyIndexCache.count();
- int effectivePropertyIndex = propertyCache->propertyIndexCacheStart + propertyCache->propertyIndexCache.count();
+ int effectiveSignalIndex = propertyCache->signalHandlerIndexCacheStart + propertyCache->propertyIndexCache.size();
+ int effectivePropertyIndex = propertyCache->propertyIndexCacheStart + propertyCache->propertyIndexCache.size();
int aliasIndex = 0;
auto alias = object.aliasesBegin();
diff --git a/src/qml/qml/qqmlpropertycachevector_p.h b/src/qml/qml/qqmlpropertycachevector_p.h
index 71a4896315..6386795086 100644
--- a/src/qml/qml/qqmlpropertycachevector_p.h
+++ b/src/qml/qml/qqmlpropertycachevector_p.h
@@ -36,10 +36,10 @@ public:
return data.resize(size);
}
- int count() const { return data.count(); }
+ int count() const { return data.size(); }
void clear()
{
- for (int i = 0; i < data.count(); ++i) {
+ for (int i = 0; i < data.size(); ++i) {
const auto &cache = data.at(i);
if (cache.isT2()) {
if (QQmlPropertyCache *data = cache.asT2())
diff --git a/src/qml/qml/qqmlpropertydata_p.h b/src/qml/qml/qqmlpropertydata_p.h
index 83ae5ff9a8..dd9aa21c7b 100644
--- a/src/qml/qml/qqmlpropertydata_p.h
+++ b/src/qml/qml/qqmlpropertydata_p.h
@@ -240,7 +240,6 @@ public:
{
Q_ASSERT(idx >= std::numeric_limits<qint16>::min());
Q_ASSERT(idx <= std::numeric_limits<qint16>::max());
- Q_ASSERT(idx != m_coreIndex);
m_overrideIndex = qint16(idx);
}
diff --git a/src/qml/qml/qqmlpropertyresolver.cpp b/src/qml/qml/qqmlpropertyresolver.cpp
index 6be2c205ed..ff29c38997 100644
--- a/src/qml/qml/qqmlpropertyresolver.cpp
+++ b/src/qml/qml/qqmlpropertyresolver.cpp
@@ -44,7 +44,7 @@ const QQmlPropertyData *QQmlPropertyResolver::signal(const QString &name, bool *
}
if (name.endsWith(QLatin1String("Changed"))) {
- QString propName = name.mid(0, name.length() - static_cast<int>(strlen("Changed")));
+ QString propName = name.mid(0, name.size() - static_cast<int>(strlen("Changed")));
d = property(propName, notInRevision);
if (d)
diff --git a/src/qml/qml/qqmlpropertyvalidator_p.h b/src/qml/qml/qqmlpropertyvalidator_p.h
index bd81b75e78..e1154347ec 100644
--- a/src/qml/qml/qqmlpropertyvalidator_p.h
+++ b/src/qml/qml/qqmlpropertyvalidator_p.h
@@ -32,6 +32,9 @@ public:
QVector<QQmlError> validate();
+ QQmlPropertyCache::ConstPtr rootPropertyCache() const { return propertyCaches.at(0); }
+ QUrl documentSourceUrl() const { return compilationUnit->url(); }
+
private:
QVector<QQmlError> validateObject(
int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding,
diff --git a/src/qml/qml/qqmlproxymetaobject.cpp b/src/qml/qml/qqmlproxymetaobject.cpp
index 9a5347bd74..ad67856c02 100644
--- a/src/qml/qml/qqmlproxymetaobject.cpp
+++ b/src/qml/qml/qqmlproxymetaobject.cpp
@@ -32,8 +32,8 @@ QQmlProxyMetaObject::~QQmlProxyMetaObject()
QObject *QQmlProxyMetaObject::getProxy(int index)
{
if (!proxies) {
- proxies = new QObject *[metaObjects->count()];
- ::memset(proxies, 0, sizeof(QObject *) * metaObjects->count());
+ proxies = new QObject *[metaObjects->size()];
+ ::memset(proxies, 0, sizeof(QObject *) * metaObjects->size());
}
if (!proxies[index]) {
@@ -71,7 +71,7 @@ int QQmlProxyMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void
if (id < metaObjects->constLast().propertyOffset)
break;
- for (int ii = 0; ii < metaObjects->count(); ++ii) {
+ for (int ii = 0; ii < metaObjects->size(); ++ii) {
const int globalPropertyOffset = metaObjects->at(ii).propertyOffset;
if (id < globalPropertyOffset)
continue;
@@ -94,7 +94,7 @@ int QQmlProxyMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void
return -1;
}
- for (int ii = 0; ii < metaObjects->count(); ++ii) {
+ for (int ii = 0; ii < metaObjects->size(); ++ii) {
const int globalMethodOffset = metaObjects->at(ii).methodOffset;
if (id < globalMethodOffset)
continue;
diff --git a/src/qml/qml/qqmlscriptblob.cpp b/src/qml/qml/qqmlscriptblob.cpp
index 5bfa6d3470..505a57636f 100644
--- a/src/qml/qml/qqmlscriptblob.cpp
+++ b/src/qml/qml/qqmlscriptblob.cpp
@@ -126,7 +126,7 @@ void QQmlScriptBlob::done()
return;
// Check all script dependencies for errors
- for (int ii = 0; ii < m_scripts.count(); ++ii) {
+ for (int ii = 0; ii < m_scripts.size(); ++ii) {
const ScriptReference &script = m_scripts.at(ii);
Q_ASSERT(script.script->isCompleteOrError());
if (script.script->isError()) {
@@ -147,7 +147,7 @@ void QQmlScriptBlob::done()
QSet<QString> ns;
- for (int scriptIndex = 0; scriptIndex < m_scripts.count(); ++scriptIndex) {
+ for (int scriptIndex = 0; scriptIndex < m_scripts.size(); ++scriptIndex) {
const ScriptReference &script = m_scripts.at(scriptIndex);
m_scriptData->scripts.append(script.script);
diff --git a/src/qml/qml/qqmlscriptdata.cpp b/src/qml/qml/qqmlscriptdata.cpp
index 994a76c96e..b5ba04c93e 100644
--- a/src/qml/qml/qqmlscriptdata.cpp
+++ b/src/qml/qml/qqmlscriptdata.cpp
@@ -55,14 +55,14 @@ QQmlRefPointer<QQmlContextData> QQmlScriptData::qmlContextDataForContext(
QV4::Scope scope(v4);
QV4::ScopedObject scriptsArray(scope);
if (qmlContextData->importedScripts().isNullOrUndefined()) {
- scriptsArray = v4->newArrayObject(scripts.count());
+ scriptsArray = v4->newArrayObject(scripts.size());
qmlContextData->setImportedScripts(
QV4::PersistentValue(v4, scriptsArray.asReturnedValue()));
} else {
scriptsArray = qmlContextData->importedScripts().valueRef();
}
QV4::ScopedValue v(scope);
- for (int ii = 0; ii < scripts.count(); ++ii) {
+ for (int ii = 0; ii < scripts.size(); ++ii) {
v = scripts.at(ii)->scriptData()->scriptValueForContext(qmlContextData);
scriptsArray->put(ii, v);
}
diff --git a/src/qml/qml/qqmlscriptstring.cpp b/src/qml/qml/qqmlscriptstring.cpp
index d872d4b55c..370573b199 100644
--- a/src/qml/qml/qqmlscriptstring.cpp
+++ b/src/qml/qml/qqmlscriptstring.cpp
@@ -154,7 +154,7 @@ Otherwise returns a null QString.
QString QQmlScriptString::stringLiteral() const
{
if (d->isStringLiteral)
- return d->script.mid(1, d->script.length()-2);
+ return d->script.mid(1, d->script.size()-2);
return QString();
}
diff --git a/src/qml/qml/qqmltype.cpp b/src/qml/qml/qqmltype.cpp
index 5c3cfa94a5..52437348d9 100644
--- a/src/qml/qml/qqmltype.cpp
+++ b/src/qml/qml/qqmltype.cpp
@@ -208,7 +208,7 @@ void QQmlTypePrivate::init() const
mo, baseMetaObject, metaObjects.isEmpty() ? nullptr
: metaObjects.constLast().metaObject));
- for (int ii = 0; ii < metaObjects.count(); ++ii) {
+ for (int ii = 0; ii < metaObjects.size(); ++ii) {
metaObjects[ii].propertyOffset =
metaObjects.at(ii).metaObject->propertyOffset();
metaObjects[ii].methodOffset =
@@ -320,7 +320,7 @@ void QQmlTypePrivate::insertEnums(const QMetaObject *metaObject) const
if (isScoped) {
scopedEnums << scoped;
- scopedEnumIndex.insert(QString::fromUtf8(e.name()), scopedEnums.count()-1);
+ scopedEnumIndex.insert(QString::fromUtf8(e.name()), scopedEnums.size()-1);
}
}
}
@@ -371,7 +371,7 @@ void QQmlTypePrivate::createEnumConflictReport(const QMetaObject *metaObject, co
qWarning().noquote() << QLatin1String("Possible conflicting items:");
// find items with conflicting key
- for (const auto &i : qAsConst(enumInfoList)) {
+ for (const auto &i : std::as_const(enumInfoList)) {
if (i.enumKey == conflictingKey)
qWarning().noquote().nospace() << " " << i.metaObjectName << "." << i.enumName << "." << i.enumKey << " from scope "
<< i.metaEnumScope << " injected by " << i.path.join(QLatin1String("->"));
@@ -392,13 +392,13 @@ void QQmlTypePrivate::insertEnumsFromPropertyCache(
QStringHash<int> *scoped = new QStringHash<int>();
QQmlEnumData *enumData = currentCache->qmlEnum(ii);
- for (int jj = 0; jj < enumData->values.count(); ++jj) {
+ for (int jj = 0; jj < enumData->values.size(); ++jj) {
const QQmlEnumValue &value = enumData->values.at(jj);
enums.insert(value.namedValue, value.value);
scoped->insert(value.namedValue, value.value);
}
scopedEnums << scoped;
- scopedEnumIndex.insert(enumData->name, scopedEnums.count()-1);
+ scopedEnumIndex.insert(enumData->name, scopedEnums.size()-1);
}
}
insertEnums(cppMetaObject);
@@ -822,7 +822,7 @@ int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, int index, const QV4::S
*ok = true;
if (d) {
- Q_ASSERT(index > -1 && index < d->scopedEnums.count());
+ Q_ASSERT(index > -1 && index < d->scopedEnums.size());
int *rv = d->scopedEnums.at(index)->value(name);
if (rv)
return *rv;
@@ -839,7 +839,7 @@ int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, int index, const QStrin
*ok = true;
if (d) {
- Q_ASSERT(index > -1 && index < d->scopedEnums.count());
+ Q_ASSERT(index > -1 && index < d->scopedEnums.size());
int *rv = d->scopedEnums.at(index)->value(name);
if (rv)
return *rv;
@@ -857,11 +857,11 @@ int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, const QByteArray &scope
d->initEnums(engine);
- int *rv = d->scopedEnumIndex.value(QHashedCStringRef(scopedEnumName.constData(), scopedEnumName.length()));
+ int *rv = d->scopedEnumIndex.value(QHashedCStringRef(scopedEnumName.constData(), scopedEnumName.size()));
if (rv) {
int index = *rv;
- Q_ASSERT(index > -1 && index < d->scopedEnums.count());
- rv = d->scopedEnums.at(index)->value(QHashedCStringRef(name.constData(), name.length()));
+ Q_ASSERT(index > -1 && index < d->scopedEnums.size());
+ rv = d->scopedEnums.at(index)->value(QHashedCStringRef(name.constData(), name.size()));
if (rv)
return *rv;
}
@@ -882,7 +882,7 @@ int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, QStringView scopedEnumN
int *rv = d->scopedEnumIndex.value(QHashedStringRef(scopedEnumName));
if (rv) {
int index = *rv;
- Q_ASSERT(index > -1 && index < d->scopedEnums.count());
+ Q_ASSERT(index > -1 && index < d->scopedEnums.size());
rv = d->scopedEnums.at(index)->value(QHashedStringRef(name));
if (rv)
return *rv;
diff --git a/src/qml/qml/qqmltypecompiler.cpp b/src/qml/qml/qqmltypecompiler.cpp
index 64a9238739..c2aff473fd 100644
--- a/src/qml/qml/qqmltypecompiler.cpp
+++ b/src/qml/qml/qqmltypecompiler.cpp
@@ -117,7 +117,7 @@ QQmlRefPointer<QV4::ExecutableCompilationUnit> QQmlTypeCompiler::compile()
document->jsModule.fileName = typeData->urlString();
document->jsModule.finalUrl = typeData->finalUrlString();
QmlIR::JSCodeGen v4CodeGenerator(document, engine->v4engine()->illegalNames());
- for (QmlIR::Object *object : qAsConst(document->objects)) {
+ for (QmlIR::Object *object : std::as_const(document->objects)) {
if (!v4CodeGenerator.generateRuntimeFunctions(object)) {
Q_ASSERT(v4CodeGenerator.hasError());
recordError(v4CodeGenerator.error());
@@ -243,7 +243,7 @@ void QQmlTypeCompiler::addImport(const QString &module, const QString &qualifier
const quint32 moduleIdx = registerString(module);
const quint32 qualifierIdx = registerString(qualifier);
- for (int i = 0, count = document->imports.count(); i < count; ++i) {
+ for (int i = 0, count = document->imports.size(); i < count; ++i) {
const QV4::CompiledData::Import *existingImport = document->imports.at(i);
if (existingImport->type == QV4::CompiledData::Import::ImportLibrary
&& existingImport->uriIndex == moduleIdx
@@ -282,7 +282,7 @@ SignalHandlerResolver::SignalHandlerResolver(QQmlTypeCompiler *typeCompiler)
bool SignalHandlerResolver::resolveSignalHandlerExpressions()
{
- for (int objectIndex = 0; objectIndex < qmlObjects.count(); ++objectIndex) {
+ for (int objectIndex = 0; objectIndex < qmlObjects.size(); ++objectIndex) {
const QmlIR::Object * const obj = qmlObjects.at(objectIndex);
QQmlPropertyCache::ConstPtr cache = propertyCaches->at(objectIndex);
if (!cache)
@@ -335,7 +335,7 @@ bool SignalHandlerResolver::resolveSignalHandlerExpressions(
QString qPropertyName;
if (signalName.endsWith(QLatin1String("Changed")))
- qPropertyName = signalName.mid(0, signalName.length() - static_cast<int>(strlen("Changed")));
+ qPropertyName = signalName.mid(0, signalName.size() - static_cast<int>(strlen("Changed")));
bool notInRevision = false;
const QQmlPropertyData * const signal = resolver.signal(signalName, &notInRevision);
@@ -353,7 +353,7 @@ bool SignalHandlerResolver::resolveSignalHandlerExpressions(
bool unnamedParameter = false;
QList<QByteArray> parameterNames = propertyCache->signalParameterNames(sigIndex);
- for (int i = 0; i < parameterNames.count(); ++i) {
+ for (int i = 0; i < parameterNames.size(); ++i) {
const QString param = QString::fromUtf8(parameterNames.at(i));
if (param.isEmpty())
unnamedParameter = true;
@@ -442,7 +442,7 @@ QQmlEnumTypeResolver::QQmlEnumTypeResolver(QQmlTypeCompiler *typeCompiler)
bool QQmlEnumTypeResolver::resolveEnumBindings()
{
- for (int i = 0; i < qmlObjects.count(); ++i) {
+ for (int i = 0; i < qmlObjects.size(); ++i) {
QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(i);
if (!propertyCache)
continue;
@@ -517,11 +517,11 @@ bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(
// * <TypeName>.<ScopedEnumName>.<EnumValue>
int dot = string.indexOf(QLatin1Char('.'));
- if (dot == -1 || dot == string.length()-1)
+ if (dot == -1 || dot == string.size()-1)
return true;
int dot2 = string.indexOf(QLatin1Char('.'), dot+1);
- if (dot2 != -1 && dot2 != string.length()-1) {
+ if (dot2 != -1 && dot2 != string.size()-1) {
if (!string.at(dot+1).isUpper())
return true;
if (string.indexOf(QLatin1Char('.'), dot2+1) != -1)
@@ -612,7 +612,7 @@ int QQmlEnumTypeResolver::evaluateEnum(const QString &scope, QStringView enumNam
return -1;
if (!enumName.isEmpty())
return type.scopedEnumValue(compiler->enginePrivate(), enumName, enumValue, ok);
- return type.enumValue(compiler->enginePrivate(), QHashedStringRef(enumValue.constData(), enumValue.length()), ok);
+ return type.enumValue(compiler->enginePrivate(), QHashedStringRef(enumValue.constData(), enumValue.size()), ok);
}
const QMetaObject *mo = &Qt::staticMetaObject;
@@ -674,7 +674,7 @@ QQmlAliasAnnotator::QQmlAliasAnnotator(QQmlTypeCompiler *typeCompiler)
void QQmlAliasAnnotator::annotateBindingsToAliases()
{
- for (int i = 0; i < qmlObjects.count(); ++i) {
+ for (int i = 0; i < qmlObjects.size(); ++i) {
QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(i);
if (!propertyCache)
continue;
@@ -706,7 +706,7 @@ QQmlScriptStringScanner::QQmlScriptStringScanner(QQmlTypeCompiler *typeCompiler)
void QQmlScriptStringScanner::scan()
{
const QMetaType scriptStringMetaType = QMetaType::fromType<QQmlScriptString>();
- for (int i = 0; i < qmlObjects.count(); ++i) {
+ for (int i = 0; i < qmlObjects.size(); ++i) {
QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(i);
if (!propertyCache)
continue;
@@ -833,7 +833,7 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(
}
qmlObjects->append(syntheticComponent);
- const int componentIndex = qmlObjects->count() - 1;
+ const int componentIndex = qmlObjects->size() - 1;
// Keep property caches symmetric
QQmlPropertyCache::ConstPtr componentCache
= QQmlMetaType::propertyCache(&QQmlComponent::staticMetaObject);
@@ -863,7 +863,7 @@ bool QQmlComponentAndAliasResolver::resolve(int root)
// someItemDelegate: Item {}
// In the implicit case Item is surrounded by a synthetic Component {} because the property
// on the left hand side is of QQmlComponent type.
- const int objCountWithoutSynthesizedComponents = qmlObjects->count();
+ const int objCountWithoutSynthesizedComponents = qmlObjects->size();
const int startObjectIndex = root == 0 ? root : root+1; // root+1, as ic root is handled at the end
for (int i = startObjectIndex; i < objCountWithoutSynthesizedComponents; ++i) {
QmlIR::Object *obj = qmlObjects->at(i);
@@ -931,7 +931,7 @@ bool QQmlComponentAndAliasResolver::resolve(int root)
}
- for (int i = 0; i < componentRoots.count(); ++i) {
+ for (int i = 0; i < componentRoots.size(); ++i) {
QmlIR::Object *component = qmlObjects->at(componentRoots.at(i));
const QmlIR::Binding *rootBinding = component->firstBinding();
@@ -977,7 +977,7 @@ bool QQmlComponentAndAliasResolver::collectIdsAndAliases(int objectIndex)
recordError(obj->locationOfIdProperty, tr("id is not unique"));
return false;
}
- obj->id = _idToObjectIndex.count();
+ obj->id = _idToObjectIndex.size();
_idToObjectIndex.insert(obj->idNameIndex, objectIndex);
}
@@ -1016,7 +1016,7 @@ bool QQmlComponentAndAliasResolver::resolveAliases(int componentIndex)
atLeastOneAliasResolved = false;
QVector<int> pendingObjects;
- for (int objectIndex: qAsConst(_objectsWithAliases)) {
+ for (int objectIndex: std::as_const(_objectsWithAliases)) {
QQmlError error;
const auto result = resolveAliasesInObject(objectIndex, &error);
@@ -1396,7 +1396,7 @@ QQmlDefaultPropertyMerger::QQmlDefaultPropertyMerger(QQmlTypeCompiler *typeCompi
void QQmlDefaultPropertyMerger::mergeDefaultProperties()
{
- for (int i = 0; i < qmlObjects.count(); ++i)
+ for (int i = 0; i < qmlObjects.size(); ++i)
mergeDefaultProperties(i);
}
diff --git a/src/qml/qml/qqmltypecompiler_p.h b/src/qml/qml/qqmltypecompiler_p.h
index 188eda471f..02edbb0c08 100644
--- a/src/qml/qml/qqmltypecompiler_p.h
+++ b/src/qml/qml/qqmltypecompiler_p.h
@@ -55,7 +55,7 @@ public:
using ListPropertyAssignBehavior = QmlIR::Pragma::ListPropertyAssignBehaviorValue;
const QmlIR::Object *objectAt(int index) const { return document->objects.at(index); }
- int objectCount() const { return document->objects.count(); }
+ int objectCount() const { return document->objects.size(); }
QString stringAt(int idx) const;
QmlIR::PoolList<QmlIR::Function>::Iterator objectFunctionsBegin(const QmlIR::Object *object) const { return object->functionsBegin(); }
QmlIR::PoolList<QmlIR::Function>::Iterator objectFunctionsEnd(const QmlIR::Object *object) const { return object->functionsEnd(); }
diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp
index 972723326a..c56acaef0d 100644
--- a/src/qml/qml/qqmltypedata.cpp
+++ b/src/qml/qml/qqmltypedata.cpp
@@ -292,7 +292,7 @@ void QQmlTypeData::done()
return;
// Check all script dependencies for errors
- for (int ii = 0; ii < m_scripts.count(); ++ii) {
+ for (int ii = 0; ii < m_scripts.size(); ++ii) {
const ScriptReference &script = m_scripts.at(ii);
Q_ASSERT(script.script->isCompleteOrError());
if (script.script->isError()) {
@@ -309,7 +309,7 @@ void QQmlTypeData::done()
}
// Check all type dependencies for errors
- for (auto it = qAsConst(m_resolvedTypes).begin(), end = qAsConst(m_resolvedTypes).end(); it != end;
+ for (auto it = std::as_const(m_resolvedTypes).begin(), end = std::as_const(m_resolvedTypes).end(); it != end;
++it) {
const TypeReference &type = *it;
Q_ASSERT(!type.typeData || type.typeData->isCompleteOrError() || type.type.isInlineComponentType());
@@ -349,7 +349,7 @@ void QQmlTypeData::done()
}
// Check all composite singleton type dependencies for errors
- for (int ii = 0; ii < m_compositeSingletons.count(); ++ii) {
+ for (int ii = 0; ii < m_compositeSingletons.size(); ++ii) {
const TypeReference &type = m_compositeSingletons.at(ii);
Q_ASSERT(!type.typeData || type.typeData->isCompleteOrError());
if (type.typeData && type.typeData->isError()) {
@@ -470,7 +470,7 @@ void QQmlTypeData::done()
auto type = QQmlMetaType::typeForUrl(finalUrlString(), hashedStringRef, false, &errors);
Q_ASSERT(errors.empty());
if (type.isValid()) {
- for (auto const &icDatum : qAsConst(m_inlineComponentData)) {
+ for (auto const &icDatum : std::as_const(m_inlineComponentData)) {
Q_ASSERT(icDatum.typeIds.isValid());
QQmlType existingType = type.lookupInlineComponentById(type.lookupInlineComponentIdByName(m_compiledData->stringAt(icDatum.nameIndex)));
type.associateInlineComponent(m_compiledData->stringAt(icDatum.nameIndex),
@@ -482,8 +482,8 @@ void QQmlTypeData::done()
{
// Collect imported scripts
- m_compiledData->dependentScripts.reserve(m_scripts.count());
- for (int scriptIndex = 0; scriptIndex < m_scripts.count(); ++scriptIndex) {
+ m_compiledData->dependentScripts.reserve(m_scripts.size());
+ for (int scriptIndex = 0; scriptIndex < m_scripts.size(); ++scriptIndex) {
const QQmlTypeData::ScriptReference &script = m_scripts.at(scriptIndex);
QStringView qualifier(script.qualifier);
@@ -599,8 +599,8 @@ bool QQmlTypeData::loadFromSource()
if (!compiler.generateFromQml(source, finalUrlString(), m_document.data())) {
QList<QQmlError> errors;
- errors.reserve(compiler.errors.count());
- for (const QQmlJS::DiagnosticMessage &msg : qAsConst(compiler.errors)) {
+ errors.reserve(compiler.errors.size());
+ for (const QQmlJS::DiagnosticMessage &msg : std::as_const(compiler.errors)) {
QQmlError e;
e.setUrl(url());
e.setLine(qmlConvertSourceCoordinate<quint32, int>(msg.loc.startLine));
@@ -668,7 +668,7 @@ void QQmlTypeData::continueLoadFromIR()
QList<QQmlError> errors;
- for (const QV4::CompiledData::Import *import : qAsConst(m_document->imports)) {
+ for (const QV4::CompiledData::Import *import : std::as_const(m_document->imports)) {
if (!addImport(import, {}, &errors)) {
Q_ASSERT(errors.size());
@@ -723,7 +723,7 @@ void QQmlTypeData::allDependenciesDone()
void QQmlTypeData::downloadProgressChanged(qreal p)
{
- for (int ii = 0; ii < m_callbacks.count(); ++ii) {
+ for (int ii = 0; ii < m_callbacks.size(); ++ii) {
TypeDataCallback *callback = m_callbacks.at(ii);
callback->typeDataProgress(this, p);
}
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 046ee0ef51..ab3ea80d35 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -614,7 +614,7 @@ bool QQmlTypeLoader::Blob::addLibraryImport(PendingImportPtr import, QList<QQmlE
scriptImported(blob, import->location, script.nameSpace, import->qualifier);
}
}
- if (!qmldir.plugins().count()) {
+ if (!qmldir.plugins().size()) {
// If the qmldir does not register a plugin, we might still have declaratively
// registered types (if we are dealing with an application instead of a library)
auto module = QQmlMetaType::typeModule(import->uri, import->version);
@@ -1035,7 +1035,7 @@ QString QQmlTypeLoader::absoluteFilePath(const QString &path)
return QString();
QString absoluteFilePath;
- QString fileName(path.mid(lastSlash+1, path.length()-lastSlash-1));
+ QString fileName(path.mid(lastSlash+1, path.size()-lastSlash-1));
bool *value = fileSet->object(fileName);
if (value) {
@@ -1048,7 +1048,7 @@ QString QQmlTypeLoader::absoluteFilePath(const QString &path)
absoluteFilePath = path;
}
- if (absoluteFilePath.length() > 2 && absoluteFilePath.at(0) != QLatin1Char('/') && absoluteFilePath.at(1) != QLatin1Char(':'))
+ if (absoluteFilePath.size() > 2 && absoluteFilePath.at(0) != QLatin1Char('/') && absoluteFilePath.at(1) != QLatin1Char(':'))
absoluteFilePath = QFileInfo(absoluteFilePath).absoluteFilePath();
return absoluteFilePath;
@@ -1134,7 +1134,7 @@ bool QQmlTypeLoader::directoryExists(const QString &path)
return fileInfo.exists() && fileInfo.isDir();
}
- int length = path.length();
+ int length = path.size();
if (path.endsWith(QLatin1Char('/')))
--length;
QString dirPath(path.left(length));
@@ -1171,7 +1171,7 @@ const QQmlTypeLoaderQmldirContent QQmlTypeLoader::qmldirContent(const QString &f
// Yet, this heuristic is the best we can do until we pass more structured information here,
// for example a QUrl also for local files.
QUrl url(filePathIn);
- if (url.scheme().length() < 2) {
+ if (url.scheme().size() < 2) {
filePath = filePathIn;
} else {
filePath = QQmlFile::urlToLocalFileOrQrc(url);
diff --git a/src/qml/qml/qqmltypemodule.cpp b/src/qml/qml/qqmltypemodule.cpp
index 4360bf8fb9..b188b7fb90 100644
--- a/src/qml/qml/qqmltypemodule.cpp
+++ b/src/qml/qml/qqmltypemodule.cpp
@@ -30,7 +30,7 @@ void QQmlTypeModule::add(QQmlTypePrivate *type)
addMinorVersion(type->version.minorVersion());
QList<QQmlTypePrivate *> &list = m_typeHash[type->elementName];
- for (int ii = 0; ii < list.count(); ++ii) {
+ for (int ii = 0; ii < list.size(); ++ii) {
QQmlTypePrivate *in_list = list.at(ii);
Q_ASSERT(in_list);
if (in_list->version.minorVersion() < type->version.minorVersion()) {
@@ -54,7 +54,7 @@ void QQmlTypeModule::remove(const QQmlTypePrivate *type)
QQmlType QQmlTypeModule::findType(const QList<QQmlTypePrivate *> *types, QTypeRevision version)
{
if (types) {
- for (int ii = 0; ii < types->count(); ++ii)
+ for (int ii = 0; ii < types->size(); ++ii)
if (types->at(ii)->version.minorVersion() <= version.minorVersion())
return QQmlType(types->at(ii));
}
diff --git a/src/qml/qml/qqmltypenamecache.cpp b/src/qml/qml/qqmltypenamecache.cpp
index bf270cef7d..d3088a6c7c 100644
--- a/src/qml/qml/qqmltypenamecache.cpp
+++ b/src/qml/qml/qqmltypenamecache.cpp
@@ -9,7 +9,7 @@ QT_BEGIN_NAMESPACE
void QQmlTypeNameCache::add(const QHashedString &name, const QUrl &url, const QHashedString &nameSpace)
{
- if (nameSpace.length() != 0) {
+ if (nameSpace.size() != 0) {
QQmlImportRef *i = m_namedImports.value(nameSpace);
Q_ASSERT(i != nullptr);
i->compositeSingletons.insert(name, url);
@@ -28,7 +28,7 @@ void QQmlTypeNameCache::add(const QHashedString &name, int importedScriptIndex,
import.scriptIndex = importedScriptIndex;
import.m_qualifier = name;
- if (nameSpace.length() != 0) {
+ if (nameSpace.size() != 0) {
QQmlImportRef *i = m_namedImports.value(nameSpace);
Q_ASSERT(i != nullptr);
m_namespacedImports[i].insert(name, import);
diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp
index 7365255935..8cb18104b6 100644
--- a/src/qml/qml/qqmlvaluetype.cpp
+++ b/src/qml/qml/qqmlvaluetype.cpp
@@ -11,20 +11,9 @@
QT_BEGIN_NAMESPACE
-QQmlValueType::QQmlValueType(QMetaType type, const QMetaObject *gadgetMetaObject)
- : metaType(type)
-{
- QMetaObjectBuilder builder(gadgetMetaObject);
-
- // This is required for calling readOnGadget() on properties from this metaObject.
- builder.setFlags(PropertyAccessInStaticMetaCall);
-
- dynamicMetaObject = builder.toMetaObject();
-}
-
QQmlValueType::~QQmlValueType()
{
- ::free(dynamicMetaObject);
+ ::free(m_dynamicMetaObject);
}
QQmlGadgetPtrWrapper *QQmlGadgetPtrWrapper::instance(QQmlEngine *engine, QMetaType type)
@@ -54,7 +43,7 @@ void QQmlGadgetPtrWrapper::read(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
}
-void QQmlGadgetPtrWrapper::write(QObject *obj, int idx, QQmlPropertyData::WriteFlags flags)
+void QQmlGadgetPtrWrapper::write(QObject *obj, int idx, QQmlPropertyData::WriteFlags flags) const
{
Q_ASSERT(m_gadgetPtr);
int status = -1;
@@ -62,16 +51,16 @@ void QQmlGadgetPtrWrapper::write(QObject *obj, int idx, QQmlPropertyData::WriteF
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
-QVariant QQmlGadgetPtrWrapper::value()
+QVariant QQmlGadgetPtrWrapper::value() const
{
Q_ASSERT(m_gadgetPtr);
- return QVariant(QMetaType(metaTypeId()), m_gadgetPtr);
+ return QVariant(metaType(), m_gadgetPtr);
}
void QQmlGadgetPtrWrapper::setValue(const QVariant &value)
{
Q_ASSERT(m_gadgetPtr);
- Q_ASSERT(metaTypeId() == value.userType());
+ Q_ASSERT(metaType() == value.metaType());
const QQmlValueType *type = valueType();
type->destruct(m_gadgetPtr);
type->construct(m_gadgetPtr, value.constData());
@@ -80,7 +69,7 @@ void QQmlGadgetPtrWrapper::setValue(const QVariant &value)
int QQmlGadgetPtrWrapper::metaCall(QMetaObject::Call type, int id, void **argv)
{
Q_ASSERT(m_gadgetPtr);
- const QMetaObject *metaObject = valueType()->metaObject();
+ const QMetaObject *metaObject = valueType()->staticMetaObject();
QQmlMetaObject::resolveGadgetMethodOrPropertyIndex(type, &metaObject, &id);
metaObject->d.static_metacall(static_cast<QObject *>(m_gadgetPtr), type, id, argv);
return id;
@@ -94,7 +83,16 @@ const QQmlValueType *QQmlGadgetPtrWrapper::valueType() const
QMetaObject *QQmlValueType::toDynamicMetaObject(QObject *)
{
- return dynamicMetaObject;
+ if (!m_dynamicMetaObject) {
+ QMetaObjectBuilder builder(m_staticMetaObject);
+
+ // Do not set PropertyAccessInStaticMetaCall here. QQmlGadgetPtrWrapper likes to
+ // to intercept the metacalls since it needs to use its gadgetPtr.
+ // For QQmlValueType::metaObject() we use the base type that has the flag.
+
+ m_dynamicMetaObject = builder.toMetaObject();
+ }
+ return m_dynamicMetaObject;
}
void QQmlValueType::objectDestroyed(QObject *)
diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h
index 6b7df3f1b9..5376130b0f 100644
--- a/src/qml/qml/qqmlvaluetype_p.h
+++ b/src/qml/qml/qqmlvaluetype_p.h
@@ -34,18 +34,20 @@ QT_BEGIN_NAMESPACE
class Q_QML_PRIVATE_EXPORT QQmlValueType : public QDynamicMetaObjectData
{
public:
- QQmlValueType() : metaType(QMetaType::UnknownType) {}
- QQmlValueType(QMetaType type, const QMetaObject *metaObject);
+ QQmlValueType() = default;
+ QQmlValueType(QMetaType type, const QMetaObject *staticMetaObject)
+ : m_metaType(type), m_staticMetaObject(staticMetaObject)
+ {}
~QQmlValueType();
- void *create() const { return metaType.create(); }
- void destroy(void *gadgetPtr) const { metaType.destroy(gadgetPtr); }
+ void *create() const { return m_metaType.create(); }
+ void destroy(void *gadgetPtr) const { m_metaType.destroy(gadgetPtr); }
- void construct(void *gadgetPtr, const void *copy) const { metaType.construct(gadgetPtr, copy); }
- void destruct(void *gadgetPtr) const { metaType.destruct(gadgetPtr); }
+ void construct(void *gadgetPtr, const void *copy) const { m_metaType.construct(gadgetPtr, copy); }
+ void destruct(void *gadgetPtr) const { m_metaType.destruct(gadgetPtr); }
- int metaTypeId() const { return metaType.id(); }
- const QMetaObject *metaObject() const { return dynamicMetaObject; }
+ QMetaType metaType() const { return m_metaType; }
+ const QMetaObject *staticMetaObject() const { return m_staticMetaObject; }
// ---- dynamic meta object data interface
QMetaObject *toDynamicMetaObject(QObject *) override;
@@ -53,9 +55,10 @@ public:
int metaCall(QObject *obj, QMetaObject::Call type, int _id, void **argv) override;
// ----
-public:
- QMetaType metaType;
- QMetaObject *dynamicMetaObject = nullptr;
+private:
+ QMetaType m_metaType;
+ const QMetaObject *m_staticMetaObject = nullptr;
+ QMetaObject *m_dynamicMetaObject = nullptr;
};
class Q_QML_PRIVATE_EXPORT QQmlGadgetPtrWrapper : public QObject
@@ -68,14 +71,18 @@ public:
~QQmlGadgetPtrWrapper();
void read(QObject *obj, int idx);
- void write(QObject *obj, int idx, QQmlPropertyData::WriteFlags flags);
- QVariant value();
+ void write(QObject *obj, int idx, QQmlPropertyData::WriteFlags flags) const;
+ QVariant value() const;
void setValue(const QVariant &value);
- int metaTypeId() const { return valueType()->metaTypeId(); }
+ QMetaType metaType() const { return valueType()->metaType(); }
int metaCall(QMetaObject::Call type, int id, void **argv);
- QMetaProperty property(int index) { return valueType()->metaObject()->property(index); }
+ QMetaProperty property(int index) const
+ {
+ return valueType()->staticMetaObject()->property(index);
+ }
+
QVariant readOnGadget(const QMetaProperty &property) const
{
return property.readOnGadget(m_gadgetPtr);
@@ -88,7 +95,6 @@ public:
private:
const QQmlValueType *valueType() const;
-
void *m_gadgetPtr = nullptr;
};
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 34de9faef9..d088d5e411 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -35,7 +35,7 @@ using namespace QV4;
void Heap::QQmlValueTypeWrapper::destroy()
{
if (m_gadgetPtr) {
- m_valueType->metaType.destruct(m_gadgetPtr);
+ m_valueType->metaType().destruct(m_gadgetPtr);
::operator delete(m_gadgetPtr);
}
Object::destroy();
@@ -44,22 +44,22 @@ void Heap::QQmlValueTypeWrapper::destroy()
void Heap::QQmlValueTypeWrapper::setData(const void *data) const
{
if (auto *gadget = gadgetPtr())
- valueType()->metaType.destruct(gadget);
+ valueType()->metaType().destruct(gadget);
if (!gadgetPtr())
- setGadgetPtr(::operator new(valueType()->metaType.sizeOf()));
- valueType()->metaType.construct(gadgetPtr(), data);
+ setGadgetPtr(::operator new(valueType()->metaType().sizeOf()));
+ valueType()->metaType().construct(gadgetPtr(), data);
}
void Heap::QQmlValueTypeWrapper::setValue(const QVariant &value) const
{
- Q_ASSERT(valueType()->metaType.id() == value.userType());
+ Q_ASSERT(valueType()->metaType().id() == value.userType());
setData(value.constData());
}
QVariant Heap::QQmlValueTypeWrapper::toVariant() const
{
Q_ASSERT(gadgetPtr());
- return QVariant(valueType()->metaType, gadgetPtr());
+ return QVariant(valueType()->metaType(), gadgetPtr());
}
@@ -86,7 +86,7 @@ bool QQmlValueTypeReference::readReferenceValue() const
if (QQmlMetaType::isValueType(variantReferenceType)) {
const QMetaObject *mo = QQmlMetaType::metaObjectForValueType(variantReferenceType);
if (d()->gadgetPtr()) {
- d()->valueType()->metaType.destruct(d()->gadgetPtr());
+ d()->valueType()->metaType().destruct(d()->gadgetPtr());
::operator delete(d()->gadgetPtr());
}
d()->setGadgetPtr(nullptr);
@@ -101,8 +101,8 @@ bool QQmlValueTypeReference::readReferenceValue() const
d()->setValue(variantReferenceValue);
} else {
if (!d()->gadgetPtr()) {
- d()->setGadgetPtr(::operator new(d()->valueType()->metaType.sizeOf()));
- d()->valueType()->metaType.construct(d()->gadgetPtr(), nullptr);
+ d()->setGadgetPtr(::operator new(d()->valueType()->metaType().sizeOf()));
+ d()->valueType()->metaType().construct(d()->gadgetPtr(), nullptr);
}
// value-type reference
void *args[] = { d()->gadgetPtr(), nullptr };
@@ -145,7 +145,7 @@ ReturnedValue QQmlValueTypeWrapper::create(
ExecutionEngine *engine, const QVariant &value, const QMetaObject *metaObject,
QMetaType type)
{
- Q_ASSERT(value.metaType() == QQmlMetaType::valueType(type)->metaType);
+ Q_ASSERT(value.metaType() == QQmlMetaType::valueType(type)->metaType());
return create(engine, value.constData(), metaObject, type);
}
@@ -181,7 +181,7 @@ bool QQmlValueTypeWrapper::toGadget(void *data) const
if (const QQmlValueTypeReference *ref = as<const QQmlValueTypeReference>())
if (!ref->readReferenceValue())
return false;
- const QMetaType type = d()->valueType()->metaType;
+ const QMetaType type = d()->valueType()->metaType();
type.destruct(data);
type.construct(data, d()->gadgetPtr());
return true;
@@ -367,12 +367,12 @@ bool QQmlValueTypeWrapper::isEqual(const QVariant& value) const
int QQmlValueTypeWrapper::typeId() const
{
- return d()->valueType()->metaType.id();
+ return d()->valueType()->metaType().id();
}
QMetaType QQmlValueTypeWrapper::type() const
{
- return d()->valueType()->metaType;
+ return d()->valueType()->metaType();
}
bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const
@@ -381,9 +381,9 @@ bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const
Q_ALLOCA_DECLARE(void, gadget);
if (const QQmlValueTypeReference *ref = as<const QQmlValueTypeReference>()) {
if (!d()->gadgetPtr()) {
- Q_ALLOCA_ASSIGN(void, gadget, d()->valueType()->metaType.sizeOf());
+ Q_ALLOCA_ASSIGN(void, gadget, d()->valueType()->metaType().sizeOf());
d()->setGadgetPtr(gadget);
- d()->valueType()->metaType.construct(d()->gadgetPtr(), nullptr);
+ d()->valueType()->metaType().construct(d()->gadgetPtr(), nullptr);
destructGadgetOnExit = true;
}
if (!ref->readReferenceValue())
@@ -396,7 +396,7 @@ bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const
QMetaObject::metacall(target, QMetaObject::WriteProperty, propertyIndex, a);
if (destructGadgetOnExit) {
- d()->valueType()->metaType.destruct(d()->gadgetPtr());
+ d()->valueType()->metaType().destruct(d()->gadgetPtr());
d()->setGadgetPtr(nullptr);
}
return true;
@@ -434,9 +434,9 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(const FunctionObject *b, con
RETURN_UNDEFINED();
QString result;
- if (!QMetaType::convert(w->d()->valueType()->metaType, w->d()->gadgetPtr(),
+ if (!QMetaType::convert(w->d()->valueType()->metaType(), w->d()->gadgetPtr(),
QMetaType(QMetaType::QString), &result)) {
- result = QString::fromUtf8(w->d()->valueType()->metaType.name()) + QLatin1Char('(');
+ result = QString::fromUtf8(w->d()->valueType()->metaType().name()) + QLatin1Char('(');
const QMetaObject *mo = w->d()->metaObject();
const int propCount = mo->propertyCount();
for (int i = 0; i < propCount; ++i) {
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 8a0bc1a08e..710aadda45 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -99,7 +99,7 @@ static void list_append(QQmlListProperty<QObject> *prop, QObject *o)
static qsizetype list_count(QQmlListProperty<QObject> *prop)
{
- return ResolvedList(prop).list()->count();
+ return ResolvedList(prop).list()->size();
}
static QObject *list_at(QQmlListProperty<QObject> *prop, qsizetype index)
@@ -203,13 +203,10 @@ void QQmlVMEMetaObjectEndpoint::tryConnect()
if (!target)
return;
- QQmlData *targetDData = QQmlData::get(target, /*create*/false);
- if (!targetDData)
- return;
QQmlPropertyIndex encodedIndex = QQmlPropertyIndex::fromEncoded(aliasData->encodedMetaPropertyIndex);
int coreIndex = encodedIndex.coreIndex();
int valueTypeIndex = encodedIndex.valueTypeIndex();
- const QQmlPropertyData *pd = targetDData->propertyCache->property(coreIndex);
+ const QQmlPropertyData *pd = QQmlData::ensurePropertyCache(target)->property(coreIndex);
if (pd && valueTypeIndex != -1 && !QQmlMetaType::valueType(pd->propType())) {
// deep alias
const QQmlPropertyCache::ConstPtr newPropertyCache
@@ -899,7 +896,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
QObject *arg = *reinterpret_cast<QObject **>(a[0]);
if (const auto *wrap = sv->as<QV4::QObjectWrapper>())
needActivate = wrap->object() != arg;
- else
+ else if (arg != nullptr || !sv->isNull())
needActivate = true;
if (needActivate)
writeProperty(id, arg);
@@ -1053,7 +1050,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
auto arguments = methodData->hasArguments() ? methodData->arguments() : nullptr;
if (arguments && arguments->names) {
- const quint32 parameterCount = arguments->names->count();
+ const quint32 parameterCount = arguments->names->size();
Q_ASSERT(parameterCount == function->formalParameterCount());
if (void *result = a[0])
arguments->types[0].destruct(result);
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 4d3ba7df24..daaeb16c13 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -504,7 +504,7 @@ ReturnedValue NodePrototype::method_get_previousSibling(const FunctionObject *b,
if (!r->d()->d->parent)
RETURN_RESULT(Encode::null());
- for (int ii = 0; ii < r->d()->d->parent->children.count(); ++ii) {
+ for (int ii = 0; ii < r->d()->d->parent->children.size(); ++ii) {
if (r->d()->d->parent->children.at(ii) == r->d()->d) {
if (ii == 0)
return Encode::null();
@@ -526,9 +526,9 @@ ReturnedValue NodePrototype::method_get_nextSibling(const FunctionObject *b, con
if (!r->d()->d->parent)
RETURN_RESULT(Encode::null());
- for (int ii = 0; ii < r->d()->d->parent->children.count(); ++ii) {
+ for (int ii = 0; ii < r->d()->d->parent->children.size(); ++ii) {
if (r->d()->d->parent->children.at(ii) == r->d()->d) {
- if ((ii + 1) == r->d()->d->parent->children.count())
+ if ((ii + 1) == r->d()->d->parent->children.size())
return Encode::null();
else
return Node::create(scope.engine, r->d()->d->parent->children.at(ii + 1));
@@ -666,7 +666,7 @@ ReturnedValue CharacterData::method_length(const FunctionObject *b, const Value
if (!r)
RETURN_UNDEFINED();
- return Encode(int(r->d()->d->data.length()));
+ return Encode(int(r->d()->d->data.size()));
}
ReturnedValue CharacterData::prototype(ExecutionEngine *v4)
@@ -859,7 +859,7 @@ ReturnedValue NamedNodeMap::virtualGet(const Managed *m, PropertyKey id, const V
if (id.isArrayIndex()) {
uint index = id.asArrayIndex();
- if ((int)index < r->d()->list().count()) {
+ if ((int)index < r->d()->list().size()) {
if (hasProperty)
*hasProperty = true;
return Node::create(v4, r->d()->list().at(index));
@@ -873,10 +873,10 @@ ReturnedValue NamedNodeMap::virtualGet(const Managed *m, PropertyKey id, const V
return Object::virtualGet(m, id, receiver, hasProperty);
if (id == v4->id_length()->propertyKey())
- return Value::fromInt32(r->d()->list().count()).asReturnedValue();
+ return Value::fromInt32(r->d()->list().size()).asReturnedValue();
QString str = id.toQString();
- for (int ii = 0; ii < r->d()->list().count(); ++ii) {
+ for (int ii = 0; ii < r->d()->list().size(); ++ii) {
if (r->d()->list().at(ii)->name == str) {
if (hasProperty)
*hasProperty = true;
@@ -902,7 +902,7 @@ ReturnedValue NodeList::virtualGet(const Managed *m, PropertyKey id, const Value
if (id.isArrayIndex()) {
uint index = id.asArrayIndex();
- if ((int)index < r->d()->d->children.count()) {
+ if ((int)index < r->d()->d->children.size()) {
if (hasProperty)
*hasProperty = true;
return Node::create(v4, r->d()->d->children.at(index));
@@ -913,7 +913,7 @@ ReturnedValue NodeList::virtualGet(const Managed *m, PropertyKey id, const Value
}
if (id == v4->id_length()->propertyKey())
- return Value::fromInt32(r->d()->d->children.count()).asReturnedValue();
+ return Value::fromInt32(r->d()->d->children.size()).asReturnedValue();
return Object::virtualGet(m, id, receiver, hasProperty);
}
@@ -1138,7 +1138,7 @@ QString QQmlXMLHttpRequest::headers() const
QString ret;
for (const HeaderPair &header : m_headersList) {
- if (ret.length())
+ if (ret.size())
ret.append(QLatin1String("\r\n"));
ret += QString::fromUtf8(header.first) + QLatin1String(": ")
+ QString::fromUtf8(header.second);
@@ -1202,7 +1202,7 @@ void QQmlXMLHttpRequest::requestFromUrl(const QUrl &url)
int n = 0;
int semiColon = str.indexOf(QLatin1Char(';'), charsetIdx);
if (semiColon == -1) {
- n = str.length() - charsetIdx;
+ n = str.size() - charsetIdx;
} else {
n = semiColon - charsetIdx;
}
@@ -1436,7 +1436,7 @@ void QQmlXMLHttpRequest::finished()
void QQmlXMLHttpRequest::readEncoding()
{
- for (const HeaderPair &header : qAsConst(m_headersList)) {
+ for (const HeaderPair &header : std::as_const(m_headersList)) {
if (header.first == "content-type") {
int separatorIdx = header.second.indexOf(';');
if (separatorIdx == -1) {
@@ -1447,7 +1447,7 @@ void QQmlXMLHttpRequest::readEncoding()
if (charsetIdx != -1) {
charsetIdx += 8;
separatorIdx = header.second.indexOf(';', charsetIdx);
- m_charset = header.second.mid(charsetIdx, separatorIdx >= 0 ? separatorIdx : header.second.length());
+ m_charset = header.second.mid(charsetIdx, separatorIdx >= 0 ? separatorIdx : header.second.size());
}
}
break;
@@ -1480,7 +1480,7 @@ QV4::ReturnedValue QQmlXMLHttpRequest::jsonResponseBody(QV4::ExecutionEngine* en
QJsonParseError error;
const QString& jtext = responseBody();
- JsonParser parser(scope.engine, jtext.constData(), jtext.length());
+ JsonParser parser(scope.engine, jtext.constData(), jtext.size());
ScopedValue jsonObject(scope, parser.parse(&error));
if (error.error != QJsonParseError::NoError)
return engine->throwSyntaxError(QStringLiteral("JSON.parse: Parse error"));
@@ -1513,11 +1513,8 @@ QStringDecoder QQmlXMLHttpRequest::findTextDecoder() const
decoder = QStringDecoder(reader.documentEncoding().toString().toUtf8());
}
- if (!decoder.isValid() && m_mime == "text/html") {
- auto encoding = QStringConverter::encodingForHtml(m_responseEntityBody);
- if (encoding)
- decoder = QStringDecoder(*encoding);
- }
+ if (!decoder.isValid() && m_mime == "text/html")
+ decoder = QStringDecoder::decoderForHtml(m_responseEntityBody);
if (!decoder.isValid()) {
auto encoding = QStringConverter::encodingForData(m_responseEntityBody);
@@ -1621,7 +1618,7 @@ struct QQmlXMLHttpRequestWrapper : Object {
Member(class, Pointer, Object *, proto)
DECLARE_HEAP_OBJECT(QQmlXMLHttpRequestCtor, FunctionObject) {
- DECLARE_MARKOBJECTS(QQmlXMLHttpRequestCtor);
+ DECLARE_MARKOBJECTS(QQmlXMLHttpRequestCtor)
void init(ExecutionEngine *engine);
};
diff --git a/src/qml/qmldirparser/qqmldirparser.cpp b/src/qml/qmldirparser/qqmldirparser.cpp
index 6415e6cee2..112c7d12d0 100644
--- a/src/qml/qmldirparser/qqmldirparser.cpp
+++ b/src/qml/qmldirparser/qqmldirparser.cpp
@@ -11,13 +11,13 @@ static int parseInt(QStringView str, bool *ok)
{
int pos = 0;
int number = 0;
- while (pos < str.length() && str.at(pos).isDigit()) {
+ while (pos < str.size() && str.at(pos).isDigit()) {
if (pos != 0)
number *= 10;
number += str.at(pos).unicode() - '0';
++pos;
}
- if (pos != str.length())
+ if (pos != str.size())
*ok = false;
else
*ok = true;
@@ -31,7 +31,7 @@ static QTypeRevision parseVersion(const QString &str)
bool ok = false;
const int major = parseInt(QStringView(str).left(dotIndex), &ok);
if (!ok) return QTypeRevision();
- const int minor = parseInt(QStringView(str).mid(dotIndex + 1, str.length() - dotIndex - 1), &ok);
+ const int minor = parseInt(QStringView(str).mid(dotIndex + 1, str.size() - dotIndex - 1), &ok);
return ok ? QTypeRevision::fromVersion(major, minor) : QTypeRevision();
}
return QTypeRevision();
diff --git a/src/qml/qmldirparser/qqmlimportresolver.cpp b/src/qml/qmldirparser/qqmlimportresolver.cpp
index b4f4dbf7a1..15ec7765b0 100644
--- a/src/qml/qmldirparser/qqmlimportresolver.cpp
+++ b/src/qml/qmldirparser/qqmlimportresolver.cpp
@@ -28,7 +28,7 @@ QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths
QStringList importPaths;
// fully & partially versioned parts + 1 unversioned for each base path
- importPaths.reserve(2 * parts.count() + 1);
+ importPaths.reserve(2 * parts.size() + 1);
auto versionString = [](QTypeRevision version, ImportVersion mode)
{
@@ -71,7 +71,7 @@ QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths
if (mode != Unversioned) {
// insert in the middle
- for (int index = parts.count() - 2; index >= 0; --index) {
+ for (int index = parts.size() - 2; index >= 0; --index) {
importPaths += dir + joinStringRefs(parts.mid(0, index + 1), Slash)
+ ver + Slash
+ joinStringRefs(parts.mid(index + 1), Slash);
diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp
index fb2664da73..34f288b9d5 100644
--- a/src/qml/types/qqmlbind.cpp
+++ b/src/qml/types/qqmlbind.cpp
@@ -307,7 +307,7 @@ void QQmlBindPrivate::validate(QQmlBind *q) const
if (!when)
return;
- qsizetype iterationEnd = entries.length();
+ qsizetype iterationEnd = entries.size();
if (lastIsTarget) {
if (obj) {
Q_ASSERT(!entries.isEmpty());
@@ -604,7 +604,7 @@ void QQmlBind::setDelayed(bool delayed)
oldEntries.pop_back();
}
- for (qsizetype i = 0, end = oldEntries.length(); i < end; ++i) {
+ for (qsizetype i = 0, end = oldEntries.size(); i < end; ++i) {
QQmlBindEntry &newEntry = d->entries[i];
QQmlBindEntry &oldEntry = oldEntries[i];
newEntry.previousKind = newEntry.previous.set(
@@ -757,7 +757,8 @@ void QQmlBindPrivate::decodeBinding(
if (!immediateState)
return;
- QQmlProperty property(q, propertyName);
+ QQmlProperty property = QQmlPropertyPrivate::create(
+ q, propertyName, contextData, QQmlPropertyPrivate::InitFlag::AllowSignal);
if (property.isValid()) {
if (!immediateState->creator) {
immediateState->completePending = true;
@@ -794,7 +795,7 @@ void QQmlBindPrivate::decodeBinding(
if (delayed) {
if (!delayedValues)
createDelayedValues();
- const QString delayedName = QString::number(entries.length());
+ const QString delayedName = QString::number(entries.size());
delayedValues->insert(delayedName, QVariant());
QQmlProperty bindingTarget = QQmlProperty(delayedValues.get(), delayedName);
Q_ASSERT(bindingTarget.isValid());
@@ -863,7 +864,7 @@ void QQmlBindPrivate::evalDelayed()
bool ok;
const int delayedIndex = delayedName.toInt(&ok);
Q_ASSERT(ok);
- Q_ASSERT(delayedIndex >= 0 && delayedIndex < entries.length());
+ Q_ASSERT(delayedIndex >= 0 && delayedIndex < entries.size());
entries[delayedIndex].prop.write((*delayedValues)[delayedName]);
}
(*delayedValues)[pendingName].setValue(QStringList());
@@ -1010,7 +1011,7 @@ void QQmlBind::eval()
return;
d->writingProperty = true;
- for (qsizetype i = 0, end = d->entries.length(); i != end; ++i) {
+ for (qsizetype i = 0, end = d->entries.size(); i != end; ++i) {
QQmlBindEntry &entry = d->entries[i];
if (!entry.prop.isValid())
continue;
diff --git a/src/qml/types/qqmlconnections.cpp b/src/qml/types/qqmlconnections.cpp
index 60d0e7a085..1527a2ea34 100644
--- a/src/qml/types/qqmlconnections.cpp
+++ b/src/qml/types/qqmlconnections.cpp
@@ -24,15 +24,13 @@ Q_LOGGING_CATEGORY(lcQmlConnections, "qt.qml.connections")
class QQmlConnectionsPrivate : public QObjectPrivate
{
public:
- QQmlConnectionsPrivate() : target(nullptr), enabled(true), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {}
-
QList<QQmlBoundSignal*> boundsignals;
- QObject *target;
+ QQmlGuard<QObject> target;
- bool enabled;
- bool targetSet;
- bool ignoreUnknownSignals;
- bool componentcomplete;
+ bool enabled = true;
+ bool targetSet = false;
+ bool ignoreUnknownSignals = false;
+ bool componentcomplete = true;
QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit;
QList<const QV4::CompiledData::Binding *> bindings;
@@ -94,6 +92,12 @@ public:
}
\endqml
+ \note For backwards compatibility you can also specify the signal handlers
+ without \c{function}, like you would specify them directly in the target
+ object. This is not recommended. If you specify one signal handler this way,
+ then all signal handlers specified as \c{function} in the same Connections
+ object are ignored.
+
\sa {Qt QML}
*/
QQmlConnections::QQmlConnections(QObject *parent) :
@@ -113,7 +117,7 @@ QQmlConnections::QQmlConnections(QObject *parent) :
QObject *QQmlConnections::target() const
{
Q_D(const QQmlConnections);
- return d->targetSet ? d->target : parent();
+ return d->targetSet ? d->target.data() : parent();
}
class QQmlBoundSignalDeleter : public QObject
@@ -132,7 +136,7 @@ void QQmlConnections::setTarget(QObject *obj)
if (d->targetSet && d->target == obj)
return;
d->targetSet = true; // even if setting to 0, it is *set*
- for (QQmlBoundSignal *s : qAsConst(d->boundsignals)) {
+ for (QQmlBoundSignal *s : std::as_const(d->boundsignals)) {
// It is possible that target is being changed due to one of our signal
// handlers -> use deleteLater().
if (s->isNotifying())
@@ -168,7 +172,7 @@ void QQmlConnections::setEnabled(bool enabled)
d->enabled = enabled;
- for (QQmlBoundSignal *s : qAsConst(d->boundsignals))
+ for (QQmlBoundSignal *s : std::as_const(d->boundsignals))
s->setEnabled(d->enabled);
emit enabledChanged();
@@ -197,11 +201,11 @@ void QQmlConnections::setIgnoreUnknownSignals(bool ignore)
void QQmlConnectionsParser::verifyBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props)
{
- for (int ii = 0; ii < props.count(); ++ii) {
+ for (int ii = 0; ii < props.size(); ++ii) {
const QV4::CompiledData::Binding *binding = props.at(ii);
const QString &propName = compilationUnit->stringAt(binding->propertyNameIndex);
- const bool thirdCharacterIsValid = (propName.length() >= 2)
+ const bool thirdCharacterIsValid = (propName.size() >= 2)
&& (propName.at(2).isUpper() || propName.at(2) == u'_');
if (!propName.startsWith(QLatin1String("on")) || !thirdCharacterIsValid) {
error(props.at(ii), QQmlConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
@@ -298,7 +302,7 @@ void QQmlConnections::connectSignalsToMethods()
signal->takeExpression(expression);
d->boundsignals += signal;
} else if (!d->ignoreUnknownSignals
- && propName.startsWith(QLatin1String("on")) && propName.length() > 2
+ && propName.startsWith(QLatin1String("on")) && propName.size() > 2
&& propName.at(2).isUpper()) {
qmlWarning(this) << tr("Detected function \"%1\" in Connections element. "
"This is probably intended to be a signal handler but no "
@@ -315,7 +319,7 @@ void QQmlConnections::connectSignalsToBindings()
QQmlData *ddata = QQmlData::get(this);
QQmlRefPointer<QQmlContextData> ctxtdata = ddata ? ddata->outerContext : nullptr;
- for (const QV4::CompiledData::Binding *binding : qAsConst(d->bindings)) {
+ for (const QV4::CompiledData::Binding *binding : std::as_const(d->bindings)) {
Q_ASSERT(binding->type() == QV4::CompiledData::Binding::Type_Script);
QString propName = d->compilationUnit->stringAt(binding->propertyNameIndex);
diff --git a/src/qml/util/qqmlpropertymap.cpp b/src/qml/util/qqmlpropertymap.cpp
index 663d4974a7..494bf4e744 100644
--- a/src/qml/util/qqmlpropertymap.cpp
+++ b/src/qml/util/qqmlpropertymap.cpp
@@ -263,7 +263,7 @@ QStringList QQmlPropertyMap::keys() const
int QQmlPropertyMap::count() const
{
Q_D(const QQmlPropertyMap);
- return d->keys.count();
+ return d->keys.size();
}
/*!
diff --git a/src/qmlcompiler/qdeferredpointer_p.h b/src/qmlcompiler/qdeferredpointer_p.h
index 481c0e27ae..f4d8696f69 100644
--- a/src/qmlcompiler/qdeferredpointer_p.h
+++ b/src/qmlcompiler/qdeferredpointer_p.h
@@ -50,15 +50,15 @@ public:
QDeferredSharedPointer() = default;
QDeferredSharedPointer(QSharedPointer<T> data)
- : m_data(data)
+ : m_data(std::move(data))
{}
QDeferredSharedPointer(QWeakPointer<T> data)
- : m_data(data)
+ : m_data(std::move(data))
{}
QDeferredSharedPointer(QSharedPointer<T> data, QSharedPointer<Factory> factory)
- : m_data(data), m_factory(factory)
+ : m_data(std::move(data)), m_factory(std::move(factory))
{
// You have to provide a valid pointer if you provide a factory. We cannot allocate the
// pointer for you because then two copies of the same QDeferredSharedPointer will diverge
diff --git a/src/qmlcompiler/qqmljsbasicblocks.cpp b/src/qmlcompiler/qqmljsbasicblocks.cpp
index a7bbd5326c..093b11684c 100644
--- a/src/qmlcompiler/qqmljsbasicblocks.cpp
+++ b/src/qmlcompiler/qqmljsbasicblocks.cpp
@@ -45,14 +45,14 @@ QQmlJSCompilePass::InstructionAnnotations QQmlJSBasicBlocks::run(
m_function = function;
m_annotations = annotations;
- for (int i = 0, end = function->argumentTypes.length(); i != end; ++i) {
+ for (int i = 0, end = function->argumentTypes.size(); i != end; ++i) {
InstructionAnnotation annotation;
annotation.changedRegisterIndex = FirstArgument + i;
annotation.changedRegister = function->argumentTypes[i];
m_annotations[-annotation.changedRegisterIndex] = annotation;
}
- for (int i = 0, end = function->registerTypes.length(); i != end; ++i) {
+ for (int i = 0, end = function->registerTypes.size(); i != end; ++i) {
InstructionAnnotation annotation;
annotation.changedRegisterIndex = firstRegisterIndex() + i;
annotation.changedRegister = function->registerTypes[i];
@@ -62,7 +62,7 @@ QQmlJSCompilePass::InstructionAnnotations QQmlJSBasicBlocks::run(
m_basicBlocks.insert_or_assign(m_annotations.begin().key(), BasicBlock());
const QByteArray byteCode = function->code;
- decode(byteCode.constData(), static_cast<uint>(byteCode.length()));
+ decode(byteCode.constData(), static_cast<uint>(byteCode.size()));
if (m_hadBackJumps) {
// We may have missed some connections between basic blocks if there were back jumps.
// Fill them in via a second pass.
@@ -75,7 +75,7 @@ QQmlJSCompilePass::InstructionAnnotations QQmlJSBasicBlocks::run(
}
reset();
- decode(byteCode.constData(), static_cast<uint>(byteCode.length()));
+ decode(byteCode.constData(), static_cast<uint>(byteCode.size()));
for (auto it = m_basicBlocks.begin(), end = m_basicBlocks.end(); it != end; ++it)
deduplicate(it->second.jumpOrigins);
}
@@ -415,7 +415,7 @@ void QQmlJSBasicBlocks::adjustTypes()
const InstructionAnnotation &annotation = m_annotations[instructionOffset];
- Q_ASSERT(it->trackedTypes.length() == 1);
+ Q_ASSERT(it->trackedTypes.size() == 1);
Q_ASSERT(it->trackedTypes[0] == m_typeResolver->containedType(annotation.changedRegister));
Q_ASSERT(!annotation.readRegisters.isEmpty());
@@ -430,7 +430,7 @@ void QQmlJSBasicBlocks::adjustTypes()
valueType);
}
- for (const QList<int> &conversions : qAsConst(it->registerReadersAndConversions)) {
+ for (const QList<int> &conversions : std::as_const(it->registerReadersAndConversions)) {
for (int conversion : conversions)
liveConversions[conversion].append(it->trackedRegister);
}
@@ -439,14 +439,14 @@ void QQmlJSBasicBlocks::adjustTypes()
}
for (auto it = m_readerLocations.begin(), end = m_readerLocations.end(); it != end; ++it) {
- for (const QList<int> &conversions : qAsConst(it->registerReadersAndConversions)) {
+ for (const QList<int> &conversions : std::as_const(it->registerReadersAndConversions)) {
for (int conversion : conversions)
liveConversions[conversion].append(it->trackedRegister);
}
// There is always one first occurrence of any tracked type. Conversions don't change
// the type.
- if (it->trackedTypes.length() != 1)
+ if (it->trackedTypes.size() != 1)
continue;
m_typeResolver->adjustTrackedType(it->trackedTypes[0], it->typeReaders.values());
diff --git a/src/qmlcompiler/qqmljscodegenerator.cpp b/src/qmlcompiler/qqmljscodegenerator.cpp
index f9455e7815..a14ea33e14 100644
--- a/src/qmlcompiler/qqmljscodegenerator.cpp
+++ b/src/qmlcompiler/qqmljscodegenerator.cpp
@@ -35,6 +35,15 @@ using namespace Qt::StringLiterals;
m_body += u"// "_s + QStringLiteral(#function) + u'\n'; \
}
+
+static bool isTypeStorable(const QQmlJSTypeResolver *resolver, const QQmlJSScope::ConstPtr &type)
+{
+ return !type.isNull()
+ && !resolver->equals(type, resolver->nullType())
+ && !resolver->equals(type, resolver->emptyListType())
+ && !resolver->equals(type, resolver->voidType());
+}
+
QString QQmlJSCodeGenerator::castTargetName(const QQmlJSScope::ConstPtr &type) const
{
return type->augmentedInternalName();
@@ -43,9 +52,8 @@ QString QQmlJSCodeGenerator::castTargetName(const QQmlJSScope::ConstPtr &type) c
QQmlJSCodeGenerator::QQmlJSCodeGenerator(const QV4::Compiler::Context *compilerContext,
const QV4::Compiler::JSUnitGenerator *unitGenerator,
const QQmlJSTypeResolver *typeResolver,
- QQmlJSLogger *logger, const QStringList &sourceCodeLines)
+ QQmlJSLogger *logger)
: QQmlJSCompilePass(unitGenerator, typeResolver, logger)
- , m_sourceCodeLines(sourceCodeLines)
, m_context(compilerContext)
{}
@@ -75,14 +83,6 @@ QString QQmlJSCodeGenerator::metaObject(const QQmlJSScope::ConstPtr &objectType)
return QString();
}
-static bool isTypeStorable(const QQmlJSTypeResolver *resolver, const QQmlJSScope::ConstPtr &type)
-{
- return !type.isNull()
- && !resolver->equals(type, resolver->nullType())
- && !resolver->equals(type, resolver->emptyListType())
- && !resolver->equals(type, resolver->voidType());
-}
-
QQmlJSAotFunction QQmlJSCodeGenerator::run(
const Function *function, const InstructionAnnotations *annotations,
QQmlJS::DiagnosticMessage *error)
@@ -103,7 +103,7 @@ QQmlJSAotFunction QQmlJSCodeGenerator::run(
auto &currentRegisterNames = registerNames[registerIndex];
QString &name = currentRegisterNames[m_typeResolver->comparableType(seenType)];
if (name.isEmpty())
- name = u"r%1_%2"_s.arg(registerIndex).arg(currentRegisterNames.count());
+ name = u"r%1_%2"_s.arg(registerIndex).arg(currentRegisterNames.size());
typesForRegisters[seenType] = name;
}
};
@@ -123,7 +123,7 @@ QT_WARNING_POP
// ensure we have m_labels for loops
for (const auto loopLabel : m_context->labelInfo)
- m_labels.insert(loopLabel, u"label_%1"_s.arg(m_labels.count()));
+ m_labels.insert(loopLabel, u"label_%1"_s.arg(m_labels.size()));
// Initialize the first instruction's state to hold the arguments.
// After this, the arguments (or whatever becomes of them) are carried
@@ -131,11 +131,14 @@ QT_WARNING_POP
m_state.State::operator=(initialState(m_function));
const QByteArray byteCode = function->code;
- decode(byteCode.constData(), static_cast<uint>(byteCode.length()));
+ decode(byteCode.constData(), static_cast<uint>(byteCode.size()));
QQmlJSAotFunction result;
result.includes.swap(m_includes);
+ result.code += u"// %1 at line %2, column %3\n"_s
+ .arg(m_context->name).arg(m_context->line).arg(m_context->column);
+
QDuplicateTracker<QString> generatedVariables;
for (auto registerIt = m_registerVariables.cbegin(), registerEnd = m_registerVariables.cend();
registerIt != registerEnd; ++registerIt) {
@@ -204,7 +207,7 @@ QT_WARNING_POP
result.code += m_body;
- for (const QQmlJSRegisterContent &argType : qAsConst(function->argumentTypes)) {
+ for (const QQmlJSRegisterContent &argType : std::as_const(function->argumentTypes)) {
if (argType.isValid()) {
result.argumentTypes.append(
m_typeResolver->originalType(argType.storedType())
@@ -309,17 +312,41 @@ void QQmlJSCodeGenerator::generate_LoadConst(int index)
{
INJECT_TRACE_INFO(generate_LoadConst);
- auto encodedConst = m_jsUnitGenerator->constant(index);
- double value = QV4::StaticValue::fromReturnedValue(encodedConst).doubleValue();
- m_body += m_state.accumulatorVariableOut;
+ // You cannot actually get it to generate LoadConst for anything but double. We have
+ // a numer of specialized instructions for the other types, after all. However, let's
+ // play it safe.
- // ### handle other types?
- m_body += u" = "_s + conversion(
- m_typeResolver->intType(), m_state.accumulatorOut().storedType(),
- toNumericString(value));
+ const QV4::ReturnedValue encodedConst = m_jsUnitGenerator->constant(index);
+ const QV4::StaticValue value = QV4::StaticValue::fromReturnedValue(encodedConst);
+ const QQmlJSScope::ConstPtr type = m_typeResolver->typeForConst(encodedConst);
+
+ m_body += m_state.accumulatorVariableOut + u" = "_s;
+ if (type == m_typeResolver->realType()) {
+ m_body += conversion(
+ type, m_state.accumulatorOut().storedType(),
+ toNumericString(value.doubleValue()));
+ } else if (type == m_typeResolver->intType()) {
+ m_body += conversion(
+ type, m_state.accumulatorOut().storedType(),
+ QString::number(value.integerValue()));
+ } else if (type == m_typeResolver->boolType()) {
+ m_body += conversion(
+ type, m_state.accumulatorOut().storedType(),
+ value.booleanValue() ? u"true"_s : u"false"_s);
+ } else if (type == m_typeResolver->voidType()) {
+ m_body += conversion(
+ type, m_state.accumulatorOut().storedType(),
+ QString());
+ } else if (type == m_typeResolver->nullType()) {
+ m_body += conversion(
+ type, m_state.accumulatorOut().storedType(),
+ u"nullptr"_s);
+ } else {
+ reject(u"unsupported constant type"_s);
+ }
m_body += u";\n"_s;
- generateOutputVariantConversion(m_typeResolver->intType());
+ generateOutputVariantConversion(type);
}
void QQmlJSCodeGenerator::generate_LoadZero()
@@ -2227,17 +2254,6 @@ QV4::Moth::ByteCodeHandler::Verdict QQmlJSCodeGenerator::startInstruction(
|| !m_state.accumulatorVariableOut.isEmpty()
|| !isTypeStorable(m_typeResolver, m_state.changedRegister().storedType()));
- const int currentLine = currentSourceLocation().startLine;
- if (currentLine != m_lastLineNumberUsed) {
- const int nextLine = nextJSLine(currentLine);
- for (auto line = currentLine - 1; line < nextLine - 1; ++line) {
- m_body += u"// "_s;
- m_body += m_sourceCodeLines.value(line).trimmed();
- m_body += u'\n';
- }
- m_lastLineNumberUsed = currentLine;
- }
-
// If the instruction has no side effects and doesn't write any register, it's dead.
// We might still need the label, though, and the source code comment.
if (!m_state.hasSideEffects() && changedRegisterVariable().isEmpty())
@@ -2291,9 +2307,18 @@ void QQmlJSCodeGenerator::generateEqualityOperation(int lhs, const QString &func
const auto primitive = m_typeResolver->jsPrimitiveType();
if (m_typeResolver->equals(lhsType, rhsType) && !m_typeResolver->equals(lhsType, primitive)) {
- m_body += conversion(m_typeResolver->boolType(), m_state.accumulatorOut().storedType(),
- registerVariable(lhs) + (invert ? u" != "_s : u" == "_s)
- + m_state.accumulatorVariableIn);
+ if (isTypeStorable(m_typeResolver, lhsType)) {
+ m_body += conversion(m_typeResolver->boolType(), m_state.accumulatorOut().storedType(),
+ registerVariable(lhs) + (invert ? u" != "_s : u" == "_s)
+ + m_state.accumulatorVariableIn);
+ } else if (m_typeResolver->equals(lhsType, m_typeResolver->emptyListType())) {
+ // We cannot compare two empty lists, because we don't know whether it's
+ // the same instance or not. "[] === []" is false, but "var a = []; a === a" is true;
+ reject(u"comparison of two empty lists"_s);
+ } else {
+ // null === null and undefined === undefined
+ m_body += invert ? u"false"_s : u"true"_s;
+ }
} else {
m_body += conversion(
m_typeResolver->boolType(), m_state.accumulatorOut().storedType(),
@@ -2462,7 +2487,7 @@ void QQmlJSCodeGenerator::generateJumpCodeWithTypeConversions(int relativeOffset
if (relativeOffset) {
auto labelIt = m_labels.find(absoluteOffset);
if (labelIt == m_labels.end())
- labelIt = m_labels.insert(absoluteOffset, u"label_%1"_s.arg(m_labels.count()));
+ labelIt = m_labels.insert(absoluteOffset, u"label_%1"_s.arg(m_labels.size()));
conversionCode += u" goto "_s + *labelIt + u";\n"_s;
}
@@ -2510,24 +2535,24 @@ QString QQmlJSCodeGenerator::conversion(const QQmlJSScope::ConstPtr &from,
const auto jsPrimitiveType = m_typeResolver->jsPrimitiveType();
const auto boolType = m_typeResolver->boolType();
- auto zeroBoolOrNumeric = [&](const QQmlJSScope::ConstPtr &to) {
+ auto zeroBoolOrInt = [&](const QQmlJSScope::ConstPtr &to) {
if (m_typeResolver->equals(to, boolType))
return u"false"_s;
if (m_typeResolver->equals(to, m_typeResolver->intType()))
return u"0"_s;
- if (m_typeResolver->equals(to, m_typeResolver->floatType()))
- return u"0.0f"_s;
- if (m_typeResolver->equals(to, m_typeResolver->realType()))
- return u"0.0"_s;
return QString();
};
if (m_typeResolver->equals(from, m_typeResolver->voidType())) {
if (to->accessSemantics() == QQmlJSScope::AccessSemantics::Reference)
return u"static_cast<"_s + to->internalName() + u" *>(nullptr)"_s;
- const QString zero = zeroBoolOrNumeric(to);
+ const QString zero = zeroBoolOrInt(to);
if (!zero.isEmpty())
return zero;
+ if (m_typeResolver->equals(to, m_typeResolver->floatType()))
+ return u"std::numeric_limits<float>::quiet_NaN()"_s;
+ if (m_typeResolver->equals(to, m_typeResolver->realType()))
+ return u"std::numeric_limits<double>::quiet_NaN()"_s;
if (m_typeResolver->equals(to, m_typeResolver->stringType()))
return QQmlJSUtils::toLiteral(u"undefined"_s);
if (m_typeResolver->equals(from, to))
@@ -2545,9 +2570,13 @@ QString QQmlJSCodeGenerator::conversion(const QQmlJSScope::ConstPtr &from,
return u"QJSPrimitiveValue(QJSPrimitiveNull())"_s;
if (m_typeResolver->equals(to, varType))
return u"QVariant::fromValue<std::nullptr_t>(nullptr)"_s;
- const QString zero = zeroBoolOrNumeric(to);
+ const QString zero = zeroBoolOrInt(to);
if (!zero.isEmpty())
return zero;
+ if (m_typeResolver->equals(to, m_typeResolver->floatType()))
+ return u"0.0f"_s;
+ if (m_typeResolver->equals(to, m_typeResolver->realType()))
+ return u"0.0"_s;
if (m_typeResolver->equals(to, m_typeResolver->stringType()))
return QQmlJSUtils::toLiteral(u"null"_s);
if (m_typeResolver->equals(from, to))
@@ -2702,21 +2731,6 @@ QString QQmlJSCodeGenerator::conversion(const QQmlJSScope::ConstPtr &from,
return QString();
}
-int QQmlJSCodeGenerator::nextJSLine(uint line) const
-{
- auto findLine = [](uint line, const QV4::CompiledData::CodeOffsetToLine &entry) {
- return entry.line > line;
- };
- const auto codeToLine
- = std::upper_bound(m_context->lineNumberMapping.constBegin(),
- m_context->lineNumberMapping.constEnd(),
- line,
- findLine);
- bool bNoNextLine = m_context->lineNumberMapping.constEnd() == codeToLine;
-
- return static_cast<int>(bNoNextLine ? -1 : codeToLine->line);
-}
-
void QQmlJSCodeGenerator::reject(const QString &thing)
{
setError(u"Cannot generate efficient code for %1"_s.arg(thing));
diff --git a/src/qmlcompiler/qqmljscodegenerator_p.h b/src/qmlcompiler/qqmljscodegenerator_p.h
index fb54ac0ad2..6fdad57831 100644
--- a/src/qmlcompiler/qqmljscodegenerator_p.h
+++ b/src/qmlcompiler/qqmljscodegenerator_p.h
@@ -33,7 +33,7 @@ public:
QQmlJSCodeGenerator(const QV4::Compiler::Context *compilerContext,
const QV4::Compiler::JSUnitGenerator *unitGenerator,
const QQmlJSTypeResolver *typeResolver,
- QQmlJSLogger *logger, const QStringList &sourceCodeLines);
+ QQmlJSLogger *logger);
~QQmlJSCodeGenerator() = default;
QQmlJSAotFunction run(const Function *function, const InstructionAnnotations *annotations,
@@ -270,17 +270,12 @@ private:
return m_typeResolver->jsGlobalObject()->property(u"Math"_s).type();
}
- int nextJSLine(uint line) const;
-
- QStringList m_sourceCodeLines;
-
// map from instruction offset to sequential label number
QHash<int, QString> m_labels;
const QV4::Compiler::Context *m_context = nullptr;
const InstructionAnnotations *m_annotations = nullptr;
- int m_lastLineNumberUsed = -1;
bool m_skipUntilNextLabel = false;
QStringList m_includes;
diff --git a/src/qmlcompiler/qqmljscompilepass_p.h b/src/qmlcompiler/qqmljscompilepass_p.h
index 40e61464f5..5c4f1c4637 100644
--- a/src/qmlcompiler/qqmljscompilepass_p.h
+++ b/src/qmlcompiler/qqmljscompilepass_p.h
@@ -166,7 +166,7 @@ protected:
int firstRegisterIndex() const
{
- return FirstArgument + m_function->argumentTypes.count();
+ return FirstArgument + m_function->argumentTypes.size();
}
bool isArgument(int registerIndex) const
@@ -184,11 +184,11 @@ protected:
State initialState(const Function *function)
{
State state;
- for (int i = 0, end = function->argumentTypes.length(); i < end; ++i) {
+ for (int i = 0, end = function->argumentTypes.size(); i < end; ++i) {
state.registers[FirstArgument + i] = function->argumentTypes.at(i);
Q_ASSERT(state.registers[FirstArgument + i].isValid());
}
- for (int i = 0, end = function->registerTypes.length(); i != end; ++i)
+ for (int i = 0, end = function->registerTypes.size(); i != end; ++i)
state.registers[firstRegisterIndex() + i] = function->registerTypes[i];
return state;
}
diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp
index 76a7ed80e2..d2e43b6f0b 100644
--- a/src/qmlcompiler/qqmljscompiler.cpp
+++ b/src/qmlcompiler/qqmljscompiler.cpp
@@ -87,7 +87,7 @@ static void annotateListElements(QmlIR::Document *document)
{
QStringList listElementNames;
- for (const QV4::CompiledData::Import *import : qAsConst(document->imports)) {
+ for (const QV4::CompiledData::Import *import : std::as_const(document->imports)) {
const QString uri = document->stringAt(import->uriIndex);
if (uri != QStringLiteral("QtQml.Models") && uri != QStringLiteral("QtQuick"))
continue;
@@ -104,7 +104,7 @@ static void annotateListElements(QmlIR::Document *document)
if (listElementNames.isEmpty())
return;
- for (QmlIR::Object *object : qAsConst(document->objects)) {
+ for (QmlIR::Object *object : std::as_const(document->objects)) {
if (!listElementNames.contains(document->stringAt(object->inheritedTypeNameIndex)))
continue;
for (QmlIR::Binding *binding = object->firstBinding(); binding; binding = binding->next) {
@@ -118,7 +118,7 @@ static void annotateListElements(QmlIR::Document *document)
static bool checkArgumentsObjectUseInSignalHandlers(const QmlIR::Document &doc,
QQmlJSCompileError *error)
{
- for (QmlIR::Object *object: qAsConst(doc.objects)) {
+ for (QmlIR::Object *object: std::as_const(doc.objects)) {
for (auto binding = object->bindingsBegin(); binding != object->bindingsEnd(); ++binding) {
if (binding->type() != QV4::CompiledData::Binding::Type_Script)
continue;
@@ -227,7 +227,7 @@ bool qCompileQmlFile(QmlIR::Document &irDocument, const QString &inputFileName,
aotCompiler->setDocument(&v4CodeGen, &irDocument);
QHash<QmlIR::Object *, QmlIR::Object *> effectiveScopes;
- for (QmlIR::Object *object: qAsConst(irDocument.objects)) {
+ for (QmlIR::Object *object: std::as_const(irDocument.objects)) {
if (object->functionsAndExpressions->count == 0 && object->bindingCount() == 0)
continue;
@@ -438,7 +438,7 @@ void wrapCall(const QQmlPrivate::AOTCompiledContext *aotContext, void *dataPtr,
{
using return_type = std::invoke_result_t<Binding, const QQmlPrivate::AOTCompiledContext *, void **>;
if constexpr (std::is_same_v<return_type, void>) {
- Q_UNUSED(dataPtr);
+ Q_UNUSED(dataPtr)
binding(aotContext, argumentsPtr);
} else {
if (dataPtr) {
@@ -453,8 +453,8 @@ void wrapCall(const QQmlPrivate::AOTCompiledContext *aotContext, void *dataPtr,
static const char *funcHeaderCode = R"(
[](const QQmlPrivate::AOTCompiledContext *aotContext, void *dataPtr, void **argumentsPtr) {
wrapCall(aotContext, dataPtr, argumentsPtr, [](const QQmlPrivate::AOTCompiledContext *aotContext, void **argumentsPtr) {
-Q_UNUSED(aotContext);
-Q_UNUSED(argumentsPtr);
+Q_UNUSED(aotContext)
+Q_UNUSED(argumentsPtr)
)";
bool qSaveQmlJSUnitAsCpp(const QString &inputFileName, const QString &outputFileName, const QV4::CompiledData::SaveableUnitPointer &unit, const QQmlJSAotFunctionMap &aotFunctions, QString *errorString)
@@ -509,7 +509,8 @@ bool qSaveQmlJSUnitAsCpp(const QString &inputFileName, const QString &outputFile
if (!writeStr(qQmlJSSymbolNamespaceForPath(inputFileName).toUtf8()))
return false;
- if (!writeStr(QByteArrayLiteral(" {\nextern const unsigned char qmlData alignas(16) [] = {\n")))
+ if (!writeStr(QByteArrayLiteral(" {\nextern const unsigned char qmlData alignas(16) [];\n"
+ "extern const unsigned char qmlData alignas(16) [] = {\n")))
return false;
unit.saveToDisk<uchar>([&writeStr](const uchar *begin, quint32 size) {
@@ -549,10 +550,12 @@ bool qSaveQmlJSUnitAsCpp(const QString &inputFileName, const QString &outputFile
writeStr(aotFunctions[FileScopeCodeIndex].code.toUtf8().constData());
if (aotFunctions.size() <= 1) {
// FileScopeCodeIndex is always there, but it may be the only one.
- writeStr("extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[] = { { 0, QMetaType::fromType<void>(), {}, nullptr } };");
+ writeStr("extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[];\n"
+ "extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[] = { { 0, QMetaType::fromType<void>(), {}, nullptr } };");
} else {
writeStr(wrapCallCode);
- writeStr("extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[] = {\n");
+ writeStr("extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[];\n"
+ "extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[] = {\n");
QString footer = QStringLiteral("});}\n");
@@ -621,7 +624,6 @@ void QQmlJSAotCompiler::setDocument(
m_logger->setFileName(resourcePathInfo.fileName());
m_logger->setCode(irDocument->code);
m_unitGenerator = &irDocument->jsGenerator;
- m_entireSourceCodeLines = irDocument->code.split(u'\n');
QQmlJSScope::Ptr target = QQmlJSScope::create();
QQmlJSImportVisitor visitor(target, m_importer, m_logger,
resourcePathInfo.canonicalPath() + u'/',
@@ -648,9 +650,8 @@ QQmlJS::DiagnosticMessage QQmlJSAotCompiler::diagnose(
const QString &message, QtMsgType type, const QQmlJS::SourceLocation &location) const
{
if (isStrict(m_document)
- && (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg)
- && !m_logger->isCategoryIgnored(Log_Compiler)
- && m_logger->categoryLevel(Log_Compiler) == QtCriticalMsg) {
+ && (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg)
+ && m_logger->isCategoryFatal(Log_Compiler)) {
qFatal("%s:%d: (strict mode) %s",
qPrintable(QFileInfo(m_resourcePath).fileName()),
location.startLine, qPrintable(message));
@@ -763,8 +764,7 @@ QQmlJSAotFunction QQmlJSAotCompiler::doCompile(
return compileError();
QQmlJSCodeGenerator codegen(
- context, m_unitGenerator, &m_typeResolver, m_logger,
- m_entireSourceCodeLines);
+ context, m_unitGenerator, &m_typeResolver, m_logger);
QQmlJSAotFunction result = codegen.run(function, &typePropagationResult, error);
return error->isValid() ? compileError() : result;
}
diff --git a/src/qmlcompiler/qqmljscompiler_p.h b/src/qmlcompiler/qqmljscompiler_p.h
index c6a60f5a94..45de4abaf1 100644
--- a/src/qmlcompiler/qqmljscompiler_p.h
+++ b/src/qmlcompiler/qqmljscompiler_p.h
@@ -75,7 +75,6 @@ protected:
const QString &message, QtMsgType type, const QQmlJS::SourceLocation &location) const;
QQmlJSTypeResolver m_typeResolver;
- QStringList m_entireSourceCodeLines;
const QString m_resourcePath;
const QStringList m_qmldirFiles;
diff --git a/src/qmlcompiler/qqmljsfunctioninitializer.cpp b/src/qmlcompiler/qqmljsfunctioninitializer.cpp
index 56d1d25124..528b4c0602 100644
--- a/src/qmlcompiler/qqmljsfunctioninitializer.cpp
+++ b/src/qmlcompiler/qqmljsfunctioninitializer.cpp
@@ -66,7 +66,7 @@ void QQmlJSFunctionInitializer::populateSignature(
arguments = ast->formals->formals();
if (function->argumentTypes.isEmpty()) {
- for (const QQmlJS::AST::BoundName &argument : qAsConst(arguments)) {
+ for (const QQmlJS::AST::BoundName &argument : std::as_const(arguments)) {
if (argument.typeAnnotation) {
if (const auto type = m_typeResolver->typeFromAST(argument.typeAnnotation->type)) {
function->argumentTypes.append(
@@ -97,7 +97,7 @@ void QQmlJSFunctionInitializer::populateSignature(
}
}
- for (int i = QQmlJSCompilePass::FirstArgument + function->argumentTypes.length();
+ for (int i = QQmlJSCompilePass::FirstArgument + function->argumentTypes.size();
i < context->registerCountInFunction; ++i) {
function->registerTypes.append(m_typeResolver->tracked(
m_typeResolver->globalType(m_typeResolver->voidType())));
diff --git a/src/qmlcompiler/qqmljsimporter.cpp b/src/qmlcompiler/qqmljsimporter.cpp
index f0897de99f..739ad70b7e 100644
--- a/src/qmlcompiler/qqmljsimporter.cpp
+++ b/src/qmlcompiler/qqmljsimporter.cpp
@@ -81,7 +81,7 @@ void QQmlJSImporter::readQmltypes(
QQmlJS::SourceLocation()
});
- for (const QString &dependency : qAsConst(dependencyStrings)) {
+ for (const QString &dependency : std::as_const(dependencyStrings)) {
const auto blank = dependency.indexOf(u' ');
if (blank < 0) {
dependencies->append(QQmlDirParser::Import(dependency, {},
@@ -265,11 +265,11 @@ void QQmlJSImporter::importDependencies(const QQmlJSImporter::Import &import,
{
// Import the dependencies with an invalid prefix. The prefix will never be matched by actual
// QML code but the C++ types will be visible.
- for (auto const &dependency : qAsConst(import.dependencies))
+ for (auto const &dependency : std::as_const(import.dependencies))
importHelper(dependency.module, types, QString(), dependency.version, true);
bool hasOptionalImports = false;
- for (auto const &import : qAsConst(import.imports)) {
+ for (auto const &import : std::as_const(import.imports)) {
if (import.flags & QQmlDirParser::Import::Optional) {
hasOptionalImports = true;
if (!m_useOptionalImports) {
@@ -576,7 +576,7 @@ void QQmlJSImporter::importQmldirs(const QStringList &qmldirFiles)
m_seenQmldirFiles.insert(qmldirName, result);
- for (const auto &object : qAsConst(result.objects)) {
+ for (const auto &object : std::as_const(result.objects)) {
for (const auto &ex : object.exports) {
m_seenImports.insert({ex.package(), ex.version()}, qmldirName);
// We also have to handle the case that no version is provided
@@ -696,7 +696,7 @@ bool QQmlJSImporter::importHelper(const QString &module, AvailableTypes *types,
if (modulePath.startsWith(u':')) {
if (m_mapper) {
const QString resourcePath = modulePath.mid(
- 1, modulePath.endsWith(u'/') ? modulePath.length() - 2 : -1)
+ 1, modulePath.endsWith(u'/') ? modulePath.size() - 2 : -1)
+ SlashQmldir;
const auto entry = m_mapper->entry(
QQmlJSResourceFileMapper::resourceFileFilter(resourcePath));
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp
index 5128b0f69c..6f2a8ee265 100644
--- a/src/qmlcompiler/qqmljsimportvisitor.cpp
+++ b/src/qmlcompiler/qqmljsimportvisitor.cpp
@@ -283,8 +283,8 @@ void QQmlJSImportVisitor::resolveAliasesAndIds()
if (doRequeue)
requeue.enqueue(object);
- if (objects.isEmpty() && requeue.length() < lastRequeueLength) {
- lastRequeueLength = requeue.length();
+ if (objects.isEmpty() && requeue.size() < lastRequeueLength) {
+ lastRequeueLength = requeue.size();
objects.swap(requeue);
}
}
@@ -547,7 +547,7 @@ void QQmlJSImportVisitor::processDefaultProperties()
const QQmlJSMetaProperty defaultProp = parentScope->property(defaultPropertyName);
- if (it.value().length() > 1 && !defaultProp.isList()) {
+ if (it.value().size() > 1 && !defaultProp.isList()) {
m_logger->log(
QStringLiteral("Cannot assign multiple objects to a default non-list property"),
Log_Property, it.value().constFirst()->sourceLocation());
@@ -618,7 +618,7 @@ void QQmlJSImportVisitor::processPropertyBindingObjects()
// literal bindings must already be added at this point.
QSet<QPair<QQmlJSScope::Ptr, QString>> visited;
for (const PendingPropertyObjectBinding &objectBinding :
- qAsConst(m_pendingPropertyObjectBindings)) {
+ std::as_const(m_pendingPropertyObjectBindings)) {
// unique because it's per-scope and per-property
const auto uniqueBindingId = qMakePair(objectBinding.scope, objectBinding.name);
if (visited.contains(uniqueBindingId))
@@ -640,7 +640,7 @@ void QQmlJSImportVisitor::processPropertyBindingObjects()
QSet<QPair<QQmlJSScope::Ptr, QString>> foundValueSources;
for (const PendingPropertyObjectBinding &objectBinding :
- qAsConst(m_pendingPropertyObjectBindings)) {
+ std::as_const(m_pendingPropertyObjectBindings)) {
const QString propertyName = objectBinding.name;
QQmlJSScope::ConstPtr childScope = objectBinding.childScope;
@@ -780,7 +780,7 @@ void QQmlJSImportVisitor::checkRequiredProperties()
QStringList aliasExpression =
property.aliasExpression().split(u'.');
- if (aliasExpression.length() != 2)
+ if (aliasExpression.size() != 2)
continue;
if (aliasExpression[0] == scopeId
&& aliasExpression[1] == propName) {
@@ -793,8 +793,8 @@ void QQmlJSImportVisitor::checkRequiredProperties()
if (propertyUsedInRootAlias)
continue;
- const QQmlJSScope::ConstPtr propertyScope = scopesToSearch.length() > 1
- ? scopesToSearch.at(scopesToSearch.length() - 2)
+ const QQmlJSScope::ConstPtr propertyScope = scopesToSearch.size() > 1
+ ? scopesToSearch.at(scopesToSearch.size() - 2)
: QQmlJSScope::ConstPtr();
const QString propertyScopeName = !propertyScope.isNull()
@@ -971,7 +971,7 @@ void QQmlJSImportVisitor::checkSignals()
const QStringList signalParameters = signalMethod->parameterNames();
- if (pair.second.length() > signalParameters.length()) {
+ if (pair.second.size() > signalParameters.size()) {
m_logger->log(QStringLiteral("Signal handler for \"%2\" has more formal"
" parameters than the signal it handles.")
.arg(pair.first),
@@ -979,7 +979,7 @@ void QQmlJSImportVisitor::checkSignals()
continue;
}
- for (qsizetype i = 0; i < pair.second.length(); i++) {
+ for (qsizetype i = 0; i < pair.second.size(); i++) {
const QStringView handlerParameter = pair.second.at(i);
const qsizetype j = signalParameters.indexOf(handlerParameter);
if (j == i || j < 0)
@@ -1043,7 +1043,7 @@ void QQmlJSImportVisitor::breakInheritanceCycles(const QQmlJSScope::Ptr &origina
for (QQmlJSScope::ConstPtr scope = originalScope; scope;) {
if (scopes.contains(scope)) {
QString inheritenceCycle;
- for (const auto &seen : qAsConst(scopes)) {
+ for (const auto &seen : std::as_const(scopes)) {
inheritenceCycle.append(seen->baseTypeName());
inheritenceCycle.append(QLatin1String(" -> "));
}
@@ -1273,7 +1273,7 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::StringLiteral *sl)
bool escaped = false;
const QChar stringQuote = s[0];
- for (qsizetype i = 1; i < s.length() - 1; i++) {
+ for (qsizetype i = 1; i < s.size() - 1; i++) {
const QChar c = s[i];
if (c == u'\\') {
@@ -1287,7 +1287,7 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::StringLiteral *sl)
} else {
if (c == u'`')
templateString += u'\\';
- if (c == u'$' && i + 1 < s.length() - 1 && s[i + 1] == u'{')
+ if (c == u'$' && i + 1 < s.size() - 1 && s[i + 1] == u'{')
templateString += u'\\';
}
@@ -1369,10 +1369,14 @@ bool QQmlJSImportVisitor::visit(UiInlineComponent *component)
return true;
}
-void QQmlJSImportVisitor::endVisit(UiInlineComponent *)
+void QQmlJSImportVisitor::endVisit(UiInlineComponent *component)
{
m_inlineComponentName = QStringView();
- Q_ASSERT(!m_nextIsInlineComponent);
+ if (m_nextIsInlineComponent) {
+ m_logger->log(u"Inline component declaration must be followed by a typename"_s,
+ Log_Syntax, component->firstSourceLocation());
+ }
+ m_nextIsInlineComponent = false; // might have missed an inline component if file contains invalid QML
}
bool QQmlJSImportVisitor::visit(UiPublicMember *publicMember)
@@ -1395,9 +1399,15 @@ bool QQmlJSImportVisitor::visit(UiPublicMember *publicMember)
QString aliasExpr;
const bool isAlias = (typeName == u"alias"_s);
if (isAlias) {
+ auto tryParseAlias = [&]() {
typeName.clear(); // type name is useless for alias here, so keep it empty
+ if (!publicMember->statement) {
+ m_logger->log(QStringLiteral("Invalid alias expression – an initalizer is needed."),
+ Log_Alias, publicMember->memberType->firstSourceLocation()); // TODO: extend warning to cover until endSourceLocation
+ return;
+ }
const auto expression = cast<ExpressionStatement *>(publicMember->statement);
- auto node = expression->expression;
+ auto node = expression ? expression->expression : nullptr;
auto fex = cast<FieldMemberExpression *>(node);
while (fex) {
node = fex->base;
@@ -1412,6 +1422,8 @@ bool QQmlJSImportVisitor::visit(UiPublicMember *publicMember)
"member expressions can be aliased."),
Log_Alias, expression->firstSourceLocation());
}
+ };
+ tryParseAlias();
} else {
const QString name = buildName(publicMember->memberType);
if (m_rootScopeImports.contains(name) && !m_rootScopeImports[name].scope.isNull()) {
diff --git a/src/qmlcompiler/qqmljslinter.cpp b/src/qmlcompiler/qqmljslinter.cpp
index 03eb481f5a..5c947cd321 100644
--- a/src/qmlcompiler/qqmljslinter.cpp
+++ b/src/qmlcompiler/qqmljslinter.cpp
@@ -223,9 +223,9 @@ void QQmlJSLinter::parseComments(QQmlJSLogger *logger,
if (!comment.startsWith(u" qmllint ") && !comment.startsWith(u"qmllint "))
continue;
- QStringList words = comment.split(u' ');
- if (words.constFirst().isEmpty())
- words.removeFirst();
+ QStringList words = comment.split(u' ', Qt::SkipEmptyParts);
+ if (words.size() < 2)
+ continue;
const QString command = words.at(1);
@@ -246,21 +246,23 @@ void QQmlJSLinter::parseComments(QQmlJSLogger *logger,
}
if (command == u"disable"_s) {
- const QString line = lines[loc.startLine - 1];
- const QString preComment = line.left(line.indexOf(comment) - 2);
-
- bool lineHasContent = false;
- for (qsizetype i = 0; i < preComment.size(); i++) {
- if (!preComment[i].isSpace()) {
- lineHasContent = true;
- break;
+ if (const qsizetype lineIndex = loc.startLine - 1; lineIndex < lines.size()) {
+ const QString line = lines[loc.startLine - 1];
+ const QString preComment = line.left(line.indexOf(comment) - 2);
+
+ bool lineHasContent = false;
+ for (qsizetype i = 0; i < preComment.size(); i++) {
+ if (!preComment[i].isSpace()) {
+ lineHasContent = true;
+ break;
+ }
}
- }
- if (lineHasContent)
- oneLineDisablesPerLine[loc.startLine] |= categories;
- else
- disablesPerLine[loc.startLine] |= categories;
+ if (lineHasContent)
+ oneLineDisablesPerLine[loc.startLine] |= categories;
+ else
+ disablesPerLine[loc.startLine] |= categories;
+ }
} else if (command == u"enable"_s) {
enablesPerLine[loc.startLine + 1] |= categories;
} else {
diff --git a/src/qmlcompiler/qqmljslintercodegen.cpp b/src/qmlcompiler/qqmljslintercodegen.cpp
index dfa474fc46..e362044779 100644
--- a/src/qmlcompiler/qqmljslintercodegen.cpp
+++ b/src/qmlcompiler/qqmljslintercodegen.cpp
@@ -28,7 +28,6 @@ void QQmlJSLinterCodegen::setDocument(const QmlIR::JSCodeGen *codegen,
Q_UNUSED(codegen);
m_document = document;
m_unitGenerator = &document->jsGenerator;
- m_entireSourceCodeLines = document->code.split(u'\n');
}
std::variant<QQmlJSAotFunction, QQmlJS::DiagnosticMessage>
diff --git a/src/qmlcompiler/qqmljsloadergenerator.cpp b/src/qmlcompiler/qqmljsloadergenerator.cpp
index 21be215bba..494ecdadd0 100644
--- a/src/qmlcompiler/qqmljsloadergenerator.cpp
+++ b/src/qmlcompiler/qqmljsloadergenerator.cpp
@@ -49,7 +49,7 @@ QString mangledIdentifier(const QString &str)
}
}
- for (int ei = str.length(); i != ei; ++i) {
+ for (int ei = str.size(); i != ei; ++i) {
auto c = str.at(i).unicode();
if ((c >= QLatin1Char('0') && c <= QLatin1Char('9'))
|| (c >= QLatin1Char('a') && c <= QLatin1Char('z'))
@@ -68,7 +68,7 @@ QString qQmlJSSymbolNamespaceForPath(const QString &relativePath)
{
QFileInfo fi(relativePath);
QString symbol = fi.path();
- if (symbol.length() == 1 && symbol.startsWith(QLatin1Char('.'))) {
+ if (symbol.size() == 1 && symbol.startsWith(QLatin1Char('.'))) {
symbol.clear();
} else {
symbol.replace(QLatin1Char('/'), QLatin1Char('_'));
@@ -105,7 +105,7 @@ bool qQmlJSGenerateLoader(const QStringList &compiledFiles, const QString &outpu
stream << "\n";
stream << "namespace QmlCacheGeneratedCode {\n";
- for (int i = 0; i < compiledFiles.count(); ++i) {
+ for (int i = 0; i < compiledFiles.size(); ++i) {
const QString compiledFile = compiledFiles.at(i);
const QString ns = qQmlJSSymbolNamespaceForPath(compiledFile);
stream << "namespace " << ns << " { \n";
@@ -131,7 +131,7 @@ bool qQmlJSGenerateLoader(const QStringList &compiledFiles, const QString &outpu
stream << "Registry::Registry() {\n";
- for (int i = 0; i < compiledFiles.count(); ++i) {
+ for (int i = 0; i < compiledFiles.size(); ++i) {
const QString qrcFile = compiledFiles.at(i);
const QString ns = qQmlJSSymbolNamespaceForPath(qrcFile);
stream << " resourcePathToCachedUnit.insert(QStringLiteral(\"" << qrcFile << "\"), &QmlCacheGeneratedCode::" << ns << "::unit);\n";
diff --git a/src/qmlcompiler/qqmljslogger.cpp b/src/qmlcompiler/qqmljslogger.cpp
index d8b1fe096f..9c22f55287 100644
--- a/src/qmlcompiler/qqmljslogger.cpp
+++ b/src/qmlcompiler/qqmljslogger.cpp
@@ -223,7 +223,7 @@ void QQmlJSLogger::printContext(const QString &overrideFileName,
int tabCount = issueLocationWithContext.beforeText().count(QLatin1Char('\t'));
int locationLength = location.length == 0 ? 1 : location.length;
- m_output.write(QString::fromLatin1(" ").repeated(issueLocationWithContext.beforeText().length()
+ m_output.write(QString::fromLatin1(" ").repeated(issueLocationWithContext.beforeText().size()
- tabCount)
+ QString::fromLatin1("\t").repeated(tabCount)
+ QString::fromLatin1("^").repeated(locationLength) + QLatin1Char('\n'));
@@ -278,9 +278,9 @@ void QQmlJSLogger::printFix(const FixSuggestion &fix)
continue;
m_output.write(u" "_s.repeated(
- issueLocationWithContext.beforeText().length() - tabCount)
+ issueLocationWithContext.beforeText().size() - tabCount)
+ u"\t"_s.repeated(tabCount)
- + u"^"_s.repeated(fixItem.replacementString.length()) + u'\n');
+ + u"^"_s.repeated(fixItem.replacementString.size()) + u'\n');
}
}
diff --git a/src/qmlcompiler/qqmljslogger_p.h b/src/qmlcompiler/qqmljslogger_p.h
index 0302201eaf..9c89fd754a 100644
--- a/src/qmlcompiler/qqmljslogger_p.h
+++ b/src/qmlcompiler/qqmljslogger_p.h
@@ -201,6 +201,16 @@ public:
m_categoryChanged[category] = true;
}
+ bool isCategoryFatal(QQmlJSLoggerCategory category) const
+ {
+ return m_categoryFatal[category];
+ }
+ void setCategoryFatal(QQmlJSLoggerCategory category, bool error)
+ {
+ m_categoryFatal[category] = error;
+ m_categoryChanged[category] = true;
+ }
+
bool wasCategoryChanged(QQmlJSLoggerCategory category) const
{
return m_categoryChanged[category];
@@ -257,6 +267,10 @@ private:
bool m_categoryIgnored[QQmlJSLoggerCategory_Last + 1] = {};
bool m_categoryChanged[QQmlJSLoggerCategory_Last + 1] = {};
+ // If true, triggers qFatal on documents with "pragma Strict"
+ // TODO: Works only for qmlCompiler category so far.
+ bool m_categoryFatal[QQmlJSLoggerCategory_Last + 1] = {};
+
QList<Message> m_infos;
QList<Message> m_warnings;
QList<Message> m_errors;
diff --git a/src/qmlcompiler/qqmljsmetatypes_p.h b/src/qmlcompiler/qqmljsmetatypes_p.h
index 75f635d5d0..e2987984fb 100644
--- a/src/qmlcompiler/qqmljsmetatypes_p.h
+++ b/src/qmlcompiler/qqmljsmetatypes_p.h
@@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE
class QQmlJSTypeResolver;
class QQmlJSScope;
-class Q_QMLCOMPILER_PRIVATE_EXPORT QQmlJSMetaEnum
+class QQmlJSMetaEnum
{
QStringList m_keys;
QList<int> m_values; // empty if values unknown.
@@ -98,7 +98,7 @@ public:
}
};
-class Q_QMLCOMPILER_PRIVATE_EXPORT QQmlJSMetaMethod
+class QQmlJSMetaMethod
{
public:
enum Type {
@@ -158,7 +158,7 @@ public:
}
void setParameterTypes(const QList<QSharedPointer<const QQmlJSScope>> &types)
{
- Q_ASSERT(types.length() == m_paramNames.length());
+ Q_ASSERT(types.size() == m_paramNames.size());
m_paramTypes.clear();
for (const auto &type : types)
m_paramTypes.append(type);
@@ -262,7 +262,7 @@ private:
bool m_isImplicitQmlPropertyChangeSignal = false;
};
-class Q_QMLCOMPILER_PRIVATE_EXPORT QQmlJSMetaProperty
+class QQmlJSMetaProperty
{
QString m_propertyName;
QString m_typeName;
diff --git a/src/qmlcompiler/qqmljsresourcefilemapper.cpp b/src/qmlcompiler/qqmljsresourcefilemapper.cpp
index b9ae292018..4213902fb3 100644
--- a/src/qmlcompiler/qqmljsresourcefilemapper.cpp
+++ b/src/qmlcompiler/qqmljsresourcefilemapper.cpp
@@ -101,7 +101,7 @@ void doFilter(const QList<QQmlJSResourceFileMapper::Entry> &qrcPathToFileSystemP
if ((filter.flags & QQmlJSResourceFileMapper::Recurse)
// Crude. But shall we really allow slashes in QRC file names?
- || !candidate.mid(terminatedDirectory.length()).contains(u'/')) {
+ || !candidate.mid(terminatedDirectory.size()).contains(u'/')) {
if (handler(*it))
return;
}
diff --git a/src/qmlcompiler/qqmljsscope.cpp b/src/qmlcompiler/qqmljsscope.cpp
index 3e0cff0e52..03d47203ce 100644
--- a/src/qmlcompiler/qqmljsscope.cpp
+++ b/src/qmlcompiler/qqmljsscope.cpp
@@ -267,6 +267,9 @@ bool QQmlJSScope::causesImplicitComponentWrapping(const QQmlJSMetaProperty &prop
Either because it has been implicitly wrapped, e.g. due to an assignment to
a Component property, or because it is the first (and only) child of a
Component.
+ For visitors: This method should only be called after implicit components
+ are detected, that is, after QQmlJSImportVisitor::endVisit(UiProgram *)
+ was called.
*/
bool QQmlJSScope::isComponentRootElement() const {
if (m_flags.testFlag(WrappedInImplicitComponent))
@@ -339,7 +342,7 @@ QQmlJSScope::ImportedScope<QQmlJSScope::ConstPtr> QQmlJSScope::findType(
const QString outerTypeName = name.left(colonColon);
const auto outerType = contextualTypes.constFind(outerTypeName);
if (outerType != contextualTypes.constEnd()) {
- for (const auto &innerType : qAsConst(outerType->scope->m_childScopes)) {
+ for (const auto &innerType : std::as_const(outerType->scope->m_childScopes)) {
if (innerType->m_internalName == name) {
if (usedTypes != nullptr)
usedTypes->insert(name);
@@ -394,10 +397,10 @@ QTypeRevision QQmlJSScope::resolveType(
const auto paramTypeNames = it->parameterTypeNames();
QList<QSharedPointer<const QQmlJSScope>> paramTypes = it->parameterTypes();
- if (paramTypes.length() < paramTypeNames.length())
- paramTypes.resize(paramTypeNames.length());
+ if (paramTypes.size() < paramTypeNames.size())
+ paramTypes.resize(paramTypeNames.size());
- for (int i = 0, length = paramTypes.length(); i < length; ++i) {
+ for (int i = 0, length = paramTypes.size(); i < length; ++i) {
auto &paramType = paramTypes[i];
const auto paramTypeName = paramTypeNames[i];
if (!paramType && !paramTypeName.isEmpty()) {
diff --git a/src/qmlcompiler/qqmljsscope_p.h b/src/qmlcompiler/qqmljsscope_p.h
index 46aee20d90..6047d0c1d9 100644
--- a/src/qmlcompiler/qqmljsscope_p.h
+++ b/src/qmlcompiler/qqmljsscope_p.h
@@ -278,10 +278,30 @@ public:
{
using namespace Qt::StringLiterals;
- QString suffix;
- if (m_semantics == AccessSemantics::Reference)
- suffix = u" *"_s;
- return m_internalName + suffix;
+ switch (m_semantics) {
+ case AccessSemantics::Reference:
+ return m_internalName + " *"_L1;
+ case AccessSemantics::Value:
+ case AccessSemantics::Sequence:
+ break;
+ case AccessSemantics::None:
+ // If we got a namespace, it might still be a regular type, exposed as namespace.
+ // We may need to travel the inheritance chain all the way up to QObject to
+ // figure this out, since all other types may be exposed the same way.
+ for (QQmlJSScope::ConstPtr base = baseType(); base; base = base->baseType()) {
+ switch (base->accessSemantics()) {
+ case AccessSemantics::Reference:
+ return m_internalName + " *"_L1;
+ case AccessSemantics::Value:
+ case AccessSemantics::Sequence:
+ return m_internalName;
+ case AccessSemantics::None:
+ break;
+ }
+ }
+ break;
+ }
+ return m_internalName;
}
// This returns a more user readable version of internalName / baseTypeName
diff --git a/src/qmlcompiler/qqmljsshadowcheck.cpp b/src/qmlcompiler/qqmljsshadowcheck.cpp
index 719eeaef31..086b778263 100644
--- a/src/qmlcompiler/qqmljsshadowcheck.cpp
+++ b/src/qmlcompiler/qqmljsshadowcheck.cpp
@@ -36,11 +36,14 @@ void QQmlJSShadowCheck::run(
m_function = function;
m_error = error;
m_state = initialState(function);
- decode(m_function->code.constData(), static_cast<uint>(m_function->code.length()));
+ decode(m_function->code.constData(), static_cast<uint>(m_function->code.size()));
}
void QQmlJSShadowCheck::generate_LoadProperty(int nameIndex)
{
+ if (!m_state.readsRegister(Accumulator))
+ return; // enum lookup cannot be shadowed.
+
auto accumulatorIn = m_state.registers.find(Accumulator);
if (accumulatorIn != m_state.registers.end())
checkShadowing(accumulatorIn.value(), m_jsUnitGenerator->stringForIndex(nameIndex));
@@ -48,6 +51,9 @@ void QQmlJSShadowCheck::generate_LoadProperty(int nameIndex)
void QQmlJSShadowCheck::generate_GetLookup(int index)
{
+ if (!m_state.readsRegister(Accumulator))
+ return; // enum lookup cannot be shadowed.
+
auto accumulatorIn = m_state.registers.find(Accumulator);
if (accumulatorIn != m_state.registers.end())
checkShadowing(accumulatorIn.value(), m_jsUnitGenerator->lookupName(index));
diff --git a/src/qmlcompiler/qqmljsstreamwriter.cpp b/src/qmlcompiler/qqmljsstreamwriter.cpp
index 093d15dbd4..e435b8df92 100644
--- a/src/qmlcompiler/qqmljsstreamwriter.cpp
+++ b/src/qmlcompiler/qqmljsstreamwriter.cpp
@@ -161,7 +161,7 @@ void QQmlJSStreamWriter::flushPotentialLinesWithNewlines()
{
if (m_maybeOneline)
m_stream->write("\n");
- for (const QByteArray &line : qAsConst(m_pendingLines)) {
+ for (const QByteArray &line : std::as_const(m_pendingLines)) {
writeIndent();
m_stream->write(line);
m_stream->write("\n");
diff --git a/src/qmlcompiler/qqmljstypepropagator.cpp b/src/qmlcompiler/qqmljstypepropagator.cpp
index bab06d1035..9469380bba 100644
--- a/src/qmlcompiler/qqmljstypepropagator.cpp
+++ b/src/qmlcompiler/qqmljstypepropagator.cpp
@@ -50,7 +50,7 @@ QQmlJSCompilePass::InstructionAnnotations QQmlJSTypePropagator::run(
m_state.State::operator=(initialState(m_function));
reset();
- decode(m_function->code.constData(), static_cast<uint>(m_function->code.length()));
+ decode(m_function->code.constData(), static_cast<uint>(m_function->code.size()));
// If we have found unresolved backwards jumps, we need to start over with a fresh state.
// Mind that m_jumpOriginRegisterStateByTargetInstructionOffset is retained in that case.
@@ -287,20 +287,20 @@ void QQmlJSTypePropagator::handleUnqualifiedAccess(const QString &name, bool isM
if (isMethod) {
if (isCallingProperty(m_function->qmlScope, name))
return;
- } else if (isMissingPropertyType(m_function->qmlScope, name)) {
+ } else if (propertyResolution(m_function->qmlScope, name) != PropertyMissing) {
return;
}
std::optional<FixSuggestion> suggestion;
auto childScopes = m_function->qmlScope->childScopes();
- for (qsizetype i = 0; i < m_function->qmlScope->childScopes().length(); i++) {
+ for (qsizetype i = 0; i < m_function->qmlScope->childScopes().size(); i++) {
auto &scope = childScopes[i];
if (location.offset > scope->sourceLocation().offset) {
- if (i + 1 < childScopes.length()
+ if (i + 1 < childScopes.size()
&& childScopes.at(i + 1)->sourceLocation().offset < location.offset)
continue;
- if (scope->childScopes().length() == 0)
+ if (scope->childScopes().size() == 0)
continue;
const auto jsId = scope->childScopes().first()->findJSIdentifier(name);
@@ -481,18 +481,20 @@ bool QQmlJSTypePropagator::isRestricted(const QString &propertyName) const
}
// Only to be called once a lookup has already failed
-bool QQmlJSTypePropagator::isMissingPropertyType(QQmlJSScope::ConstPtr scope,
- const QString &propertyName) const
+QQmlJSTypePropagator::PropertyResolution QQmlJSTypePropagator::propertyResolution(
+ QQmlJSScope::ConstPtr scope, const QString &propertyName) const
{
auto property = scope->property(propertyName);
if (!property.isValid())
- return false;
+ return PropertyMissing;
QString errorType;
if (property.type().isNull())
errorType = u"found"_s;
else if (!property.type()->isFullyResolved())
errorType = u"fully resolved"_s;
+ else
+ return PropertyFullyResolved;
Q_ASSERT(!errorType.isEmpty());
@@ -501,7 +503,7 @@ bool QQmlJSTypePropagator::isMissingPropertyType(QQmlJSScope::ConstPtr scope,
.arg(property.typeName(), propertyName, errorType),
Log_Type, getCurrentSourceLocation());
- return true;
+ return PropertyTypeUnresolved;
}
bool QQmlJSTypePropagator::isCallingProperty(QQmlJSScope::ConstPtr scope, const QString &name) const
@@ -664,6 +666,10 @@ void QQmlJSTypePropagator::generate_StoreElement(int base, int index)
addReadAccumulator(jsValue);
addReadRegister(base, jsValue);
addReadRegister(index, jsValue);
+
+ // Writing to a JS array can have side effects all over the place since it's
+ // passed by reference.
+ m_state.setHasSideEffects(true);
return;
}
@@ -777,7 +783,7 @@ void QQmlJSTypePropagator::propagatePropertyLookup(const QString &propertyName)
auto baseType = m_typeResolver->containedType(m_state.accumulatorIn());
// Warn separately when a property is only not found because of a missing type
- if (isMissingPropertyType(baseType, propertyName))
+ if (propertyResolution(baseType, propertyName) != PropertyMissing)
return;
std::optional<FixSuggestion> fixSuggestion;
@@ -808,7 +814,7 @@ void QQmlJSTypePropagator::propagatePropertyLookup(const QString &propertyName)
return;
}
- if (m_state.accumulatorOut().isMethod() && m_state.accumulatorOut().method().length() != 1) {
+ if (m_state.accumulatorOut().isMethod() && m_state.accumulatorOut().method().size() != 1) {
setError(u"Cannot determine overloaded method on loadProperty"_s);
return;
}
@@ -1026,8 +1032,9 @@ void QQmlJSTypePropagator::generate_CallProperty(int nameIndex, int base, int ar
if (m_passManager != nullptr) {
// TODO: Should there be an analyzeCall() in the future? (w. corresponding onCall in Pass)
- m_passManager->analyzeRead(m_typeResolver->containedType(m_state.accumulatorIn()),
- propertyName, m_function->qmlScope, getCurrentSourceLocation());
+ m_passManager->analyzeRead(
+ m_typeResolver->containedType(callBase),
+ propertyName, m_function->qmlScope, getCurrentSourceLocation());
}
addReadRegister(base, callBase);
@@ -1159,8 +1166,8 @@ void QQmlJSTypePropagator::propagateCall(const QList<QQmlJSMetaMethod> &methods,
const QQmlJSMetaMethod match = bestMatchForCall(methods, argc, argv, &errors);
if (!match.isValid()) {
- Q_ASSERT(errors.length() == methods.length());
- if (methods.length() == 1)
+ Q_ASSERT(errors.size() == methods.size());
+ if (methods.size() == 1)
setError(errors.first());
else
setError(u"No matching override found. Candidates:\n"_s + errors.join(u'\n'));
@@ -1180,7 +1187,7 @@ void QQmlJSTypePropagator::propagateCall(const QList<QQmlJSMetaMethod> &methods,
m_state.setHasSideEffects(true);
const auto types = match.parameterTypes();
for (int i = 0; i < argc; ++i) {
- if (i < types.length()) {
+ if (i < types.size()) {
const QQmlJSScope::ConstPtr type = match.isJavaScriptFunction()
? m_typeResolver->jsValueType()
: QQmlJSScope::ConstPtr(types.at(i));
@@ -2156,12 +2163,12 @@ QString QQmlJSTypePropagator::registerName(int registerIndex) const
if (registerIndex == Accumulator)
return u"accumulator"_s;
if (registerIndex >= FirstArgument
- && registerIndex < FirstArgument + m_function->argumentTypes.count()) {
+ && registerIndex < FirstArgument + m_function->argumentTypes.size()) {
return u"argument %1"_s.arg(registerIndex - FirstArgument);
}
return u"temporary register %1"_s.arg(
- registerIndex - FirstArgument - m_function->argumentTypes.count());
+ registerIndex - FirstArgument - m_function->argumentTypes.size());
}
QQmlJSRegisterContent QQmlJSTypePropagator::checkedInputRegister(int reg)
diff --git a/src/qmlcompiler/qqmljstypepropagator_p.h b/src/qmlcompiler/qqmljstypepropagator_p.h
index 30967413b9..06fc2c9793 100644
--- a/src/qmlcompiler/qqmljstypepropagator_p.h
+++ b/src/qmlcompiler/qqmljstypepropagator_p.h
@@ -191,7 +191,14 @@ private:
void checkDeprecated(QQmlJSScope::ConstPtr scope, const QString &name, bool isMethod) const;
bool isRestricted(const QString &propertyName) const;
bool isCallingProperty(QQmlJSScope::ConstPtr scope, const QString &name) const;
- bool isMissingPropertyType(QQmlJSScope::ConstPtr scope, const QString &type) const;
+
+ enum PropertyResolution {
+ PropertyMissing,
+ PropertyTypeUnresolved,
+ PropertyFullyResolved
+ };
+
+ PropertyResolution propertyResolution(QQmlJSScope::ConstPtr scope, const QString &type) const;
QQmlJS::SourceLocation getCurrentSourceLocation() const;
QQmlJS::SourceLocation getCurrentBindingSourceLocation() const;
diff --git a/src/qmlcompiler/qqmljstyperesolver.cpp b/src/qmlcompiler/qqmljstyperesolver.cpp
index 046a79ce01..eeb5f605f0 100644
--- a/src/qmlcompiler/qqmljstyperesolver.cpp
+++ b/src/qmlcompiler/qqmljstyperesolver.cpp
@@ -38,6 +38,10 @@ QQmlJSTypeResolver::QQmlJSTypeResolver(QQmlJSImporter *importer)
m_varType = builtinTypes[u"QVariant"_s].scope;
m_jsValueType = builtinTypes[u"QJSValue"_s].scope;
+ QQmlJSScope::Ptr emptyType = QQmlJSScope::create();
+ emptyType->setAccessSemantics(QQmlJSScope::AccessSemantics::None);
+ m_emptyType = emptyType;
+
QQmlJSScope::Ptr emptyListType = QQmlJSScope::create();
emptyListType->setInternalName(u"void*"_s);
emptyListType->setAccessSemantics(QQmlJSScope::AccessSemantics::Sequence);
@@ -70,7 +74,7 @@ QQmlJSTypeResolver::QQmlJSTypeResolver(QQmlJSImporter *importer)
m_jsGlobalObject = importer->jsGlobalObject();
auto numberMethods = m_jsGlobalObject->methods(u"Number"_s);
- Q_ASSERT(numberMethods.length() == 1);
+ Q_ASSERT(numberMethods.size() == 1);
m_numberPrototype = numberMethods[0].returnType()->baseType();
Q_ASSERT(m_numberPrototype);
Q_ASSERT(m_numberPrototype->internalName() == u"NumberPrototype"_s);
@@ -169,7 +173,10 @@ QQmlJSScope::ConstPtr QQmlJSTypeResolver::typeForConst(QV4::ReturnedValue rv) co
return realType();
if (value.isNull())
- return jsPrimitiveType();
+ return nullType();
+
+ if (value.isEmpty())
+ return emptyType();
return {};
}
@@ -396,6 +403,64 @@ QQmlJSRegisterContent QQmlJSTypeResolver::transformed(
return {};
}
+QQmlJSRegisterContent QQmlJSTypeResolver::referenceTypeForName(
+ const QString &name, const QQmlJSScope::ConstPtr &scopeType,
+ bool hasObjectModulePrefix) const
+{
+ QQmlJSScope::ConstPtr type = typeForName(name);
+ if (!type)
+ return QQmlJSRegisterContent();
+
+ if (type->isSingleton())
+ return QQmlJSRegisterContent::create(storedType(type), type,
+ QQmlJSRegisterContent::Singleton, scopeType);
+
+ if (type->isScript())
+ return QQmlJSRegisterContent::create(storedType(type), type,
+ QQmlJSRegisterContent::Script, scopeType);
+
+ if (const auto attached = type->attachedType()) {
+ if (!genericType(attached)) {
+ m_logger->log(u"Cannot resolve generic base of attached %1"_s.arg(
+ attached->internalName()),
+ Log_Compiler, attached->sourceLocation());
+ return {};
+ } else if (type->accessSemantics() != QQmlJSScope::AccessSemantics::Reference) {
+ m_logger->log(u"Cannot retrieve attached object for non-reference type %1"_s.arg(
+ type->internalName()),
+ Log_Compiler, type->sourceLocation());
+ return {};
+ } else {
+ // We don't know yet whether we need the attached or the plain object. In direct
+ // mode, we will figure this out using the scope type and access any enums of the
+ // plain type directly. In indirect mode, we can use enum lookups.
+ return QQmlJSRegisterContent::create(
+ storedType(attached), attached,
+ hasObjectModulePrefix
+ ? QQmlJSRegisterContent::ObjectAttached
+ : QQmlJSRegisterContent::ScopeAttached, type);
+ }
+ }
+
+ switch (type->accessSemantics()) {
+ case QQmlJSScope::AccessSemantics::None:
+ case QQmlJSScope::AccessSemantics::Reference:
+ // A plain reference to a non-singleton, non-attached type.
+ // We may still need the plain type reference for enum lookups,
+ // Store it as QMetaObject.
+ // This only works with namespaces and object types.
+ return QQmlJSRegisterContent::create(metaObjectType(), metaObjectType(),
+ QQmlJSRegisterContent::MetaType, type);
+ case QQmlJSScope::AccessSemantics::Sequence:
+ case QQmlJSScope::AccessSemantics::Value:
+ // This is not actually a type reference. You cannot get the metaobject
+ // of a value type in QML and sequences don't even have metaobjects.
+ break;
+ }
+
+ return QQmlJSRegisterContent();
+}
+
QQmlJSRegisterContent QQmlJSTypeResolver::original(const QQmlJSRegisterContent &type) const
{
return transformed(type, &QQmlJSTypeResolver::originalType);
@@ -643,7 +708,8 @@ QQmlJSScope::ConstPtr QQmlJSTypeResolver::genericType(const QQmlJSScope::ConstPt
return m_metaObjectType;
if (type->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) {
- for (auto base = type; base; base = base->baseType()) {
+ QString unresolvedBaseTypeName;
+ for (auto base = type; base;) {
// QObject and QQmlComponent are the two required base types.
// Any QML type system has to define those, or use the ones from builtins.
// As QQmlComponent is derived from QObject, we can restrict ourselves to the latter.
@@ -655,10 +721,19 @@ QQmlJSScope::ConstPtr QQmlJSTypeResolver::genericType(const QQmlJSScope::ConstPt
&& base->internalName() == u"QQmlComponent"_s) {
return base;
}
+
+ if (auto baseBase = base->baseType()) {
+ base = baseBase;
+ } else {
+ unresolvedBaseTypeName = base->baseTypeName();
+ break;
+ }
}
- m_logger->log(u"Object type %1 is not derived from QObject or QQmlComponent"_s.arg(
- type->internalName()),
+ m_logger->log(u"Object type %1 is not derived from QObject or QQmlComponent. "
+ "You may need to fully qualify all names in C++ so that moc can see them. "
+ "You may also need to add qt_extract_metatypes(<target containing %2>)."_s
+ .arg(type->internalName(), unresolvedBaseTypeName),
Log_Compiler, type->sourceLocation());
// Reference types that are not QObject or QQmlComponent are likely JavaScript objects.
@@ -685,6 +760,7 @@ QQmlJSScope::ConstPtr QQmlJSTypeResolver::genericType(const QQmlJSScope::ConstPt
return type;
if (const QQmlJSScope::ConstPtr valueType = type->valueType())
return listType(genericType(valueType), UseQObjectList);
+ return m_variantListType;
}
return m_varType;
@@ -802,51 +878,9 @@ QQmlJSRegisterContent QQmlJSTypeResolver::scopedType(const QQmlJSScope::ConstPtr
}
}
- if (QQmlJSScope::ConstPtr type = typeForName(name)) {
- if (type->isSingleton())
- return QQmlJSRegisterContent::create(storedType(type), type,
- QQmlJSRegisterContent::Singleton);
-
- if (type->isScript())
- return QQmlJSRegisterContent::create(storedType(type), type,
- QQmlJSRegisterContent::Script);
-
- if (const auto attached = type->attachedType()) {
- if (!genericType(attached)) {
- m_logger->log(u"Cannot resolve generic base of attached %1"_s.arg(
- attached->internalName()),
- Log_Compiler, attached->sourceLocation());
- return {};
- } else if (type->accessSemantics() != QQmlJSScope::AccessSemantics::Reference) {
- m_logger->log(u"Cannot retrieve attached object for non-reference type %1"_s.arg(
- type->internalName()),
- Log_Compiler, type->sourceLocation());
- return {};
- } else {
- // We don't know yet whether we need the attached or the plain object. In direct
- // mode, we will figure this out using the scope type and access any enums of the
- // plain type directly. In indirect mode, we can use enum lookups.
- return QQmlJSRegisterContent::create(storedType(attached), attached,
- QQmlJSRegisterContent::ScopeAttached, type);
- }
- }
-
- switch (type->accessSemantics()) {
- case QQmlJSScope::AccessSemantics::None:
- case QQmlJSScope::AccessSemantics::Reference:
- // A plain reference to a non-singleton, non-attached type.
- // We may still need the plain type reference for enum lookups,
- // Store it as QMetaObject.
- // This only works with namespaces and object types.
- return QQmlJSRegisterContent::create(metaObjectType(), metaObjectType(),
- QQmlJSRegisterContent::MetaType, type);
- case QQmlJSScope::AccessSemantics::Sequence:
- case QQmlJSScope::AccessSemantics::Value:
- // This is not actually a type reference. You cannot get the metaobject
- // of a value type in QML and sequences don't even have metaobjects.
- break;
- }
- }
+ QQmlJSRegisterContent result = referenceTypeForName(name);
+ if (result.isValid())
+ return result;
if (m_jsGlobalObject->hasProperty(name)) {
return QQmlJSRegisterContent::create(jsValueType(), m_jsGlobalObject->property(name),
@@ -987,6 +1021,10 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType(const QQmlJSScope::ConstPtr
{
QQmlJSRegisterContent result;
+ // If we got a plain type reference we have to check the enums of the _scope_.
+ if (equals(type, metaObjectType()))
+ return {};
+
if (equals(type, jsValueType())) {
QQmlJSMetaProperty prop;
prop.setPropertyName(name);
@@ -1134,34 +1172,9 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType(const QQmlJSRegisterContent
return {};
}
- if (QQmlJSScope::ConstPtr result = typeForName(name)) {
- QQmlJSScope::ConstPtr attached = result->attachedType();
- if (attached && genericType(attached)) {
- return QQmlJSRegisterContent::create(
- storedType(attached), attached,
- type.variant() == QQmlJSRegisterContent::ObjectModulePrefix
- ? QQmlJSRegisterContent::ObjectAttached
- : QQmlJSRegisterContent::ScopeAttached,
- result);
- }
-
- if (result->isSingleton()) {
- return QQmlJSRegisterContent::create(
- storedType(result), result,
- QQmlJSRegisterContent::Singleton, type.scopeType());
- }
-
- if (result->isScript()) {
- return QQmlJSRegisterContent::create(
- storedType(result), result,
- QQmlJSRegisterContent::Script, type.scopeType());
- }
-
- return QQmlJSRegisterContent::create(metaObjectType(), metaObjectType(),
- QQmlJSRegisterContent::MetaType, result);
- }
-
- return {};
+ return referenceTypeForName(
+ name, type.scopeType(),
+ type.variant() == QQmlJSRegisterContent::ObjectModulePrefix);
}
if (type.isConversion()) {
const auto result = memberType(type.conversionResult(), name);
@@ -1243,7 +1256,7 @@ bool QQmlJSTypeResolver::registerContains(const QQmlJSRegisterContent &reg,
: equals(type, prop.type());
}
if (reg.isEnumeration())
- return equals(type, intType());
+ return equals(type, reg.enumeration().type());
if (reg.isMethod())
return equals(type, jsValueType());
return false;
diff --git a/src/qmlcompiler/qqmljstyperesolver_p.h b/src/qmlcompiler/qqmljstyperesolver_p.h
index e05f5b3757..a56a85bbc6 100644
--- a/src/qmlcompiler/qqmljstyperesolver_p.h
+++ b/src/qmlcompiler/qqmljstyperesolver_p.h
@@ -39,6 +39,7 @@ public:
void init(QQmlJSImportVisitor *visitor, QQmlJS::AST::Node *program);
QQmlJSScope::ConstPtr voidType() const { return m_voidType; }
+ QQmlJSScope::ConstPtr emptyType() const { return m_emptyType; }
QQmlJSScope::ConstPtr emptyListType() const { return m_emptyListType; }
QQmlJSScope::ConstPtr nullType() const { return m_nullType; }
QQmlJSScope::ConstPtr realType() const { return m_realType; }
@@ -167,8 +168,14 @@ protected:
const QQmlJSRegisterContent &origin,
QQmlJSScope::ConstPtr (QQmlJSTypeResolver::*op)(const QQmlJSScope::ConstPtr &) const) const;
+ QQmlJSRegisterContent referenceTypeForName(
+ const QString &name,
+ const QQmlJSScope::ConstPtr &scopeType = QQmlJSScope::ConstPtr(),
+ bool hasObjectModuelPrefix = false) const;
+
QQmlJSScope::ConstPtr m_voidType;
QQmlJSScope::ConstPtr m_emptyListType;
+ QQmlJSScope::ConstPtr m_emptyType;
QQmlJSScope::ConstPtr m_nullType;
QQmlJSScope::ConstPtr m_numberPrototype;
QQmlJSScope::ConstPtr m_realType;
diff --git a/src/qmlcompiler/qqmljsutils.cpp b/src/qmlcompiler/qqmljsutils.cpp
index c07c0b6845..8ef11444d7 100644
--- a/src/qmlcompiler/qqmljsutils.cpp
+++ b/src/qmlcompiler/qqmljsutils.cpp
@@ -25,17 +25,23 @@ resolveAlias(ScopeForId scopeForId, const QQmlJSMetaProperty &property,
QQmlJSUtils::ResolvedAlias result {};
result.owner = owner;
- for (QQmlJSMetaProperty nextProperty = property; nextProperty.isAlias();) {
-
- // this is a special (seemingly useless) section which is necessary when
- // we have an alias pointing to an alias. this way we avoid a check
- // whether a property is an alias at the very end of the loop body
+ // TODO: one could optimize the generated alias code for aliases pointing to aliases
+ // e.g., if idA.myAlias -> idB.myAlias2 -> idC.myProp, then one could directly generate
+ // idA.myProp as pointing to idC.myProp.
+ // This gets complicated when idB.myAlias is in a different Component than where the
+ // idA.myAlias is defined: scopeForId currently only contains the ids of the current
+ // component and alias resolution on the ids of a different component fails then.
+ if (QQmlJSMetaProperty nextProperty = property; nextProperty.isAlias()) {
QQmlJSScope::ConstPtr resultOwner = result.owner;
result = QQmlJSUtils::ResolvedAlias {};
visitor.reset();
auto aliasExprBits = nextProperty.aliasExpression().split(u'.');
+ // do not crash on invalid aliasexprbits when accessing aliasExprBits[0]
+ if (aliasExprBits.size() < 1)
+ return {};
+
// resolve id first:
resultOwner = scopeForId(aliasExprBits[0], resultOwner);
if (!resultOwner)
@@ -46,10 +52,8 @@ resolveAlias(ScopeForId scopeForId, const QQmlJSMetaProperty &property,
aliasExprBits.removeFirst(); // Note: for simplicity, remove the <id>
result.owner = resultOwner;
result.kind = QQmlJSUtils::AliasTarget_Object;
- // reset the property to avoid endless loop when aliasExprBits is empty
- nextProperty = QQmlJSMetaProperty {};
- for (const QString &bit : qAsConst(aliasExprBits)) {
+ for (const QString &bit : std::as_const(aliasExprBits)) {
nextProperty = resultOwner->property(bit);
if (!nextProperty.isValid())
return {};
@@ -96,7 +100,7 @@ std::optional<FixSuggestion> QQmlJSUtils::didYouMean(const QString &userInput,
QQmlJS::SourceLocation location)
{
QString shortestDistanceWord;
- int shortestDistance = userInput.length();
+ int shortestDistance = userInput.size();
// Most of the time the candidates are keys() from QHash, which means that
// running this function in the seemingly same setup might yield different
@@ -114,14 +118,14 @@ std::optional<FixSuggestion> QQmlJSUtils::didYouMean(const QString &userInput,
* Roughly based on
* https://en.wikipedia.org/wiki/Levenshtein_distance#Iterative_with_two_matrix_rows.
*/
- QList<int> v0(candidate.length() + 1);
- QList<int> v1(candidate.length() + 1);
+ QList<int> v0(candidate.size() + 1);
+ QList<int> v1(candidate.size() + 1);
std::iota(v0.begin(), v0.end(), 0);
- for (qsizetype i = 0; i < userInput.length(); i++) {
+ for (qsizetype i = 0; i < userInput.size(); i++) {
v1[0] = i + 1;
- for (qsizetype j = 0; j < candidate.length(); j++) {
+ for (qsizetype j = 0; j < candidate.size(); j++) {
int deletionCost = v0[j + 1] + 1;
int insertionCost = v1[j] + 1;
int substitutionCost = userInput[i] == candidate[j] ? v0[j] : v0[j] + 1;
@@ -130,7 +134,7 @@ std::optional<FixSuggestion> QQmlJSUtils::didYouMean(const QString &userInput,
std::swap(v0, v1);
}
- int distance = v0[candidate.length()];
+ int distance = v0[candidate.size()];
if (distance < shortestDistance) {
shortestDistanceWord = candidate;
shortestDistance = distance;
@@ -138,7 +142,7 @@ std::optional<FixSuggestion> QQmlJSUtils::didYouMean(const QString &userInput,
}
if (shortestDistance
- < std::min(std::max(userInput.length() / 2, qsizetype(3)), userInput.length())) {
+ < std::min(std::max(userInput.size() / 2, qsizetype(3)), userInput.size())) {
return FixSuggestion { { FixSuggestion::Fix {
u"Did you mean \"%1\"?"_s.arg(shortestDistanceWord), location,
shortestDistanceWord } } };
diff --git a/src/qmlcompiler/qqmljsutils_p.h b/src/qmlcompiler/qqmljsutils_p.h
index 8a1ee9c287..040e996cd4 100644
--- a/src/qmlcompiler/qqmljsutils_p.h
+++ b/src/qmlcompiler/qqmljsutils_p.h
@@ -104,7 +104,7 @@ struct Q_QMLCOMPILER_PRIVATE_EXPORT QQmlJSUtils
{
if (handlerName.startsWith(u"on") && handlerName.size() > 2) {
QString signal = handlerName.mid(2).toString();
- for (int i = 0; i < signal.length(); ++i) {
+ for (int i = 0; i < signal.size(); ++i) {
QChar &ch = signal[i];
if (ch.isLower())
return {};
diff --git a/src/qmldebug/qqmlprofilerclient_p_p.h b/src/qmldebug/qqmlprofilerclient_p_p.h
index 39e606ab61..e6cf1054ee 100644
--- a/src/qmldebug/qqmlprofilerclient_p_p.h
+++ b/src/qmldebug/qqmlprofilerclient_p_p.h
@@ -43,7 +43,7 @@ public:
{
}
- virtual ~QQmlProfilerClientPrivate() override;
+ ~QQmlProfilerClientPrivate() override;
void sendRecordingStatus(int engineId);
bool updateFeatures(ProfileFeature feature);
diff --git a/src/qmldebug/qv4debugclient.cpp b/src/qmldebug/qv4debugclient.cpp
index bb108fc5ef..83c6660a94 100644
--- a/src/qmldebug/qv4debugclient.cpp
+++ b/src/qmldebug/qv4debugclient.cpp
@@ -293,7 +293,7 @@ void QV4DebugClient::scripts(int types, const QList<int> &ids, bool includeSourc
QJsonObject args;
args.insert(QLatin1String(TYPES), types);
- if (ids.count()) {
+ if (ids.size()) {
QJsonArray array;
for (int id : ids)
array.append(id);
diff --git a/src/qmldom/qqmldomastcreator.cpp b/src/qmldom/qqmldomastcreator.cpp
index 81d2d5d750..78c896619e 100644
--- a/src/qmldom/qqmldomastcreator.cpp
+++ b/src/qmldom/qqmldomastcreator.cpp
@@ -67,6 +67,26 @@ static QString toString(const UiQualifiedId *qualifiedId, QChar delimiter = QLat
return result;
}
+static QString typeToString(AST::Type *t)
+{
+ Q_ASSERT(t);
+ QString res = toString(t->typeId);
+ if (!t->typeArguments)
+ return res;
+ res += u"<";
+ bool first = true;
+ for (TypeArgumentList *tt = static_cast<TypeArgumentList *>(t->typeArguments);
+ tt; tt = tt->next) {
+ if (first)
+ first = false;
+ else
+ res += u",";
+ res += typeToString(tt->typeId);
+ }
+ res += u">";
+ return res;
+}
+
SourceLocation combineLocations(SourceLocation s1, SourceLocation s2)
{
return combine(s1, s2);
@@ -113,9 +133,9 @@ class QmlDomAstCreator final : public AST::Visitor
template<typename T>
StackEl &currentEl(int idx = 0)
{
- Q_ASSERT_X(idx < nodeStack.length() && idx >= 0, "currentQmlObjectOrComponentEl",
+ Q_ASSERT_X(idx < nodeStack.size() && idx >= 0, "currentQmlObjectOrComponentEl",
"Stack does not contain enough elements!");
- int i = nodeStack.length() - idx;
+ int i = nodeStack.size() - idx;
while (i-- > 0) {
DomType k = nodeStack.at(i).item.kind;
if (k == T::kindValue)
@@ -135,9 +155,9 @@ class QmlDomAstCreator final : public AST::Visitor
StackEl &currentQmlObjectOrComponentEl(int idx = 0)
{
- Q_ASSERT_X(idx < nodeStack.length() && idx >= 0, "currentQmlObjectOrComponentEl",
+ Q_ASSERT_X(idx < nodeStack.size() && idx >= 0, "currentQmlObjectOrComponentEl",
"Stack does not contain enough elements!");
- int i = nodeStack.length() - idx;
+ int i = nodeStack.size() - idx;
while (i-- > 0) {
DomType k = nodeStack.at(i).item.kind;
if (k == DomType::QmlObject || k == DomType::QmlComponent)
@@ -149,16 +169,16 @@ class QmlDomAstCreator final : public AST::Visitor
StackEl &currentNodeEl(int i = 0)
{
- Q_ASSERT_X(i < nodeStack.length() && i >= 0, "currentNode",
+ Q_ASSERT_X(i < nodeStack.size() && i >= 0, "currentNode",
"Stack does not contain element!");
- return nodeStack[nodeStack.length() - i - 1];
+ return nodeStack[nodeStack.size() - i - 1];
}
DomValue &currentNode(int i = 0)
{
- Q_ASSERT_X(i < nodeStack.length() && i >= 0, "currentNode",
+ Q_ASSERT_X(i < nodeStack.size() && i >= 0, "currentNode",
"Stack does not contain element!");
- return nodeStack[nodeStack.length() - i - 1].item;
+ return nodeStack[nodeStack.size() - i - 1].item;
}
void removeCurrentNode(std::optional<DomType> expectedType)
@@ -451,7 +471,7 @@ public:
currentEl<QmlObject>()
.path.field(Fields::bindings)
.key(pDef.name)
- .index(obj.m_bindings.values(pDef.name).length() - 1),
+ .index(obj.m_bindings.values(pDef.name).size() - 1),
ann);
}
}
@@ -487,13 +507,8 @@ public:
MethodInfo m;
m.name = fDef->name.toString();
if (AST::TypeAnnotation *tAnn = fDef->typeAnnotation) {
- if (AST::Type *t = tAnn->type) {
- m.typeName = toString(t->typeId);
- if (t->typeArguments) {
- Q_ASSERT_X(false, className,
- "todo: type argument should be added to the typeName");
- }
- }
+ if (AST::Type *t = tAnn->type)
+ m.typeName = typeToString(t);
}
m.access = MethodInfo::Public;
m.methodType = MethodInfo::Method;
@@ -528,13 +543,8 @@ public:
MethodParameter param;
param.name = args->element->bindingIdentifier.toString();
if (AST::TypeAnnotation *tAnn = args->element->typeAnnotation) {
- if (AST::Type *t = tAnn->type) {
- param.typeName = toString(t->typeId);
- if (t->typeArguments) {
- Q_ASSERT_X(false, className,
- "todo: type argument should be added to the typeName");
- }
- }
+ if (AST::Type *t = tAnn->type)
+ param.typeName = typeToString(t);
}
if (args->element->initializer) {
SourceLocation loc = combineLocations(args->element->initializer);
@@ -581,11 +591,11 @@ public:
scope.addPrototypePath(Paths::lookupTypePath(scope.name()));
QmlObject *sPtr = nullptr;
Path sPathFromOwner;
- if (!arrayBindingLevels.isEmpty() && nodeStack.length() == arrayBindingLevels.last()) {
+ if (!arrayBindingLevels.isEmpty() && nodeStack.size() == arrayBindingLevels.last()) {
if (currentNode().kind == DomType::Binding) {
QList<QmlObject> *vals = std::get<Binding>(currentNode().value).arrayValue();
if (vals) {
- int idx = vals->length();
+ int idx = vals->size();
vals->append(scope);
sPathFromOwner = currentNodeEl().path.field(Fields::value).index(idx);
sPtr = &((*vals)[idx]);
@@ -621,7 +631,7 @@ public:
{
QmlObject &obj = current<QmlObject>();
int idx = currentIndex();
- if (!arrayBindingLevels.isEmpty() && nodeStack.length() == arrayBindingLevels.last() + 1) {
+ if (!arrayBindingLevels.isEmpty() && nodeStack.size() == arrayBindingLevels.last() + 1) {
if (currentNode(1).kind == DomType::Binding) {
Binding &b = std::get<Binding>(currentNode(1).value);
QList<QmlObject> *vals = b.arrayValue();
@@ -804,7 +814,7 @@ public:
createMap(currentNodeEl().fileLocations, Path::Field(Fields::value), nullptr);
FileLocations::addRegion(arrayList, u"leftSquareBrace", el->lbracketToken);
FileLocations::addRegion(arrayList, u"rightSquareBrace", el->lbracketToken);
- arrayBindingLevels.append(nodeStack.length());
+ arrayBindingLevels.append(nodeStack.size());
return true;
}
diff --git a/src/qmldom/qqmldomcomments.cpp b/src/qmldom/qqmldomcomments.cpp
index 19e1328d6e..257916cffa 100644
--- a/src/qmldom/qqmldomcomments.cpp
+++ b/src/qmldom/qqmldomcomments.cpp
@@ -68,12 +68,12 @@ CommentInfo gets such a raw comment string and makes the various pieces availabl
CommentInfo::CommentInfo(QStringView rawComment) : rawComment(rawComment)
{
commentBegin = 0;
- while (commentBegin < quint32(rawComment.length()) && rawComment.at(commentBegin).isSpace()) {
+ while (commentBegin < quint32(rawComment.size()) && rawComment.at(commentBegin).isSpace()) {
if (rawComment.at(commentBegin) == QLatin1Char('\n'))
hasStartNewline = true;
++commentBegin;
}
- if (commentBegin < quint32(rawComment.length())) {
+ if (commentBegin < quint32(rawComment.size())) {
QString expectedEnd;
switch (rawComment.at(commentBegin).unicode()) {
case '/':
@@ -98,7 +98,7 @@ CommentInfo::CommentInfo(QStringView rawComment) : rawComment(rawComment)
break;
}
commentEnd = commentBegin + commentStartStr.size();
- quint32 rawEnd = quint32(rawComment.length());
+ quint32 rawEnd = quint32(rawComment.size());
while (commentEnd < rawEnd && rawComment.at(commentEnd).isSpace())
++commentEnd;
commentContentEnd = commentContentBegin = commentEnd;
@@ -106,9 +106,9 @@ CommentInfo::CommentInfo(QStringView rawComment) : rawComment(rawComment)
while (commentEnd < rawEnd) {
QChar c = rawComment.at(commentEnd);
if (c == e1) {
- if (expectedEnd.length() > 1) {
+ if (expectedEnd.size() > 1) {
if (++commentEnd < rawEnd && rawComment.at(commentEnd) == expectedEnd.at(1)) {
- Q_ASSERT(expectedEnd.length() == 2);
+ Q_ASSERT(expectedEnd.size() == 2);
commentEndStr = rawComment.mid(++commentEnd - 2, 2);
break;
} else {
diff --git a/src/qmldom/qqmldomcomments_p.h b/src/qmldom/qqmldomcomments_p.h
index fe7638913a..5dd541684e 100644
--- a/src/qmldom/qqmldomcomments_p.h
+++ b/src/qmldom/qqmldomcomments_p.h
@@ -145,7 +145,7 @@ public:
Path addPreComment(const Comment &comment, QString regionName)
{
auto &preList = regionComments[regionName].preComments;
- index_type idx = preList.length();
+ index_type idx = preList.size();
preList.append(comment);
return Path::Field(Fields::regionComments)
.key(regionName)
@@ -156,7 +156,7 @@ public:
Path addPostComment(const Comment &comment, QString regionName)
{
auto &postList = regionComments[regionName].postComments;
- index_type idx = postList.length();
+ index_type idx = postList.size();
postList.append(comment);
return Path::Field(Fields::regionComments)
.key(regionName)
diff --git a/src/qmldom/qqmldomelements_p.h b/src/qmldom/qqmldomelements_p.h
index 0f5159e535..341ca1e68f 100644
--- a/src/qmldom/qqmldomelements_p.h
+++ b/src/qmldom/qqmldomelements_p.h
@@ -541,7 +541,7 @@ public:
bool isSignalHandler() const
{
QString baseName = m_name.split(QLatin1Char('.')).last();
- if (baseName.startsWith(u"on") && baseName.length() > 2 && baseName.at(2).isUpper())
+ if (baseName.startsWith(u"on") && baseName.size() > 2 && baseName.at(2).isUpper())
return true;
return false;
}
diff --git a/src/qmldom/qqmldomerrormessage.cpp b/src/qmldom/qqmldomerrormessage.cpp
index 6eb9ce98ea..d4b95850e2 100644
--- a/src/qmldom/qqmldomerrormessage.cpp
+++ b/src/qmldom/qqmldomerrormessage.cpp
@@ -72,20 +72,20 @@ and use it to create new ErrorMessages using its debug, warning, error,... metho
void ErrorGroups::dump(Sink sink) const
{
- for (int i = 0; i < groups.length(); ++i)
+ for (int i = 0; i < groups.size(); ++i)
groups.at(i).dump(sink);
}
void ErrorGroups::dumpId(Sink sink) const
{
- for (int i = 0; i < groups.length(); ++i)
+ for (int i = 0; i < groups.size(); ++i)
groups.at(i).dumpId(sink);
}
QCborArray ErrorGroups::toCbor() const
{
QCborArray res;
- for (int i = 0; i < groups.length(); ++i)
+ for (int i = 0; i < groups.size(); ++i)
res.append(QCborValue(groups.at(i).groupId()));
return res;
}
@@ -163,7 +163,7 @@ void ErrorGroups::fatal(Dumper msg, Path element, QStringView canonicalFilePath,
int ibuf = 0;
auto sink = [&ibuf, &buf](QStringView s) {
int is = 0;
- while (ibuf < FatalMsgMaxLen && is < s.length()) {
+ while (ibuf < FatalMsgMaxLen && is < s.size()) {
QChar c = s.at(is);
if (c == QChar::fromLatin1('\n') || c == QChar::fromLatin1('\r') || (c >= QChar::fromLatin1(' ') && c <= QChar::fromLatin1('~')))
buf[ibuf++] = c.toLatin1();
@@ -236,11 +236,11 @@ int ErrorGroups::cmp(const ErrorGroups &o1, const ErrorGroups &o2)
{
auto &g1 = o1.groups;
auto &g2 = o2.groups;
- if (g1.length() < g2.length())
+ if (g1.size() < g2.size())
return -1;
- if (g1.length() < g2.length())
+ if (g1.size() < g2.size())
return 1;
- for (int i = 0; i < g1.length(); ++i) {
+ for (int i = 0; i < g1.size(); ++i) {
int c = std::strcmp(g1.at(i).groupId().data(), g2.at(i).groupId().data());
if (c != 0)
return c;
diff --git a/src/qmldom/qqmldomexternalitems_p.h b/src/qmldom/qqmldomexternalitems_p.h
index 4f6648f9e4..7bd51a30d1 100644
--- a/src/qmldom/qqmldomexternalitems_p.h
+++ b/src/qmldom/qqmldomexternalitems_p.h
@@ -286,7 +286,7 @@ public:
void setImports(const QList<Import> &imports) { m_imports = imports; }
Path addImport(const Import &i)
{
- index_type idx = index_type(m_imports.length());
+ index_type idx = index_type(m_imports.size());
m_imports.append(i);
if (i.uri.isModule()) {
m_importScope.addImport((i.importId.isEmpty()
@@ -313,7 +313,7 @@ public:
void setPragmas(QList<Pragma> pragmas) { m_pragmas = pragmas; }
Path addPragma(const Pragma &pragma)
{
- int idx = m_pragmas.length();
+ int idx = m_pragmas.size();
m_pragmas.append(pragma);
return Path::Field(Fields::pragmas).index(idx);
}
@@ -383,7 +383,7 @@ public:
void setExports(QMultiMap<QString, Export> e) { m_exports = e; }
Path addExport(const Export &e)
{
- index_type i = m_exports.values(e.typeName).length();
+ index_type i = m_exports.values(e.typeName).size();
m_exports.insert(e.typeName, e);
addUri(e.uri, e.version.majorVersion);
return canonicalPath().field(Fields::exports).index(i);
diff --git a/src/qmldom/qqmldomitem.cpp b/src/qmldom/qqmldomitem.cpp
index f7ef17771b..040218cf84 100644
--- a/src/qmldom/qqmldomitem.cpp
+++ b/src/qmldom/qqmldomitem.cpp
@@ -1653,6 +1653,11 @@ bool DomItem::visitLookup1(QString symbolName, function_ref<bool(DomItem &)> vis
// the prototype chain)
DomItem importScope = fileObject().field(Fields::importScope);
if (const ImportScope *importScopePtr = importScope.as<ImportScope>()) {
+ if (importScopePtr->subImports().contains(symbolName)) {
+ DomItem subItem = importScope.field(Fields::qualifiedImports).key(symbolName);
+ if (!visitor(subItem))
+ return false;
+ }
QList<DomItem> types = importScopePtr->importedItemsWithName(importScope, symbolName);
for (DomItem &t : types) {
if (!visitor(t))
@@ -1740,18 +1745,18 @@ bool DomItem::visitLookup(QString target, function_ref<bool(DomItem &)> visitor,
while (!lookupToDos.isEmpty()) {
ResolveToDo tNow = lookupToDos.takeFirst();
auto vNow = qMakePair(tNow.item.id(), tNow.pathIndex);
- if (vNow.first != 0) {
- if (lookupVisited[vNow.second].contains(vNow.first))
- continue;
- else
- lookupVisited[vNow.second].insert(vNow.first);
- }
DomItem subNow = tNow.item;
int iSubPath = tNow.pathIndex;
Q_ASSERT(iSubPath < subpath.length());
QString subPathNow = subpath[iSubPath++];
DomItem scope = subNow.proceedToScope();
if (iSubPath < subpath.length()) {
+ if (vNow.first != 0) {
+ if (lookupVisited[vNow.second].contains(vNow.first))
+ continue;
+ else
+ lookupVisited[vNow.second].insert(vNow.first);
+ }
if (scope.internalKind() == DomType::QmlObject)
scope.visitDirectAccessibleScopes(
[&lookupToDos, subPathNow, iSubPath](DomItem &el) {
@@ -2106,7 +2111,7 @@ bool DomItem::visitLocalSymbolsNamed(QString name, function_ref<bool(DomItem &)>
return false;
f = field(Fields::qualifiedImports);
v = f.key(name);
- if (!v.visitIndexes(visitor))
+ if (v && !visitor(v))
return false;
break;
default:
diff --git a/src/qmldom/qqmldomitem_p.h b/src/qmldom/qqmldomitem_p.h
index f5fca3bc41..10945734da 100644
--- a/src/qmldom/qqmldomitem_p.h
+++ b/src/qmldom/qqmldomitem_p.h
@@ -407,7 +407,7 @@ public:
for (void *p : pList)
m_pList.append(p);
} else if (options == ListOptions::Reverse) {
- for (qsizetype i = pList.length(); i-- != 0;)
+ for (qsizetype i = pList.size(); i-- != 0;)
// probably writing in reverse and reading sequentially would be better
m_pList.append(pList.at(i));
} else {
@@ -1204,21 +1204,21 @@ List List::fromQList(
std::function<DomItem(DomItem &, const PathEls::PathComponent &, T &)> elWrapper,
ListOptions options)
{
- index_type len = list.length();
+ index_type len = list.size();
if (options == ListOptions::Reverse) {
return List(
pathFromOwner,
[list, elWrapper](DomItem &self, index_type i) mutable {
- if (i < 0 || i >= list.length())
+ if (i < 0 || i >= list.size())
return DomItem();
- return elWrapper(self, PathEls::Index(i), list[list.length() - i - 1]);
+ return elWrapper(self, PathEls::Index(i), list[list.size() - i - 1]);
},
[len](DomItem &) { return len; }, nullptr, QLatin1String(typeid(T).name()));
} else {
return List(
pathFromOwner,
[list, elWrapper](DomItem &self, index_type i) mutable {
- if (i < 0 || i >= list.length())
+ if (i < 0 || i >= list.size())
return DomItem();
return elWrapper(self, PathEls::Index(i), list[i]);
},
@@ -1236,21 +1236,21 @@ List List::fromQListRef(
return List(
pathFromOwner,
[&list, elWrapper](DomItem &self, index_type i) {
- if (i < 0 || i >= list.length())
+ if (i < 0 || i >= list.size())
return DomItem();
- return elWrapper(self, PathEls::Index(i), list[list.length() - i - 1]);
+ return elWrapper(self, PathEls::Index(i), list[list.size() - i - 1]);
},
- [&list](DomItem &) { return list.length(); }, nullptr,
+ [&list](DomItem &) { return list.size(); }, nullptr,
QLatin1String(typeid(T).name()));
} else {
return List(
pathFromOwner,
[&list, elWrapper](DomItem &self, index_type i) {
- if (i < 0 || i >= list.length())
+ if (i < 0 || i >= list.size())
return DomItem();
return elWrapper(self, PathEls::Index(i), list[i]);
},
- [&list](DomItem &) { return list.length(); }, nullptr,
+ [&list](DomItem &) { return list.size(); }, nullptr,
QLatin1String(typeid(T).name()));
}
}
@@ -1635,7 +1635,7 @@ template<typename T>
Path appendUpdatableElementInQList(Path listPathFromOwner, QList<T> &list, const T &value,
T **vPtr = nullptr)
{
- int idx = list.length();
+ int idx = list.size();
list.append(value);
Path newPath = listPathFromOwner.index(idx);
T &targetV = list[idx];
@@ -1946,7 +1946,7 @@ bool ListPT<T>::iterateDirectSubpaths(DomItem &self, DirectVisitor v)
template<typename T>
DomItem ListPT<T>::index(DomItem &self, index_type index) const
{
- if (index >= 0 && index < m_pList.length())
+ if (index >= 0 && index < m_pList.size())
return self.wrap(PathEls::Index(index), *reinterpret_cast<T *>(m_pList.value(index)));
return DomItem();
}
diff --git a/src/qmldom/qqmldomlinewriter.cpp b/src/qmldom/qqmldomlinewriter.cpp
index cb312b4fa7..c0110e8bf9 100644
--- a/src/qmldom/qqmldomlinewriter.cpp
+++ b/src/qmldom/qqmldomlinewriter.cpp
@@ -94,10 +94,10 @@ LineWriter &LineWriter::ensureSpace(QStringView space, TextAddType t)
if (ind.nNewlines > 0)
ensureNewline(ind.nNewlines, t);
if (cc != counter() || m_currentLine.isEmpty()
- || !m_currentLine.at(m_currentLine.length() - 1).isSpace())
+ || !m_currentLine.at(m_currentLine.size() - 1).isSpace())
write(ind.trailingString, t);
else {
- int len = m_currentLine.length();
+ int len = m_currentLine.size();
int i = len;
while (i != 0 && m_currentLine.at(i - 1).isSpace())
--i;
@@ -109,8 +109,8 @@ LineWriter &LineWriter::ensureSpace(QStringView space, TextAddType t)
ind = IndentInfo(space, tabSize, trailingSpaceStartColumn);
if (i == 0) {
if (indExisting.column < ind.column) {
- qint32 utf16Change = ind.trailingString.length() - trailingSpace.length();
- m_currentColumnNr += ind.trailingString.length() - trailingSpace.length();
+ qint32 utf16Change = ind.trailingString.size() - trailingSpace.size();
+ m_currentColumnNr += ind.trailingString.size() - trailingSpace.size();
m_currentLine.replace(
i, len - i, ind.trailingString.toString()); // invalidates most QStringViews
changeAtOffset(i, utf16Change, utf16Change, 0);
@@ -341,8 +341,8 @@ void LineWriter::changeAtOffset(quint32 offset, qint32 change, qint32 colChange,
int LineWriter::column(int index)
{
- if (index > m_currentLine.length())
- index = m_currentLine.length();
+ if (index > m_currentLine.size())
+ index = m_currentLine.size();
IndentInfo iInfo(QStringView(m_currentLine).mid(0, index), m_options.formatOptions.tabSize,
m_columnNr);
return iInfo.column;
diff --git a/src/qmldom/qqmldomlinewriter_p.h b/src/qmldom/qqmldomlinewriter_p.h
index b3efadd958..ff7c075899 100644
--- a/src/qmldom/qqmldomlinewriter_p.h
+++ b/src/qmldom/qqmldomlinewriter_p.h
@@ -45,7 +45,7 @@ public:
column = initialColumn + fixup;
const QChar tab = QLatin1Char('\t');
int iStart = 0;
- int len = line.length();
+ int len = line.size();
for (int i = 0; i < len; i++) {
if (line[i] == tab)
column = ((column / tabSize) + 1) * tabSize;
diff --git a/src/qmldom/qqmldommoduleindex.cpp b/src/qmldom/qqmldommoduleindex.cpp
index 5dfb4d7917..37a33c328a 100644
--- a/src/qmldom/qqmldommoduleindex.cpp
+++ b/src/qmldom/qqmldommoduleindex.cpp
@@ -154,7 +154,7 @@ QSet<QString> ModuleIndex::exportNames(DomItem &self) const
{
QSet<QString> res;
QList<Path> mySources = sources();
- for (int i = 0; i < mySources.length(); ++i) {
+ for (int i = 0; i < mySources.size(); ++i) {
DomItem source = self.path(mySources.at(i));
res += source.field(Fields::exports).keys();
}
@@ -230,7 +230,7 @@ QList<DomItem> ModuleIndex::exportsWithNameAndMinorVersion(DomItem &self, QStrin
if (minorVersion < 0)
minorVersion = std::numeric_limits<int>::max();
int vNow = Version::Undefined;
- for (int i = 0; i < mySources.length(); ++i) {
+ for (int i = 0; i < mySources.size(); ++i) {
DomItem source = self.path(mySources.at(i));
DomItem exports = source.field(Fields::exports).key(name);
int nExports = exports.indexes();
diff --git a/src/qmldom/qqmldompath.cpp b/src/qmldom/qqmldompath.cpp
index 447e0479c4..2af5f3739b 100644
--- a/src/qmldom/qqmldompath.cpp
+++ b/src/qmldom/qqmldompath.cpp
@@ -90,7 +90,7 @@ QString Filter::name() const {
bool Filter::checkName(QStringView s) const
{
return s.startsWith(u"?(")
- && s.mid(2, s.length()-3) == filterDescription
+ && s.mid(2, s.size()-3) == filterDescription
&& s.endsWith(u")");
}
@@ -181,9 +181,9 @@ const PathEls::PathComponent &Path::component(int i) const
i = i - m_length - m_endOffset;
auto data = m_data.get();
while (data) {
- i += data->components.length();
+ i += data->components.size();
if (i >= 0)
- return qAsConst(data)->components[i];
+ return std::as_const(data)->components[i];
data = data->parent.get();
}
Q_ASSERT(false && "Invalid data reached while resolving a seemengly valid index in Path (inconsisten Path object)");
@@ -311,7 +311,7 @@ Path Path::fromString(QStringView s, ErrorHandler errorHandler)
const QChar backslash = QChar::fromLatin1('\\');
const QChar underscore = QChar::fromLatin1('_');
const QChar tilda = QChar::fromLatin1('~');
- for (int i=0; i < s.length(); ++i)
+ for (int i=0; i < s.size(); ++i)
if (s.at(i) == lsBrace || s.at(i) == dot)
++len;
QVector<Component> components;
@@ -320,25 +320,25 @@ Path Path::fromString(QStringView s, ErrorHandler errorHandler)
int i0 = 0;
PathEls::ParserState state = PathEls::ParserState::Start;
QStringList strVals;
- while (i < s.length()) {
+ while (i < s.size()) {
// skip space
- while (i < s.length() && s.at(i).isSpace())
+ while (i < s.size() && s.at(i).isSpace())
++i;
- if (i >= s.length())
+ if (i >= s.size())
break;
QChar c = s.at(i++);
switch (state) {
case PathEls::ParserState::Start:
if (c == dollar) {
i0 = i;
- while (i < s.length() && s.at(i).isLetterOrNumber()){
+ while (i < s.size() && s.at(i).isLetterOrNumber()){
++i;
}
components.append(Component(PathEls::Root(s.mid(i0,i-i0))));
state = PathEls::ParserState::End;
} else if (c == at) {
i0 = i;
- while (i < s.length() && s.at(i).isLetterOrNumber()){
+ while (i < s.size() && s.at(i).isLetterOrNumber()){
++i;
}
components.append(Component(PathEls::Current(s.mid(i0,i-i0))));
@@ -355,7 +355,7 @@ Path Path::fromString(QStringView s, ErrorHandler errorHandler)
case PathEls::ParserState::IndexOrKey:
if (c.isDigit()) {
i0 = i-1;
- while (i < s.length() && s.at(i).isDigit())
+ while (i < s.size() && s.at(i).isDigit())
++i;
bool ok;
components.append(Component(static_cast<index_type>(s.mid(i0,i-i0).toString()
@@ -367,14 +367,14 @@ Path Path::fromString(QStringView s, ErrorHandler errorHandler)
}
} else if (c.isLetter() || c == tilda || c == underscore) {
i0 = i-1;
- while (i < s.length() && (s.at(i).isLetterOrNumber() || s.at(i) == underscore || s.at(i) == tilda))
+ while (i < s.size() && (s.at(i).isLetterOrNumber() || s.at(i) == underscore || s.at(i) == tilda))
++i;
components.append(Component(PathEls::Key(s.mid(i0, i - i0).toString())));
} else if (c == quote) {
i0 = i;
QString strVal;
bool properEnd = false;
- while (i < s.length()) {
+ while (i < s.size()) {
c = s.at(i);
if (c == quote) {
properEnd = true;
@@ -406,16 +406,16 @@ Path Path::fromString(QStringView s, ErrorHandler errorHandler)
} else if (c == QChar::fromLatin1('*')) {
components.append(Component(PathEls::Any()));
} else if (c == QChar::fromLatin1('?')) {
- while (i < s.length() && s.at(i).isSpace())
+ while (i < s.size() && s.at(i).isSpace())
++i;
- if (i >= s.length() || s.at(i) != QChar::fromLatin1('(')) {
+ if (i >= s.size() || s.at(i) != QChar::fromLatin1('(')) {
myErrors().error(tr("Expected a brace in filter after the question mark (at char %1).")
.arg(QString::number(i))).handle(errorHandler);
return Path();
}
i0 = ++i;
- while (i < s.length() && s.at(i) != QChar::fromLatin1(')')) ++i; // check matching braces when skipping??
- if (i >= s.length() || s.at(i) != QChar::fromLatin1(')')) {
+ while (i < s.size() && s.at(i) != QChar::fromLatin1(')')) ++i; // check matching braces when skipping??
+ if (i >= s.size() || s.at(i) != QChar::fromLatin1(')')) {
myErrors().error(tr("Expected a closing brace in filter after the question mark (at char %1).")
.arg(QString::number(i))).handle(errorHandler);
return Path();
@@ -429,8 +429,8 @@ Path Path::fromString(QStringView s, ErrorHandler errorHandler)
.arg(c).arg(i-1)).handle(errorHandler);
return Path();
}
- while (i < s.length() && s.at(i).isSpace()) ++i;
- if (i >= s.length() || s.at(i) != rsBrace) {
+ while (i < s.size() && s.at(i).isSpace()) ++i;
+ if (i >= s.size() || s.at(i) != rsBrace) {
myErrors().error(tr("square braces misses closing brace at char %1.")
.arg(QString::number(i))).handle(errorHandler);
return Path();
@@ -441,20 +441,20 @@ Path Path::fromString(QStringView s, ErrorHandler errorHandler)
break;
case PathEls::ParserState::End:
if (c == dot) {
- while (i < s.length() && s.at(i).isSpace()) ++i;
- if (i == s.length()) {
+ while (i < s.size() && s.at(i).isSpace()) ++i;
+ if (i == s.size()) {
components.append(Component());
state = PathEls::ParserState::End;
} else if (s.at(i).isLetter() || s.at(i) == underscore || s.at(i) == tilda) {
i0 = i;
- while (i < s.length() && (s.at(i).isLetterOrNumber() || s.at(i) == underscore || s.at(i) == tilda)) {
+ while (i < s.size() && (s.at(i).isLetterOrNumber() || s.at(i) == underscore || s.at(i) == tilda)) {
++i;
}
components.append(Component(PathEls::Field(s.mid(i0,i-i0))));
state = PathEls::ParserState::End;
} else if (s.at(i).isDigit()) {
i0 = i;
- while (i < s.length() && s.at(i).isDigit()){
+ while (i < s.size() && s.at(i).isDigit()){
++i;
}
bool ok;
@@ -474,14 +474,14 @@ Path Path::fromString(QStringView s, ErrorHandler errorHandler)
state = PathEls::ParserState::End;
} else if (s.at(i) == at) {
i0 = ++i;
- while (i < s.length() && s.at(i).isLetterOrNumber()){
+ while (i < s.size() && s.at(i).isLetterOrNumber()){
++i;
}
components.append(Component(PathEls::Current(s.mid(i0,i-i0))));
state = PathEls::ParserState::End;
} else if (s.at(i) == dollar) {
i0 = ++i;
- while (i < s.length() && s.at(i).isLetterOrNumber()){
+ while (i < s.size() && s.at(i).isLetterOrNumber()){
++i;
}
components.append(Component(PathEls::Root(s.mid(i0,i-i0))));
@@ -512,7 +512,7 @@ Path Path::fromString(QStringView s, ErrorHandler errorHandler)
return Path();
case PathEls::ParserState::End:
- return Path(0, components.length(), std::shared_ptr<PathEls::PathData>(
+ return Path(0, components.size(), std::shared_ptr<PathEls::PathData>(
new PathEls::PathData(strVals, components)));
}
Q_ASSERT(false && "Unexpected state in Path::fromString");
@@ -728,9 +728,9 @@ Path Path::path(Path toAdd, bool avoidToAddAsBase) const
}
data = toAdd.m_data.get();
while (data) {
- for (int ij = 0; ij < data->strData.length(); ++ij) {
+ for (int ij = 0; ij < data->strData.size(); ++ij) {
bool hasAlready = false;
- for (int ii = 0; ii < myStrs.length() && !hasAlready; ++ii)
+ for (int ii = 0; ii < myStrs.size() && !hasAlready; ++ii)
hasAlready = inQString(data->strData[ij], myStrs[ii]);
if (!hasAlready)
addedStrs.append(data->strData[ij]);
@@ -743,7 +743,7 @@ Path Path::path(Path toAdd, bool avoidToAddAsBase) const
components.append(toAdd.component(i));
QStringView compStrView = toAdd.component(i).stringView();
if (!compStrView.isEmpty()) {
- for (int j = 0; j < addedStrs.length(); ++j) {
+ for (int j = 0; j < addedStrs.size(); ++j) {
if (inQString(compStrView, addedStrs[j])) {
toAddStrs.append(addedStrs[j]);
addedStrs.removeAt(j);
@@ -761,7 +761,7 @@ Path Path::expandFront() const
int newLen = 0;
auto data = m_data.get();
while (data) {
- newLen += data->components.length();
+ newLen += data->components.size();
data = data->parent.get();
}
newLen -= m_endOffset;
@@ -822,14 +822,14 @@ Path Path::noEndOffset() const
// peel back
qint16 endOffset = m_endOffset;
std::shared_ptr<PathEls::PathData> lastData = m_data;
- while (lastData && endOffset >= lastData->components.length()) {
- endOffset -= lastData->components.length();
+ while (lastData && endOffset >= lastData->components.size()) {
+ endOffset -= lastData->components.size();
lastData = lastData->parent;
}
if (endOffset > 0) {
Q_ASSERT(lastData && "Internal problem, reference to non existing PathData");
return Path(0, m_length, std::shared_ptr<PathEls::PathData>(
- new PathEls::PathData(lastData->strData, lastData->components.mid(0, lastData->components.length() - endOffset), lastData->parent)));
+ new PathEls::PathData(lastData->strData, lastData->components.mid(0, lastData->components.size() - endOffset), lastData->parent)));
}
return Path(0, m_length, lastData);
}
diff --git a/src/qmldom/qqmldomreformatter.cpp b/src/qmldom/qqmldomreformatter.cpp
index bb76f8f772..3dfacfc84e 100644
--- a/src/qmldom/qqmldomreformatter.cpp
+++ b/src/qmldom/qqmldomreformatter.cpp
@@ -301,6 +301,7 @@ protected:
for (PatternPropertyList *it = ast; it; it = it->next) {
PatternProperty *assignment = AST::cast<PatternProperty *>(it->property);
if (assignment) {
+ preVisit(assignment);
bool isStringLike = AST::cast<StringLiteralPropertyName *>(assignment->name)
|| cast<IdentifierPropertyName *>(assignment->name);
if (isStringLike)
@@ -316,6 +317,7 @@ protected:
accept(assignment->initializer);
if (it->next)
newLine();
+ postVisit(assignment);
continue;
}
PatternPropertyList *getterSetter = AST::cast<PatternPropertyList *>(it->next);
diff --git a/src/qmldom/qqmldomstringdumper.cpp b/src/qmldom/qqmldomstringdumper.cpp
index a964a542e0..081a6abf81 100644
--- a/src/qmldom/qqmldomstringdumper.cpp
+++ b/src/qmldom/qqmldomstringdumper.cpp
@@ -63,7 +63,7 @@ void sinkEscaped(Sink sink, QStringView s, EscapeOptions options) {
if (options == EscapeOptions::OuterQuotes)
sink(u"\"");
int it0=0;
- for (int it = 0; it < s.length();++it) {
+ for (int it = 0; it < s.size();++it) {
QChar c=s[it];
bool noslash = c != QLatin1Char('\\');
bool noquote = c != QLatin1Char('"');
@@ -84,7 +84,7 @@ void sinkEscaped(Sink sink, QStringView s, EscapeOptions options) {
else
Q_ASSERT(0);
}
- sink(s.mid(it0, s.length() - it0));
+ sink(s.mid(it0, s.size() - it0));
if (options == EscapeOptions::OuterQuotes)
sink(u"\"");
}
@@ -161,9 +161,9 @@ void sinkIndent(Sink s, int indent)
{
if (indent > 0) {
QStringView spaces = u" ";
- while (indent > spaces.length()) {
+ while (indent > spaces.size()) {
s(spaces);
- indent -= spaces.length();
+ indent -= spaces.size();
}
s(spaces.left(indent));
}
diff --git a/src/qmldom/qqmldomtop.cpp b/src/qmldom/qqmldomtop.cpp
index 61ecbb4957..0e263a0859 100644
--- a/src/qmldom/qqmldomtop.cpp
+++ b/src/qmldom/qqmldomtop.cpp
@@ -2158,7 +2158,7 @@ void DomEnvironment::loadPendingDependencies(DomItem &self)
m_allLoadedCallback.clear();
}
}
- for (const Callback &cb : qAsConst(endCallbacks))
+ for (const Callback &cb : std::as_const(endCallbacks))
cb(self.canonicalPath(), self, self);
});
DomItem loadInfoObj = self.copy(loadInfo);
diff --git a/src/qmldom/qqmldomtop_p.h b/src/qmldom/qqmldomtop_p.h
index f1b0a3b76a..1e020600fc 100644
--- a/src/qmldom/qqmldomtop_p.h
+++ b/src/qmldom/qqmldomtop_p.h
@@ -567,7 +567,7 @@ public:
int nNotDone() const
{
QMutexLocker l(mutex());
- return m_toDo.length() + m_inProgress.length();
+ return m_toDo.size() + m_inProgress.size();
}
QList<Dependency> inProgress() const
@@ -585,7 +585,7 @@ public:
int nCallbacks() const
{
QMutexLocker l(mutex());
- return m_endCallbacks.length();
+ return m_endCallbacks.size();
}
private:
diff --git a/src/qmldom/qqmldomtypesreader.cpp b/src/qmldom/qqmldomtypesreader.cpp
index f6c8eecdc4..5dd486a41d 100644
--- a/src/qmldom/qqmldomtypesreader.cpp
+++ b/src/qmldom/qqmldomtypesreader.cpp
@@ -248,7 +248,7 @@ bool QmltypesReader::parse()
QStringList dependencies;
QHash<QString, QQmlJSExportedScope> objects;
m_isValid = reader(&objects, &dependencies);
- for (const auto &obj : qAsConst(objects))
+ for (const auto &obj : std::as_const(objects))
insertComponent(obj.scope, obj.exports);
qmltypesFilePtr()->setIsValid(m_isValid);
return m_isValid;
diff --git a/src/qmldom/standalone/private/qtqmlcompilerexports_p.h b/src/qmldom/standalone/private/qtqmlcompilerexports_p.h
index 6906e69371..28864cd96f 100644
--- a/src/qmldom/standalone/private/qtqmlcompilerexports_p.h
+++ b/src/qmldom/standalone/private/qtqmlcompilerexports_p.h
@@ -4,6 +4,18 @@
#include "../qqmldom_global.h"
#ifndef QTQMLCOMPILEREXPORTS_P_H
#define QTQMLCOMPILEREXPORTS_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.
+//
+
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
#include <QtCore/qstring.h>
namespace Qt {
diff --git a/src/qmllocalstorage/qqmllocalstorage.cpp b/src/qmllocalstorage/qqmllocalstorage.cpp
index 59e503f59d..073b3c790f 100644
--- a/src/qmllocalstorage/qqmllocalstorage.cpp
+++ b/src/qmllocalstorage/qqmllocalstorage.cpp
@@ -491,7 +491,7 @@ through the data.
*/
/*!
- \qmlmodule QtQuick.LocalStorage 2.\QtMinorVersion
+ \qmlmodule QtQuick.LocalStorage
\title Qt Quick Local Storage QML Types
\ingroup qmlmodules
\brief Provides a JavaScript object singleton type for accessing a local
@@ -549,10 +549,10 @@ db = Sql.openDatabaseSync(identifier, version, description, estimated_size, call
\endqml
The above code returns the database identified by \e identifier. If the database does not already
-exist, it is created, and the function \e callback is called with the database as a parameter. \e
-identifier is the name of the physical file (with or without full path) containing the database. \e
-description and \e estimated_size are written to the INI file (described below), but are currently
-unused.
+exist, it is created, and the function \e callback is called with the database as a parameter.
+\e identifier is the name of the physical file (with or without relative path) containing the
+database. \e description and \e estimated_size are written to the INI file (described below), but
+are currently unused.
May throw exception with code property SQLException.DATABASE_ERR, or SQLException.VERSION_ERR.
diff --git a/src/qmlmodels/qqmladaptormodel.cpp b/src/qmlmodels/qqmladaptormodel.cpp
index 080cd90aa6..1f275ded5a 100644
--- a/src/qmlmodels/qqmladaptormodel.cpp
+++ b/src/qmlmodels/qqmladaptormodel.cpp
@@ -109,7 +109,7 @@ public:
}
QVector<int> signalIndexes;
- for (int i = 0; i < roles.count(); ++i) {
+ for (int i = 0; i < roles.size(); ++i) {
const int role = roles.at(i);
if (!changed && watchedRoleIds.contains(role))
changed = true;
@@ -119,7 +119,7 @@ public:
signalIndexes.append(propertyId + signalOffset);
}
if (roles.isEmpty()) {
- const int propertyRolesCount = propertyRoles.count();
+ const int propertyRolesCount = propertyRoles.size();
signalIndexes.reserve(propertyRolesCount);
for (int propertyId = 0; propertyId < propertyRolesCount; ++propertyId)
signalIndexes.append(propertyId + signalOffset);
@@ -129,13 +129,13 @@ public:
for (const auto item : items)
guardedItems.append(item);
- for (const auto &item : qAsConst(guardedItems)) {
+ for (const auto &item : std::as_const(guardedItems)) {
if (item.isNull())
continue;
const int idx = item->modelIndex();
if (idx >= index && idx < index + count) {
- for (int i = 0; i < signalIndexes.count(); ++i)
+ for (int i = 0; i < signalIndexes.size(); ++i)
QMetaObject::activate(item, signalIndexes.at(i), nullptr);
}
}
@@ -226,7 +226,7 @@ QQmlDMCachedModelData::QQmlDMCachedModelData(
, type(dataType)
{
if (index == -1)
- cachedData.resize(type->hasModelData ? 1 : type->propertyRoles.count());
+ cachedData.resize(type->hasModelData ? 1 : type->propertyRoles.size());
QObjectPrivate::get(this)->metaObject = type;
@@ -250,10 +250,10 @@ int QQmlDMCachedModelData::metaCall(QMetaObject::Call call, int id, void **argum
const int propertyIndex = id - type->propertyOffset;
if (index == -1) {
const QMetaObject *meta = metaObject();
- if (cachedData.count() > 1) {
+ if (cachedData.size() > 1) {
cachedData[propertyIndex] = *static_cast<QVariant *>(arguments[0]);
QMetaObject::activate(this, meta, propertyIndex, nullptr);
- } else if (cachedData.count() == 1) {
+ } else if (cachedData.size() == 1) {
cachedData[0] = *static_cast<QVariant *>(arguments[0]);
QMetaObject::activate(this, meta, 0, nullptr);
QMetaObject::activate(this, meta, 1, nullptr);
@@ -271,7 +271,7 @@ void QQmlDMCachedModelData::setValue(const QString &role, const QVariant &value)
{
QHash<QByteArray, int>::iterator it = type->roleNames.find(role.toUtf8());
if (it != type->roleNames.end()) {
- for (int i = 0; i < type->propertyRoles.count(); ++i) {
+ for (int i = 0; i < type->propertyRoles.size(); ++i) {
if (type->propertyRoles.at(i) == *it) {
cachedData[i] = value;
return;
@@ -287,7 +287,7 @@ bool QQmlDMCachedModelData::resolveIndex(const QQmlAdaptorModel &adaptorModel, i
cachedData.clear();
setModelIndex(idx, adaptorModel.rowAt(idx), adaptorModel.columnAt(idx));
const QMetaObject *meta = metaObject();
- const int propertyCount = type->propertyRoles.count();
+ const int propertyCount = type->propertyRoles.size();
for (int i = 0; i < propertyCount; ++i)
QMetaObject::activate(this, meta, i, nullptr);
return true;
@@ -332,10 +332,10 @@ QV4::ReturnedValue QQmlDMCachedModelData::set_property(const QV4::FunctionObject
if (o->d()->item->index == -1) {
QQmlDMCachedModelData *modelData = static_cast<QQmlDMCachedModelData *>(o->d()->item);
if (!modelData->cachedData.isEmpty()) {
- if (modelData->cachedData.count() > 1) {
+ if (modelData->cachedData.size() > 1) {
modelData->cachedData[propertyId] = scope.engine->toVariant(argv[0], QMetaType {});
QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), propertyId, nullptr);
- } else if (modelData->cachedData.count() == 1) {
+ } else if (modelData->cachedData.size() == 1) {
modelData->cachedData[0] = scope.engine->toVariant(argv[0], QMetaType {});
QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 0, nullptr);
QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 1, nullptr);
@@ -496,12 +496,12 @@ public:
const QAbstractItemModel *aim = model.aim();
const QHash<int, QByteArray> names = aim ? aim->roleNames() : QHash<int, QByteArray>();
for (QHash<int, QByteArray>::const_iterator it = names.begin(), cend = names.end(); it != cend; ++it) {
- const int propertyId = propertyRoles.count();
+ const int propertyId = propertyRoles.size();
propertyRoles.append(it.key());
roleNames.insert(it.value(), it.key());
addProperty(&builder, propertyId, it.value(), propertyType);
}
- if (propertyRoles.count() == 1) {
+ if (propertyRoles.size() == 1) {
hasModelData = true;
const int role = names.begin().key();
const QByteArray propertyName = QByteArrayLiteral("modelData");
@@ -656,7 +656,7 @@ public:
// NB: This acquires the lock on QQmlMetaTypeData. If we had a QQmlEngine here,
// we could use QQmlGadgetPtrWrapper::instance() to avoid this.
if (const QQmlValueType *valueType = QQmlMetaType::valueType(type))
- metaObject = valueType->metaObject();
+ metaObject = valueType->staticMetaObject();
else
return QVariant();
}
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp
index 7222b6cb93..46d8dbe14c 100644
--- a/src/qmlmodels/qqmldelegatemodel.cpp
+++ b/src/qmlmodels/qqmldelegatemodel.cpp
@@ -144,6 +144,9 @@ QQmlDelegateModelParts::QQmlDelegateModelParts(QQmlDelegateModel *parent)
provide delegates to multiple views, and with DelegateModelGroup to sort and filter
delegate items.
+ DelegateModel only supports one-dimensional models -- assigning a table model to
+ DelegateModel and that to TableView will thus only show one column.
+
The example below illustrates using a DelegateModel with a ListView.
\snippet delegatemodel/delegatemodel.qml 0
@@ -227,7 +230,7 @@ QQmlDelegateModel::~QQmlDelegateModel()
d->disconnectFromAbstractItemModel();
d->m_adaptorModel.setObject(nullptr);
- for (QQmlDelegateModelItem *cacheItem : qAsConst(d->m_cache)) {
+ for (QQmlDelegateModelItem *cacheItem : std::as_const(d->m_cache)) {
if (cacheItem->object) {
delete cacheItem->object;
@@ -412,7 +415,7 @@ void QQmlDelegateModel::setModel(const QVariant &model)
d->connectToAbstractItemModel();
d->m_adaptorModel.replaceWatchedRoles(QList<QByteArray>(), d->m_watchedRoles);
- for (int i = 0; d->m_parts && i < d->m_parts->models.count(); ++i) {
+ for (int i = 0; d->m_parts && i < d->m_parts->models.size(); ++i) {
d->m_adaptorModel.replaceWatchedRoles(
QList<QByteArray>(), d->m_parts->models.at(i)->watchedRoles());
}
@@ -656,7 +659,7 @@ void QQmlDelegateModel::cancel(int index)
Compositor::Cache, it.cacheIndex(), 1, Compositor::CacheFlag);
d->m_cache.removeAt(it.cacheIndex());
delete cacheItem;
- Q_ASSERT(d->m_cache.count() == d->m_compositor.count(Compositor::Cache));
+ Q_ASSERT(d->m_cache.size() == d->m_compositor.count(Compositor::Cache));
}
}
}
@@ -833,7 +836,7 @@ void QQmlDelegateModelPrivate::updateFilterGroup()
if (m_parts) {
auto partsCopy = m_parts->models; // deliberate; this may alter m_parts
- for (QQmlPartsModel *model : qAsConst(partsCopy))
+ for (QQmlPartsModel *model : std::as_const(partsCopy))
model->updateFilterGroup(m_compositorGroup, changeSet);
}
}
@@ -1083,7 +1086,7 @@ void QQmlDelegateModelPrivate::addCacheItem(QQmlDelegateModelItem *item, Composi
{
m_cache.insert(it.cacheIndex(), item);
m_compositor.setFlags(it, 1, Compositor::CacheFlag);
- Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
+ Q_ASSERT(m_cache.size() == m_compositor.count(Compositor::Cache));
}
void QQmlDelegateModelPrivate::removeCacheItem(QQmlDelegateModelItem *cacheItem)
@@ -1093,7 +1096,7 @@ void QQmlDelegateModelPrivate::removeCacheItem(QQmlDelegateModelItem *cacheItem)
m_compositor.clearFlags(Compositor::Cache, cidx, 1, Compositor::CacheFlag);
m_cache.removeAt(cidx);
}
- Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
+ Q_ASSERT(m_cache.size() == m_compositor.count(Compositor::Cache));
}
void QQmlDelegateModelPrivate::incubatorStatusChanged(QQDMIncubationTask *incubationTask, QQmlIncubator::Status status)
@@ -1489,7 +1492,7 @@ void QQmlDelegateModelPrivate::itemsInserted(
if (movedItems && insert.isMove()) {
QList<QQmlDelegateModelItem *> items = movedItems->take(insert.moveId);
- Q_ASSERT(items.count() == insert.count);
+ Q_ASSERT(items.size() == insert.count);
m_cache = m_cache.mid(0, insert.cacheIndex())
+ items + m_cache.mid(insert.cacheIndex());
}
@@ -1516,7 +1519,7 @@ void QQmlDelegateModelPrivate::itemsInserted(
cacheIndex = insert.cacheIndex() + insert.count;
}
}
- for (const QList<QQmlDelegateModelItem *> cache = m_cache; cacheIndex < cache.count(); ++cacheIndex)
+ for (const QList<QQmlDelegateModelItem *> cache = m_cache; cacheIndex < cache.size(); ++cacheIndex)
incrementIndexes(cache.at(cacheIndex), m_groupCount, inserted);
}
@@ -1524,7 +1527,7 @@ void QQmlDelegateModelPrivate::itemsInserted(const QVector<Compositor::Insert> &
{
QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> translatedInserts(m_groupCount);
itemsInserted(inserts, &translatedInserts);
- Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
+ Q_ASSERT(m_cache.size() == m_compositor.count(Compositor::Cache));
if (!m_delegate)
return;
@@ -1542,7 +1545,7 @@ void QQmlDelegateModel::_q_itemsInserted(int index, int count)
d->m_count += count;
const QList<QQmlDelegateModelItem *> cache = d->m_cache;
- for (int i = 0, c = cache.count(); i < c; ++i) {
+ for (int i = 0, c = cache.size(); i < c; ++i) {
QQmlDelegateModelItem *item = cache.at(i);
// layout change triggered by changing the modelIndex might have
// already invalidated this item in d->m_cache and deleted it.
@@ -1620,7 +1623,7 @@ void QQmlDelegateModelPrivate::itemsRemoved(
delete cacheItem;
--cacheIndex;
++removedCache;
- Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
+ Q_ASSERT(m_cache.size() == m_compositor.count(Compositor::Cache));
} else if (remove.groups() == cacheItem->groups) {
cacheItem->groups = 0;
if (QQDMIncubationTask *incubationTask = cacheItem->incubationTask) {
@@ -1664,7 +1667,7 @@ void QQmlDelegateModelPrivate::itemsRemoved(
}
}
- for (const QList<QQmlDelegateModelItem *> cache = m_cache; cacheIndex < cache.count(); ++cacheIndex)
+ for (const QList<QQmlDelegateModelItem *> cache = m_cache; cacheIndex < cache.size(); ++cacheIndex)
incrementIndexes(cache.at(cacheIndex), m_groupCount, removed);
}
@@ -1672,7 +1675,7 @@ void QQmlDelegateModelPrivate::itemsRemoved(const QVector<Compositor::Remove> &r
{
QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> translatedRemoves(m_groupCount);
itemsRemoved(removes, &translatedRemoves);
- Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
+ Q_ASSERT(m_cache.size() == m_compositor.count(Compositor::Cache));
if (!m_delegate)
return;
@@ -1693,7 +1696,7 @@ void QQmlDelegateModel::_q_itemsRemoved(int index, int count)
for (QQmlDelegateModelItem *item : cache)
item->referenceObject();
- for (int i = 0, c = cache.count(); i < c; ++i) {
+ for (int i = 0, c = cache.size(); i < c; ++i) {
QQmlDelegateModelItem *item = cache.at(i);
// layout change triggered by removal of a previous item might have
// already invalidated this item in d->m_cache and deleted it
@@ -1730,7 +1733,7 @@ void QQmlDelegateModelPrivate::itemsMoved(
QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> translatedInserts(m_groupCount);
itemsInserted(inserts, &translatedInserts, &movedItems);
- Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
+ Q_ASSERT(m_cache.size() == m_compositor.count(Compositor::Cache));
Q_ASSERT(movedItems.isEmpty());
if (!m_delegate)
return;
@@ -1753,7 +1756,7 @@ void QQmlDelegateModel::_q_itemsMoved(int from, int to, int count)
const int difference = from > to ? count : -count;
const QList<QQmlDelegateModelItem *> cache = d->m_cache;
- for (int i = 0, c = cache.count(); i < c; ++i) {
+ for (int i = 0, c = cache.size(); i < c; ++i) {
QQmlDelegateModelItem *item = cache.at(i);
// layout change triggered by changing the modelIndex might have
// already invalidated this item in d->m_cache and deleted it.
@@ -1831,7 +1834,7 @@ void QQmlDelegateModelPrivate::emitChanges()
QQmlDelegateModelGroupPrivate::get(m_groups[i])->emitModelUpdated(reset);
auto cacheCopy = m_cache; // deliberate; emitChanges may alter m_cache
- for (QQmlDelegateModelItem *cacheItem : qAsConst(cacheCopy)) {
+ for (QQmlDelegateModelItem *cacheItem : std::as_const(cacheCopy)) {
if (cacheItem->attached)
cacheItem->attached->emitChanges();
}
@@ -1853,7 +1856,7 @@ void QQmlDelegateModel::_q_modelReset()
for (QQmlDelegateModelItem *item : cache)
item->referenceObject();
- for (int i = 0, c = cache.count(); i < c; ++i) {
+ for (int i = 0, c = cache.size(); i < c; ++i) {
QQmlDelegateModelItem *item = cache.at(i);
// layout change triggered by changing the modelIndex might have
// already invalidated this item in d->m_cache and deleted it.
@@ -1974,7 +1977,7 @@ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelInd
bool QQmlDelegateModel::isDescendantOf(const QPersistentModelIndex& desc, const QList< QPersistentModelIndex >& parents) const
{
- for (int i = 0, c = parents.count(); i < c; ++i) {
+ for (int i = 0, c = parents.size(); i < c; ++i) {
for (QPersistentModelIndex parent = desc; parent.isValid(); parent = parent.parent()) {
if (parent == parents[i])
return true;
@@ -2058,7 +2061,7 @@ bool QQmlDelegateModelPrivate::insert(Compositor::insert_iterator &before, const
QQmlDelegateModelItemMetaType::QQmlDelegateModelItemMetaType(
QV4::ExecutionEngine *engine, QQmlDelegateModel *model, const QStringList &groupNames)
: model(model)
- , groupCount(groupNames.count() + 1)
+ , groupCount(groupNames.size() + 1)
, v4Engine(engine)
, metaObject(nullptr)
, groupNames(groupNames)
@@ -2079,7 +2082,7 @@ void QQmlDelegateModelItemMetaType::initializeMetaObject()
builder.setSuperClass(&QQmlDelegateModelAttached::staticMetaObject);
int notifierId = 0;
- for (int i = 0; i < groupNames.count(); ++i, ++notifierId) {
+ for (int i = 0; i < groupNames.size(); ++i, ++notifierId) {
QString propertyName = QLatin1String("in") + groupNames.at(i);
propertyName.replace(2, 1, propertyName.at(2).toUpper());
builder.addSignal("__" + propertyName.toUtf8() + "Changed()");
@@ -2087,7 +2090,7 @@ void QQmlDelegateModelItemMetaType::initializeMetaObject()
propertyName.toUtf8(), "bool", notifierId);
propertyBuilder.setWritable(true);
}
- for (int i = 0; i < groupNames.count(); ++i, ++notifierId) {
+ for (int i = 0; i < groupNames.size(); ++i, ++notifierId) {
const QString propertyName = groupNames.at(i) + QLatin1String("Index");
builder.addSignal("__" + propertyName.toUtf8() + "Changed()");
QMetaPropertyBuilder propertyBuilder = builder.addProperty(
@@ -2134,7 +2137,7 @@ void QQmlDelegateModelItemMetaType::initializePrototype()
p->setSetter(nullptr);
proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- for (int i = 2; i < groupNames.count(); ++i) {
+ for (int i = 2; i < groupNames.size(); ++i) {
QString propertyName = QLatin1String("in") + groupNames.at(i);
propertyName.replace(2, 1, propertyName.at(2).toUpper());
s = v4Engine->newString(propertyName);
@@ -2142,7 +2145,7 @@ void QQmlDelegateModelItemMetaType::initializePrototype()
p->setSetter((f = QV4::DelegateModelGroupFunction::create(global, i + 1, QQmlDelegateModelItem::set_member)));
proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
}
- for (int i = 2; i < groupNames.count(); ++i) {
+ for (int i = 2; i < groupNames.size(); ++i) {
const QString propertyName = groupNames.at(i) + QLatin1String("Index");
s = v4Engine->newString(propertyName);
p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, i + 1, QQmlDelegateModelItem::get_index)));
@@ -2447,7 +2450,7 @@ QQmlDelegateModelAttachedMetaObject::QQmlDelegateModelAttachedMetaObject(
: metaType(metaType)
, metaObject(metaObject)
, memberPropertyOffset(QQmlDelegateModelAttached::staticMetaObject.propertyCount())
- , indexPropertyOffset(QQmlDelegateModelAttached::staticMetaObject.propertyCount() + metaType->groupNames.count())
+ , indexPropertyOffset(QQmlDelegateModelAttached::staticMetaObject.propertyCount() + metaType->groupNames.size())
{
// Don't reference count the meta-type here as that would create a circular reference.
// Instead we rely the fact that the meta-type's reference count can't reach 0 without first
@@ -3237,7 +3240,7 @@ void QQmlDelegateModelGroup::resolve(QQmlV4Function *args)
Compositor::Cache, toIt.cacheIndex(), resolvedList,
resolvedIndex, 1, Compositor::CacheFlag);
- Q_ASSERT(model->m_cache.count() == model->m_compositor.count(Compositor::Cache));
+ Q_ASSERT(model->m_cache.size() == model->m_compositor.count(Compositor::Cache));
if (!cacheItem->isReferenced()) {
Q_ASSERT(toIt.cacheIndex() == model->m_cache.indexOf(cacheItem));
@@ -3245,7 +3248,7 @@ void QQmlDelegateModelGroup::resolve(QQmlV4Function *args)
model->m_compositor.clearFlags(
Compositor::Cache, toIt.cacheIndex(), 1, Compositor::CacheFlag);
delete cacheItem;
- Q_ASSERT(model->m_cache.count() == model->m_compositor.count(Compositor::Cache));
+ Q_ASSERT(model->m_cache.size() == model->m_compositor.count(Compositor::Cache));
} else {
cacheItem->resolveIndex(model->m_adaptorModel, resolvedIndex);
if (cacheItem->attached)
@@ -3901,7 +3904,7 @@ public:
return engine->memoryManager->allocate<QQmlDelegateModelGroupChangeArray>(changes);
}
- quint32 count() const { return d()->changes->count(); }
+ quint32 count() const { return d()->changes->size(); }
const QQmlChangeSet::Change &at(int index) const { return d()->changes->at(index); }
static QV4::ReturnedValue virtualGet(const QV4::Managed *m, QV4::PropertyKey id, const QV4::Value *receiver, bool *hasProperty)
diff --git a/src/qmlmodels/qqmlinstantiator.cpp b/src/qmlmodels/qqmlinstantiator.cpp
index 5b5ac7766e..fca56dd45a 100644
--- a/src/qmlmodels/qqmlinstantiator.cpp
+++ b/src/qmlmodels/qqmlinstantiator.cpp
@@ -39,10 +39,10 @@ void QQmlInstantiatorPrivate::clear()
Q_Q(QQmlInstantiator);
if (!instanceModel)
return;
- if (!objects.count())
+ if (!objects.size())
return;
- for (int i=0; i < objects.count(); i++) {
+ for (int i=0; i < objects.size(); i++) {
q->objectRemoved(i, objects[i]);
instanceModel->release(objects[i]);
}
@@ -103,7 +103,7 @@ void QQmlInstantiatorPrivate::_q_createdItem(int idx, QObject* item)
if (QObject *o = objects.at(idx))
instanceModel->release(o);
objects.replace(idx, item);
- if (objects.count() == 1)
+ if (objects.size() == 1)
q->objectChanged();
q->objectAdded(idx, item);
}
@@ -126,8 +126,8 @@ void QQmlInstantiatorPrivate::_q_modelUpdated(const QQmlChangeSet &changeSet, bo
QHash<int, QVector<QPointer<QObject> > > moved;
const QVector<QQmlChangeSet::Change> &removes = changeSet.removes();
for (const QQmlChangeSet::Change &remove : removes) {
- int index = qMin(remove.index, objects.count());
- int count = qMin(remove.index + remove.count, objects.count()) - index;
+ int index = qMin(remove.index, objects.size());
+ int count = qMin(remove.index + remove.count, objects.size()) - index;
if (remove.isMove()) {
moved.insert(remove.moveId, objects.mid(index, count));
objects.erase(
@@ -146,7 +146,7 @@ void QQmlInstantiatorPrivate::_q_modelUpdated(const QQmlChangeSet &changeSet, bo
const QVector<QQmlChangeSet::Change> &inserts = changeSet.inserts();
for (const QQmlChangeSet::Change &insert : inserts) {
- int index = qMin(insert.index, objects.count());
+ int index = qMin(insert.index, objects.size());
if (insert.isMove()) {
QVector<QPointer<QObject> > movedObjects = moved.value(insert.moveId);
objects = objects.mid(0, index) + movedObjects + objects.mid(index);
@@ -288,7 +288,7 @@ void QQmlInstantiator::setAsync(bool newVal)
int QQmlInstantiator::count() const
{
Q_D(const QQmlInstantiator);
- return d->objects.count();
+ return d->objects.size();
}
/*!
@@ -420,7 +420,7 @@ void QQmlInstantiator::setModel(const QVariant &v)
QObject *QQmlInstantiator::object() const
{
Q_D(const QQmlInstantiator);
- if (d->objects.count())
+ if (d->objects.size())
return d->objects[0];
return nullptr;
}
@@ -433,7 +433,7 @@ QObject *QQmlInstantiator::object() const
QObject *QQmlInstantiator::objectAt(int index) const
{
Q_D(const QQmlInstantiator);
- if (index >= 0 && index < d->objects.count())
+ if (index >= 0 && index < d->objects.size())
return d->objects[index];
return nullptr;
}
diff --git a/src/qmlmodels/qqmllistaccessor.cpp b/src/qmlmodels/qqmllistaccessor.cpp
index d68d0a2b90..0e57c3c4e9 100644
--- a/src/qmlmodels/qqmllistaccessor.cpp
+++ b/src/qmlmodels/qqmllistaccessor.cpp
@@ -94,16 +94,16 @@ qsizetype QQmlListAccessor::count() const
switch(m_type) {
case StringList:
Q_ASSERT(d.metaType() == QMetaType::fromType<QStringList>());
- return reinterpret_cast<const QStringList *>(d.constData())->count();
+ return reinterpret_cast<const QStringList *>(d.constData())->size();
case UrlList:
Q_ASSERT(d.metaType() == QMetaType::fromType<QList<QUrl>>());
- return reinterpret_cast<const QList<QUrl> *>(d.constData())->count();
+ return reinterpret_cast<const QList<QUrl> *>(d.constData())->size();
case VariantList:
Q_ASSERT(d.metaType() == QMetaType::fromType<QVariantList>());
- return reinterpret_cast<const QVariantList *>(d.constData())->count();
+ return reinterpret_cast<const QVariantList *>(d.constData())->size();
case ObjectList:
Q_ASSERT(d.metaType() == QMetaType::fromType<QList<QObject *>>());
- return reinterpret_cast<const QList<QObject *> *>(d.constData())->count();
+ return reinterpret_cast<const QList<QObject *> *>(d.constData())->size();
case ListProperty:
Q_ASSERT(d.metaType() == QMetaType::fromType<QQmlListReference>());
return reinterpret_cast<const QQmlListReference *>(d.constData())->count();
diff --git a/src/qmlmodels/qqmllistmodel.cpp b/src/qmlmodels/qqmllistmodel.cpp
index f02449e6c6..78a513fb02 100644
--- a/src/qmlmodels/qqmllistmodel.cpp
+++ b/src/qmlmodels/qqmllistmodel.cpp
@@ -98,7 +98,7 @@ const ListLayout::Role &ListLayout::createRole(const QString &key, ListLayout::R
sizeof(double),
sizeof(bool),
sizeof(ListModel *),
- sizeof(ListElement::GuardedQObjectPointer),
+ sizeof(QV4::PersistentValue),
sizeof(QVariantMap),
sizeof(QDateTime),
sizeof(QUrl),
@@ -109,7 +109,7 @@ const ListLayout::Role &ListLayout::createRole(const QString &key, ListLayout::R
alignof(double),
alignof(bool),
alignof(ListModel *),
- alignof(QObject *),
+ alignof(QV4::PersistentValue),
alignof(QVariantMap),
alignof(QDateTime),
alignof(QUrl),
@@ -140,7 +140,7 @@ const ListLayout::Role &ListLayout::createRole(const QString &key, ListLayout::R
currentBlockOffset = dataOffset + dataSize;
}
- int roleIndex = roles.count();
+ int roleIndex = roles.size();
r->index = roleIndex;
roles.append(r);
@@ -151,7 +151,7 @@ const ListLayout::Role &ListLayout::createRole(const QString &key, ListLayout::R
ListLayout::ListLayout(const ListLayout *other) : currentBlock(0), currentBlockOffset(0)
{
- const int otherRolesCount = other->roles.count();
+ const int otherRolesCount = other->roles.size();
roles.reserve(otherRolesCount);
for (int i=0 ; i < otherRolesCount; ++i) {
Role *role = new Role(other->roles[i]);
@@ -169,8 +169,8 @@ ListLayout::~ListLayout()
void ListLayout::sync(ListLayout *src, ListLayout *target)
{
- int roleOffset = target->roles.count();
- int newRoleCount = src->roles.count() - roleOffset;
+ int roleOffset = target->roles.size();
+ int newRoleCount = src->roles.size() - roleOffset;
for (int i=0 ; i < newRoleCount ; ++i) {
Role *role = new Role(src->roles[roleOffset + i]);
@@ -271,7 +271,7 @@ void StringOrTranslation::setString(const QString &s)
QString::DataPointer dataPointer = mutableString.data_ptr();
arrayData = dataPointer->d_ptr();
stringData = dataPointer->data();
- stringSize = mutableString.length();
+ stringSize = mutableString.size();
if (arrayData)
arrayData->ref();
}
@@ -618,10 +618,9 @@ void ListModel::set(int elementIndex, QV4::Object *object, QVector<int> *roles)
roleIndex = e->setFunctionProperty(r, jsv);
} else if (QV4::Object *o = propertyValue->as<QV4::Object>()) {
if (QV4::QObjectWrapper *wrapper = o->as<QV4::QObjectWrapper>()) {
- QObject *o = wrapper->object();
const ListLayout::Role &role = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject);
if (role.type == ListLayout::Role::QObject)
- roleIndex = e->setQObjectProperty(role, o);
+ roleIndex = e->setQObjectProperty(role, wrapper);
} else if (QVariant maybeUrl = o->engine()->toVariant(o->asReturnedValue(), QMetaType::fromType<QUrl>(), true);
maybeUrl.metaType() == QMetaType::fromType<QUrl>()) {
const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Url);
@@ -709,10 +708,9 @@ void ListModel::set(int elementIndex, QV4::Object *object, ListModel::SetElement
}
} else if (QV4::Object *o = propertyValue->as<QV4::Object>()) {
if (QV4::QObjectWrapper *wrapper = o->as<QV4::QObjectWrapper>()) {
- QObject *o = wrapper->object();
const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::QObject);
if (r.type == ListLayout::Role::QObject)
- e->setQObjectPropertyFast(r, o);
+ e->setQObjectPropertyFast(r, wrapper);
} else {
QVariant maybeUrl = o->engine()->toVariant(o->asReturnedValue(), QMetaType::fromType<QUrl>(), true);
if (maybeUrl.metaType() == QMetaType::fromType<QUrl>()) {
@@ -836,12 +834,11 @@ StringOrTranslation *ListElement::getStringProperty(const ListLayout::Role &role
return s;
}
-QObject *ListElement::getQObjectProperty(const ListLayout::Role &role)
+QV4::QObjectWrapper *ListElement::getQObjectProperty(const ListLayout::Role &role)
{
char *mem = getPropertyMemory(role);
- GuardedQObjectPointer *o
- = reinterpret_cast<GuardedQObjectPointer *>(mem);
- return o->data();
+ QV4::PersistentValue *g = reinterpret_cast<QV4::PersistentValue *>(mem);
+ return g->as<QV4::QObjectWrapper>();
}
QVariantMap *ListElement::getVariantMapProperty(const ListLayout::Role &role)
@@ -888,13 +885,13 @@ QJSValue *ListElement::getFunctionProperty(const ListLayout::Role &role)
return f;
}
-ListElement::GuardedQObjectPointer *
+QV4::PersistentValue *
ListElement::getGuardProperty(const ListLayout::Role &role)
{
char *mem = getPropertyMemory(role);
bool existingGuard = false;
- for (size_t i = 0; i < sizeof(GuardedQObjectPointer);
+ for (size_t i = 0; i < sizeof(QV4::PersistentValue);
++i) {
if (mem[i] != 0) {
existingGuard = true;
@@ -902,12 +899,12 @@ ListElement::getGuardProperty(const ListLayout::Role &role)
}
}
- GuardedQObjectPointer *o = nullptr;
+ QV4::PersistentValue *g = nullptr;
if (existingGuard)
- o = reinterpret_cast<GuardedQObjectPointer *>(mem);
+ g = reinterpret_cast<QV4::PersistentValue *>(mem);
- return o;
+ return g;
}
ListModel *ListElement::getListProperty(const ListLayout::Role &role)
@@ -963,12 +960,8 @@ QVariant ListElement::getProperty(const ListLayout::Role &role, const QQmlListMo
break;
case ListLayout::Role::QObject:
{
- GuardedQObjectPointer *guard =
- reinterpret_cast<GuardedQObjectPointer *>(
- mem);
- QObject *object = guard->data();
- if (object)
- data = QVariant::fromValue(object);
+ QV4::PersistentValue *guard = reinterpret_cast<QV4::PersistentValue *>(mem);
+ data = QVariant::fromValue(guard->as<QV4::QObjectWrapper>()->object());
}
break;
case ListLayout::Role::VariantMap:
@@ -1080,67 +1073,17 @@ int ListElement::setListProperty(const ListLayout::Role &role, ListModel *m)
return roleIndex;
}
-static void
-restoreQObjectOwnership(ListElement::GuardedQObjectPointer *pointer)
-{
- if (QObject *o = pointer->data()) {
- QQmlData *data = QQmlData::get(o, false);
- Q_ASSERT(data);
-
- // Only restore the previous state if the object hasn't become explicitly
- // owned
- if (!data->explicitIndestructibleSet)
- data->indestructible = (pointer->tag() & ListElement::Indestructible);
- }
-}
-
-static void setQObjectOwnership(char *mem, QObject *o)
-{
- QQmlData *ddata = QQmlData::get(o, false);
- const int ownership = (!ddata || ddata->indestructible ? ListElement::Indestructible : 0)
- | (ddata && ddata->explicitIndestructibleSet ? ListElement::ExplicitlySet : 0);
-
- // If ddata didn't exist above, force its creation now
- if (!ddata)
- ddata = QQmlData::get(o, true);
-
- if (!ddata->explicitIndestructibleSet)
- ddata->indestructible = ownership != 0;
-
- new (mem) ListElement::GuardedQObjectPointer(
- o, static_cast<ListElement::ObjectIndestructible>(ownership));
-}
-
-int ListElement::setQObjectProperty(const ListLayout::Role &role, QObject *o)
+int ListElement::setQObjectProperty(const ListLayout::Role &role, QV4::QObjectWrapper *o)
{
int roleIndex = -1;
if (role.type == ListLayout::Role::QObject) {
char *mem = getPropertyMemory(role);
- GuardedQObjectPointer *g =
- reinterpret_cast<GuardedQObjectPointer *>(mem);
- bool existingGuard = false;
- for (size_t i = 0; i < sizeof(GuardedQObjectPointer);
- ++i) {
- if (mem[i] != 0) {
- existingGuard = true;
- break;
- }
- }
- bool changed;
- if (existingGuard) {
- changed = g->data() != o;
- if (changed)
- restoreQObjectOwnership(g);
- g->~GuardedQObjectPointer();
- } else {
- changed = true;
- }
-
- setQObjectOwnership(mem, o);
-
- if (changed)
- roleIndex = role.index;
+ if (isMemoryUsed<QVariantMap>(mem))
+ reinterpret_cast<QV4::PersistentValue *>(mem)->set(o->engine(), *o);
+ else
+ new (mem) QV4::PersistentValue(o->engine(), o);
+ roleIndex = role.index;
}
return roleIndex;
@@ -1273,11 +1216,10 @@ void ListElement::setBoolPropertyFast(const ListLayout::Role &role, bool b)
*value = b;
}
-void ListElement::setQObjectPropertyFast(const ListLayout::Role &role, QObject *o)
+void ListElement::setQObjectPropertyFast(const ListLayout::Role &role, QV4::QObjectWrapper *o)
{
char *mem = getPropertyMemory(role);
-
- setQObjectOwnership(mem, o);
+ new (mem) QV4::PersistentValue(o->engine(), o);
}
void ListElement::setListPropertyFast(const ListLayout::Role &role, ListModel *m)
@@ -1394,7 +1336,7 @@ QVector<int> ListElement::sync(ListElement *src, ListLayout *srcLayout, ListElem
break;
case ListLayout::Role::QObject:
{
- QObject *object = src->getQObjectProperty(srcRole);
+ QV4::QObjectWrapper *object = src->getQObjectProperty(srcRole);
roleIndex = target->setQObjectProperty(targetRole, object);
}
break;
@@ -1449,14 +1391,8 @@ void ListElement::destroy(ListLayout *layout)
break;
case ListLayout::Role::QObject:
{
- GuardedQObjectPointer *guard =
- getGuardProperty(r);
-
- if (guard) {
- restoreQObjectOwnership(guard);
-
- guard->~GuardedQObjectPointer();
- }
+ if (QV4::PersistentValue *guard = getGuardProperty(r))
+ guard->~PersistentValue();
}
break;
case ListLayout::Role::VariantMap:
@@ -1593,8 +1529,7 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d
QV4::ScopedObject o(scope, d);
QV4::QObjectWrapper *wrapper = o->as<QV4::QObjectWrapper>();
if (role.type == ListLayout::Role::QObject && wrapper) {
- QObject *o = wrapper->object();
- roleIndex = setQObjectProperty(role, o);
+ roleIndex = setQObjectProperty(role, wrapper);
} else if (role.type == ListLayout::Role::VariantMap) {
roleIndex = setVariantMapProperty(role, o);
} else if (role.type == ListLayout::Role::Url) {
@@ -1671,10 +1606,10 @@ void ModelNodeMetaObject::updateValues()
void ModelNodeMetaObject::updateValues(const QVector<int> &roles)
{
if (!m_initialized) {
- emitDirectNotifies(roles.constData(), roles.count());
+ emitDirectNotifies(roles.constData(), roles.size());
return;
}
- int roleCount = roles.count();
+ int roleCount = roles.size();
for (int i=0 ; i < roleCount ; ++i) {
int roleIndex = roles.at(i);
const ListLayout::Role &role = m_model->m_listModel->getExistingRole(roleIndex);
@@ -1872,7 +1807,7 @@ void DynamicRoleModelNode::updateValues(const QVariantMap &object, QVector<int>
int roleIndex = m_owner->m_roles.indexOf(key);
if (roleIndex == -1) {
- roleIndex = m_owner->m_roles.count();
+ roleIndex = m_owner->m_roles.size();
m_owner->m_roles.append(key);
}
@@ -2172,7 +2107,7 @@ bool QQmlListModel::sync(QQmlListModel *src, QQmlListModel *target)
// Build hash of elements <-> uid for each of the lists
QHash<int, ElementSync> elementHash;
- for (int i = 0 ; i < target->m_modelObjects.count(); ++i) {
+ for (int i = 0 ; i < target->m_modelObjects.size(); ++i) {
DynamicRoleModelNode *e = target->m_modelObjects.at(i);
int uid = e->getUid();
ElementSync sync;
@@ -2180,7 +2115,7 @@ bool QQmlListModel::sync(QQmlListModel *src, QQmlListModel *target)
sync.targetIndex = i;
elementHash.insert(uid, sync);
}
- for (int i = 0 ; i < src->m_modelObjects.count(); ++i) {
+ for (int i = 0 ; i < src->m_modelObjects.size(); ++i) {
DynamicRoleModelNode *e = src->m_modelObjects.at(i);
int uid = e->getUid();
@@ -2199,7 +2134,7 @@ bool QQmlListModel::sync(QQmlListModel *src, QQmlListModel *target)
// Get list of elements that are in the target but no longer in the source. These get deleted first.
int rowsRemoved = 0;
- for (int i = 0 ; i < target->m_modelObjects.count() ; ++i) {
+ for (int i = 0 ; i < target->m_modelObjects.size() ; ++i) {
DynamicRoleModelNode *element = target->m_modelObjects.at(i);
ElementSync &s = elementHash.find(element->getUid()).value();
Q_ASSERT(s.targetIndex >= 0);
@@ -2220,7 +2155,7 @@ bool QQmlListModel::sync(QQmlListModel *src, QQmlListModel *target)
// Clear the target list, and append in correct order from the source
target->m_modelObjects.clear();
- for (int i = 0 ; i < src->m_modelObjects.count() ; ++i) {
+ for (int i = 0 ; i < src->m_modelObjects.size() ; ++i) {
DynamicRoleModelNode *element = src->m_modelObjects.at(i);
ElementSync &s = elementHash.find(element->getUid()).value();
Q_ASSERT(s.srcIndex >= 0);
@@ -2238,7 +2173,7 @@ bool QQmlListModel::sync(QQmlListModel *src, QQmlListModel *target)
// to ensure things are kept in the correct order, emit inserts and moves first. This shouls ensure all persistent
// model indices are updated correctly
int rowsInserted = 0;
- for (int i = 0 ; i < target->m_modelObjects.count() ; ++i) {
+ for (int i = 0 ; i < target->m_modelObjects.size() ; ++i) {
DynamicRoleModelNode *element = target->m_modelObjects.at(i);
ElementSync &s = elementHash.find(element->getUid()).value();
Q_ASSERT(s.srcIndex >= 0);
@@ -2357,7 +2292,7 @@ QHash<int, QByteArray> QQmlListModel::roleNames() const
QHash<int, QByteArray> roleNames;
if (m_dynamicRoles) {
- for (int i = 0 ; i < m_roles.count() ; ++i)
+ for (int i = 0 ; i < m_roles.size() ; ++i)
roleNames.insert(i, m_roles.at(i).toUtf8());
} else {
for (int i = 0 ; i < m_listModel->roleCount() ; ++i) {
@@ -2404,7 +2339,7 @@ void QQmlListModel::setDynamicRoles(bool enableDynamicRoles)
else
m_dynamicRoles = true;
} else {
- if (m_roles.count()) {
+ if (m_roles.size()) {
qmlWarning(this) << tr("unable to enable static roles as this model is not empty");
} else {
m_dynamicRoles = false;
@@ -2421,7 +2356,7 @@ void QQmlListModel::setDynamicRoles(bool enableDynamicRoles)
*/
int QQmlListModel::count() const
{
- return m_dynamicRoles ? m_modelObjects.count() : m_listModel->elementCount();
+ return m_dynamicRoles ? m_modelObjects.size() : m_listModel->elementCount();
}
/*!
@@ -2502,6 +2437,16 @@ void QQmlListModel::updateTranslations()
if (m_dynamicRoles)
return;
Q_ASSERT(m_listModel);
+
+ QList<int> roles;
+ for (int i = 0, end = m_listModel->roleCount(); i != end; ++i) {
+ if (m_listModel->getExistingRole(i).type == ListLayout::Role::String)
+ roles.append(i);
+ }
+
+ if (!roles.isEmpty())
+ emitItemsChanged(0, rowCount(QModelIndex()), roles);
+
m_listModel->updateTranslations();
}
@@ -2668,7 +2613,7 @@ void QQmlListModel::append(QQmlV4Function *args)
int index;
if (m_dynamicRoles) {
- index = m_modelObjects.count();
+ index = m_modelObjects.size();
emitItemsAboutToBeInserted(index, 1);
m_modelObjects.append(DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this));
} else {
@@ -2794,7 +2739,7 @@ void QQmlListModel::set(int index, const QJSValue &value)
m_listModel->set(index, object, &roles);
}
- if (roles.count())
+ if (roles.size())
emitItemsChanged(index, 1, roles);
}
}
@@ -2822,7 +2767,7 @@ void QQmlListModel::setProperty(int index, const QString& property, const QVaria
if (m_dynamicRoles) {
int roleIndex = m_roles.indexOf(property);
if (roleIndex == -1) {
- roleIndex = m_roles.count();
+ roleIndex = m_roles.size();
m_roles.append(property);
}
if (m_modelObjects[index]->setValue(property.toUtf8(), value))
@@ -2881,9 +2826,8 @@ bool QQmlListModelParser::verifyProperty(const QQmlRefPointer<QV4::ExecutableCom
} else if (binding->type() == QV4::CompiledData::Binding::Type_Script) {
QString scriptStr = compilationUnit->bindingValueAsScriptString(binding);
if (!binding->isFunctionExpression() && !definesEmptyList(scriptStr)) {
- QByteArray script = scriptStr.toUtf8();
bool ok;
- evaluateEnum(script, &ok);
+ evaluateEnum(scriptStr, &ok);
if (!ok) {
error(binding, QQmlListModel::tr("ListElement: cannot use script for property value"));
return false;
@@ -2966,9 +2910,8 @@ bool QQmlListModelParser::applyProperty(
QJSValuePrivate::setValue(&v, result->asReturnedValue());
value.setValue(v);
} else {
- QByteArray script = scriptStr.toUtf8();
bool ok;
- value = evaluateEnum(script, &ok);
+ value = evaluateEnum(scriptStr, &ok);
}
} else {
Q_UNREACHABLE();
@@ -3027,7 +2970,7 @@ void QQmlListModelParser::applyBindings(QObject *obj, const QQmlRefPointer<QV4::
bool QQmlListModelParser::definesEmptyList(const QString &s)
{
if (s.startsWith(QLatin1Char('[')) && s.endsWith(QLatin1Char(']'))) {
- for (int i=1; i<s.length()-1; i++) {
+ for (int i=1; i<s.size()-1; i++) {
if (!s[i].isSpace())
return false;
}
diff --git a/src/qmlmodels/qqmllistmodel_p_p.h b/src/qmlmodels/qqmllistmodel_p_p.h
index 0499c6a1a0..662a12f9e7 100644
--- a/src/qmlmodels/qqmllistmodel_p_p.h
+++ b/src/qmlmodels/qqmllistmodel_p_p.h
@@ -202,7 +202,7 @@ public:
const Role *getExistingRole(const QString &key) const;
const Role *getExistingRole(QV4::String *key) const;
- int roleCount() const { return roles.count(); }
+ int roleCount() const { return roles.size(); }
static void sync(ListLayout *src, ListLayout *target);
@@ -245,43 +245,6 @@ public:
enum ObjectIndestructible { Indestructible = 1, ExplicitlySet = 2 };
enum { BLOCK_SIZE = 64 - sizeof(int) - sizeof(ListElement *) - sizeof(ModelNodeMetaObject *) };
- // This is a basic guarded QObject pointer, with tag. It cannot be copied or moved.
- class GuardedQObjectPointer
- {
- Q_DISABLE_COPY_MOVE(GuardedQObjectPointer)
-
- using RefCountData = QtSharedPointer::ExternalRefCountData;
- using Storage = QTaggedPointer<QObject, ObjectIndestructible>;
-
- public:
- GuardedQObjectPointer(QObject *o, ObjectIndestructible ownership)
- : storage(o, ownership)
- , refCount(o ? RefCountData::getAndRef(o) : nullptr)
- {}
-
- ~GuardedQObjectPointer()
- {
- if (refCount && !refCount->weakref.deref())
- delete refCount;
- }
-
- QObject *data() const
- {
- return (refCount == nullptr || refCount->strongref.loadRelaxed() == 0)
- ? nullptr
- : storage.data();
- }
-
- ObjectIndestructible tag() const
- {
- return storage.tag();
- }
-
- private:
- Storage storage;
- RefCountData *refCount = nullptr;
- };
-
ListElement();
ListElement(int existingUid);
~ListElement();
@@ -300,7 +263,7 @@ private:
int setDoubleProperty(const ListLayout::Role &role, double n);
int setBoolProperty(const ListLayout::Role &role, bool b);
int setListProperty(const ListLayout::Role &role, ListModel *m);
- int setQObjectProperty(const ListLayout::Role &role, QObject *o);
+ int setQObjectProperty(const ListLayout::Role &role, QV4::QObjectWrapper *o);
int setVariantMapProperty(const ListLayout::Role &role, QV4::Object *o);
int setVariantMapProperty(const ListLayout::Role &role, QVariantMap *m);
int setDateTimeProperty(const ListLayout::Role &role, const QDateTime &dt);
@@ -311,7 +274,7 @@ private:
void setStringPropertyFast(const ListLayout::Role &role, const QString &s);
void setDoublePropertyFast(const ListLayout::Role &role, double n);
void setBoolPropertyFast(const ListLayout::Role &role, bool b);
- void setQObjectPropertyFast(const ListLayout::Role &role, QObject *o);
+ void setQObjectPropertyFast(const ListLayout::Role &role, QV4::QObjectWrapper *o);
void setListPropertyFast(const ListLayout::Role &role, ListModel *m);
void setVariantMapFast(const ListLayout::Role &role, QV4::Object *o);
void setDateTimePropertyFast(const ListLayout::Role &role, const QDateTime &dt);
@@ -323,8 +286,8 @@ private:
QVariant getProperty(const ListLayout::Role &role, const QQmlListModel *owner, QV4::ExecutionEngine *eng);
ListModel *getListProperty(const ListLayout::Role &role);
StringOrTranslation *getStringProperty(const ListLayout::Role &role);
- QObject *getQObjectProperty(const ListLayout::Role &role);
- GuardedQObjectPointer *getGuardProperty(const ListLayout::Role &role);
+ QV4::QObjectWrapper *getQObjectProperty(const ListLayout::Role &role);
+ QV4::PersistentValue *getGuardProperty(const ListLayout::Role &role);
QVariantMap *getVariantMapProperty(const ListLayout::Role &role);
QDateTime *getDateTimeProperty(const ListLayout::Role &role);
QUrl *getUrlProperty(const ListLayout::Role &role);
diff --git a/src/qmlmodels/qqmlobjectmodel.cpp b/src/qmlmodels/qqmlobjectmodel.cpp
index 118b2fab78..970a1e541f 100644
--- a/src/qmlmodels/qqmlobjectmodel.cpp
+++ b/src/qmlmodels/qqmlobjectmodel.cpp
@@ -39,12 +39,12 @@ public:
QQmlObjectModelPrivate() : QObjectPrivate(), moveId(0) {}
static void children_append(QQmlListProperty<QObject> *prop, QObject *item) {
- qsizetype index = static_cast<QQmlObjectModelPrivate *>(prop->data)->children.count();
+ qsizetype index = static_cast<QQmlObjectModelPrivate *>(prop->data)->children.size();
static_cast<QQmlObjectModelPrivate *>(prop->data)->insert(index, item);
}
static qsizetype children_count(QQmlListProperty<QObject> *prop) {
- return static_cast<QQmlObjectModelPrivate *>(prop->data)->children.count();
+ return static_cast<QQmlObjectModelPrivate *>(prop->data)->children.size();
}
static QObject *children_at(QQmlListProperty<QObject> *prop, qsizetype index) {
@@ -61,13 +61,13 @@ public:
static void children_removeLast(QQmlListProperty<QObject> *prop) {
auto data = static_cast<QQmlObjectModelPrivate *>(prop->data);
- data->remove(data->children.count() - 1, 1);
+ data->remove(data->children.size() - 1, 1);
}
void insert(int index, QObject *item) {
Q_Q(QQmlObjectModel);
children.insert(index, Item(item));
- for (int i = index; i < children.count(); ++i) {
+ for (int i = index; i < children.size(); ++i) {
QQmlObjectModelAttached *attached = QQmlObjectModelAttached::properties(children.at(i).item);
attached->setIndex(i);
}
@@ -126,7 +126,7 @@ public:
attached->setIndex(-1);
}
children.erase(children.begin() + index, children.begin() + index + n);
- for (int i = index; i < children.count(); ++i) {
+ for (int i = index; i < children.size(); ++i) {
QQmlObjectModelAttached *attached = QQmlObjectModelAttached::properties(children.at(i).item);
attached->setIndex(i);
}
@@ -142,11 +142,11 @@ public:
const auto copy = children;
for (const Item &child : copy)
emit q->destroyingItem(child.item);
- remove(0, children.count());
+ remove(0, children.size());
}
int indexOf(QObject *item) const {
- for (int i = 0; i < children.count(); ++i)
+ for (int i = 0; i < children.size(); ++i)
if (children.at(i).item == item)
return i;
return -1;
@@ -231,7 +231,7 @@ QQmlListProperty<QObject> QQmlObjectModel::children()
int QQmlObjectModel::count() const
{
Q_D(const QQmlObjectModel);
- return d->children.count();
+ return d->children.size();
}
bool QQmlObjectModel::isValid() const
@@ -265,7 +265,7 @@ QQmlInstanceModel::ReleaseFlags QQmlObjectModel::release(QObject *item, Reusable
QVariant QQmlObjectModel::variantValue(int index, const QString &role)
{
Q_D(QQmlObjectModel);
- if (index < 0 || index >= d->children.count())
+ if (index < 0 || index >= d->children.size())
return QString();
return d->children.at(index).item->property(role.toUtf8().constData());
}
@@ -308,7 +308,7 @@ QQmlObjectModelAttached *QQmlObjectModel::qmlAttachedProperties(QObject *obj)
QObject *QQmlObjectModel::get(int index) const
{
Q_D(const QQmlObjectModel);
- if (index < 0 || index >= d->children.count())
+ if (index < 0 || index >= d->children.size())
return nullptr;
return d->children.at(index).item;
}
diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp
index 39102c27c9..b6836be349 100644
--- a/src/qmlmodels/qqmltableinstancemodel.cpp
+++ b/src/qmlmodels/qqmltableinstancemodel.cpp
@@ -409,7 +409,7 @@ void QQmlTableInstanceModel::deleteIncubationTaskLater(QQmlIncubator *incubation
// delete them while we're in the middle of an incubation change callback.
Q_ASSERT(!m_finishedIncubationTasks.contains(incubationTask));
m_finishedIncubationTasks.append(incubationTask);
- if (m_finishedIncubationTasks.count() == 1)
+ if (m_finishedIncubationTasks.size() == 1)
QTimer::singleShot(1, this, &QQmlTableInstanceModel::deleteAllFinishedIncubationTasks);
}
diff --git a/src/qmlmodels/qqmltreemodeltotablemodel.cpp b/src/qmlmodels/qqmltreemodeltotablemodel.cpp
index 810ea2cde8..1fdcc1f95b 100644
--- a/src/qmlmodels/qqmltreemodeltotablemodel.cpp
+++ b/src/qmlmodels/qqmltreemodeltotablemodel.cpp
@@ -133,7 +133,7 @@ int QQmlTreeModelToTableModel::rowCount(const QModelIndex &) const
{
if (!m_model)
return 0;
- return m_items.count();
+ return m_items.size();
}
int QQmlTreeModelToTableModel::columnCount(const QModelIndex &parent) const
@@ -166,7 +166,7 @@ QVariant QQmlTreeModelToTableModel::headerData(int section, Qt::Orientation orie
int QQmlTreeModelToTableModel::depthAtRow(int row) const
{
- if (row < 0 || row >= m_items.count())
+ if (row < 0 || row >= m_items.size())
return 0;
return m_items.at(row).depth;
}
@@ -177,7 +177,7 @@ int QQmlTreeModelToTableModel::itemIndex(const QModelIndex &index) const
if (!index.isValid() || index == m_rootIndex || m_items.isEmpty())
return -1;
- const int totalCount = m_items.count();
+ const int totalCount = m_items.size();
// We start nearest to the lastViewedItem
int localCount = qMin(m_lastItemIndex - 1, totalCount - m_lastItemIndex);
@@ -232,7 +232,7 @@ QModelIndex QQmlTreeModelToTableModel::mapToModel(const QModelIndex &index) cons
return QModelIndex();
const int row = index.row();
- if (row < 0 || row > m_items.count() - 1)
+ if (row < 0 || row > m_items.size() - 1)
return QModelIndex();
const QModelIndex sourceIndex = m_items.at(row).index;
@@ -245,7 +245,7 @@ QModelIndex QQmlTreeModelToTableModel::mapFromModel(const QModelIndex &index) co
return QModelIndex();
int row = -1;
- for (int i = 0; i < m_items.count(); ++i) {
+ for (int i = 0; i < m_items.size(); ++i) {
const QModelIndex proxyIndex = m_items[i].index;
if (proxyIndex.row() == index.row() && proxyIndex.parent() == index.parent()) {
row = i;
@@ -261,7 +261,7 @@ QModelIndex QQmlTreeModelToTableModel::mapFromModel(const QModelIndex &index) co
QModelIndex QQmlTreeModelToTableModel::mapToModel(int row) const
{
- if (row < 0 || row >= m_items.count())
+ if (row < 0 || row >= m_items.size())
return QModelIndex();
return m_items.at(row).index;
}
@@ -314,8 +314,8 @@ QItemSelection QQmlTreeModelToTableModel::selectionForRowRange(const QModelInde
}
QItemSelection sel;
- sel.reserve(ranges.count());
- for (const MIPair &pair : qAsConst(ranges))
+ sel.reserve(ranges.size());
+ for (const MIPair &pair : std::as_const(ranges))
sel.append(QItemSelectionRange(pair.first, pair.second));
return sel;
@@ -368,7 +368,7 @@ void QQmlTreeModelToTableModel::showModelChildItems(const TreeItem &parentItem,
int rowDepth = rowIdx == 0 ? 0 : parentItem.depth + 1;
if (doInsertRows)
beginInsertRows(QModelIndex(), startIdx, startIdx + insertCount - 1);
- m_items.reserve(m_items.count() + insertCount);
+ m_items.reserve(m_items.size() + insertCount);
for (int i = 0; i < insertCount; i++) {
const QModelIndex &cmi = m_model->index(start + i, 0, parentIndex);
@@ -446,14 +446,14 @@ bool QQmlTreeModelToTableModel::isExpanded(const QModelIndex &index) const
bool QQmlTreeModelToTableModel::isExpanded(int row) const
{
- if (row < 0 || row >= m_items.count())
+ if (row < 0 || row >= m_items.size())
return false;
return m_items.at(row).expanded;
}
bool QQmlTreeModelToTableModel::hasChildren(int row) const
{
- if (row < 0 || row >= m_items.count())
+ if (row < 0 || row >= m_items.size())
return false;
return m_model->hasChildren(m_items[row].index);
}
@@ -591,7 +591,7 @@ int QQmlTreeModelToTableModel::lastChildIndex(const QModelIndex &index) const
parent = parent.parent();
}
- int firstIndex = nextSiblingIndex.isValid() ? itemIndex(nextSiblingIndex) : m_items.count();
+ int firstIndex = nextSiblingIndex.isValid() ? itemIndex(nextSiblingIndex) : m_items.size();
return firstIndex - 1;
}
@@ -607,7 +607,7 @@ void QQmlTreeModelToTableModel::removeVisibleRows(int startIndex, int endIndex,
endRemoveRows();
/* We need to update the model index for all the items below the removed ones */
- int lastIndex = m_items.count() - 1;
+ int lastIndex = m_items.size() - 1;
if (startIndex <= lastIndex) {
const QModelIndex &topLeft = index(startIndex, 0, QModelIndex());
const QModelIndex &bottomRight = index(lastIndex, 0, QModelIndex());
@@ -647,7 +647,7 @@ void QQmlTreeModelToTableModel::modelDataChanged(const QModelIndex &topLeft, con
for (int i = topLeft.row(); i <= bottomRight.row(); i++) {
// Group items with same parent to minize the number of 'dataChanged()' emits
int bottomIndex = topIndex;
- while (bottomIndex < m_items.count()) {
+ while (bottomIndex < m_items.size()) {
const QModelIndex &idx = m_items.at(bottomIndex).index;
if (idx.parent() != parent) {
--bottomIndex;
@@ -663,7 +663,7 @@ void QQmlTreeModelToTableModel::modelDataChanged(const QModelIndex &topLeft, con
if (i == bottomRight.row())
break;
topIndex = bottomIndex + 1;
- while (topIndex < m_items.count()
+ while (topIndex < m_items.size()
&& m_items.at(topIndex).index.parent() != parent)
topIndex++;
}
@@ -672,50 +672,87 @@ void QQmlTreeModelToTableModel::modelDataChanged(const QModelIndex &topLeft, con
void QQmlTreeModelToTableModel::modelLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint)
{
- ASSERT_CONSISTENCY();
- Q_UNUSED(parents)
Q_UNUSED(hint)
+
+ // Since the m_items is a list of TreeItems that contains QPersistentModelIndexes, we
+ // cannot wait until we get a modelLayoutChanged() before we remove the affected rows
+ // from that list. After the layout has changed, the list (or, the persistent indexes
+ // that it contains) is no longer in sync with the model (after all, that is what we're
+ // supposed to correct in modelLayoutChanged()).
+ // This means that vital functions, like itemIndex(index), cannot be trusted at that point.
+ // Therefore we need to do the update in two steps; First remove all the affected rows
+ // from here (while we're still in sync with the model), and then add back the
+ // affected rows, and notify about it, from modelLayoutChanged().
+ m_modelLayoutChanged = false;
+
+ if (parents.isEmpty() || !parents[0].isValid()) {
+ // Update entire model
+ emit layoutAboutToBeChanged();
+ m_modelLayoutChanged = true;
+ m_items.clear();
+ return;
+ }
+
+ for (const QPersistentModelIndex &pmi : parents) {
+ if (!m_expandedItems.contains(pmi))
+ continue;
+ const int row = itemIndex(pmi);
+ if (row == -1)
+ continue;
+ const int rowCount = m_model->rowCount(pmi);
+ if (rowCount == 0)
+ continue;
+
+ if (!m_modelLayoutChanged) {
+ emit layoutAboutToBeChanged();
+ m_modelLayoutChanged = true;
+ }
+
+ const QModelIndex &lmi = m_model->index(rowCount - 1, 0, pmi);
+ const int lastRow = lastChildIndex(lmi);
+ removeVisibleRows(row + 1, lastRow, false /*doRemoveRows*/);
+ }
+
+ ASSERT_CONSISTENCY();
}
void QQmlTreeModelToTableModel::modelLayoutChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint)
{
Q_UNUSED(hint)
- if (parents.isEmpty()) {
- emit layoutAboutToBeChanged();
- m_items.clear();
+ if (!m_modelLayoutChanged) {
+ // No relevant changes done from modelLayoutAboutToBeChanged()
+ return;
+ }
+
+ if (m_items.isEmpty()) {
+ // Entire model has changed. Add back all rows.
showModelTopLevelItems(false /*doInsertRows*/);
const QModelIndex &mi = m_model->index(0, 0);
const int columnCount = m_model->columnCount(mi);
- emit dataChanged(index(0, 0), index(m_items.count() - 1, columnCount - 1));
+ emit dataChanged(index(0, 0), index(m_items.size() - 1, columnCount - 1));
emit layoutChanged();
return;
}
- bool shouldEmitLayoutChanged = false;
for (const QPersistentModelIndex &pmi : parents) {
- if (m_expandedItems.contains(pmi)) {
- int row = itemIndex(pmi);
- if (row != -1) {
- if (!shouldEmitLayoutChanged) {
- shouldEmitLayoutChanged = true;
- emit layoutAboutToBeChanged();
- }
- int rowCount = m_model->rowCount(pmi);
- if (rowCount > 0) {
- const QModelIndex &lmi = m_model->index(rowCount - 1, 0, pmi);
- const int lastRow = lastChildIndex(lmi);
- const int columnCount = m_model->columnCount(lmi);
- removeVisibleRows(row + 1, lastRow, false /*doRemoveRows*/);
- showModelChildItems(m_items.at(row), 0, rowCount - 1, false /*doInsertRows*/);
- emit dataChanged(index(row + 1, 0), index(lastRow, columnCount - 1));
- }
- }
- }
+ if (!m_expandedItems.contains(pmi))
+ continue;
+ const int row = itemIndex(pmi);
+ if (row == -1)
+ continue;
+ const int rowCount = m_model->rowCount(pmi);
+ if (rowCount == 0)
+ continue;
+
+ const QModelIndex &lmi = m_model->index(rowCount - 1, 0, pmi);
+ const int columnCount = m_model->columnCount(lmi);
+ showModelChildItems(m_items.at(row), 0, rowCount - 1, false /*doInsertRows*/);
+ const int lastRow = lastChildIndex(lmi);
+ emit dataChanged(index(row + 1, 0), index(lastRow, columnCount - 1));
}
- if (shouldEmitLayoutChanged)
- emit layoutChanged();
+ emit layoutChanged();
ASSERT_CONSISTENCY();
}
@@ -864,7 +901,7 @@ void QQmlTreeModelToTableModel::modelRowsAboutToBeMoved(const QModelIndex & sour
}
bufferCopyOffset = destIndex;
}
- for (int i = 0; i < buffer.length(); i++) {
+ for (int i = 0; i < buffer.size(); i++) {
TreeItem item = buffer.at(i);
item.depth += depthDifference;
m_items.replace(bufferCopyOffset + i, item);
@@ -933,7 +970,7 @@ void QQmlTreeModelToTableModel::dump() const
{
if (!m_model)
return;
- int count = m_items.count();
+ int count = m_items.size();
if (count == 0)
return;
int countWidth = floor(log10(double(count))) + 1;
@@ -965,7 +1002,7 @@ bool QQmlTreeModelToTableModel::testConsistency(bool dumpOnFail) const
QModelIndex parent = m_rootIndex;
QStack<QModelIndex> ancestors;
QModelIndex idx = m_model->index(0, 0, parent);
- for (int i = 0; i < m_items.count(); i++) {
+ for (int i = 0; i < m_items.size(); i++) {
bool isConsistent = true;
const TreeItem &item = m_items.at(i);
if (item.index != idx) {
@@ -978,9 +1015,9 @@ bool QQmlTreeModelToTableModel::testConsistency(bool dumpOnFail) const
qWarning() << " stored index parent" << item.index.parent() << "model parent" << parent;
isConsistent = false;
}
- if (item.depth != ancestors.count()) {
+ if (item.depth != ancestors.size()) {
qWarning() << "Depth inconsistency" << i << item.index;
- qWarning() << " item depth" << item.depth << "ancestors stack" << ancestors.count();
+ qWarning() << " item depth" << item.depth << "ancestors stack" << ancestors.size();
isConsistent = false;
}
if (item.expanded && !m_expandedItems.contains(item.index)) {
@@ -1045,7 +1082,7 @@ void QQmlTreeModelToTableModel::emitQueuedSignals()
* We don't merge adjacent updates, because they are typically filed with a
* different role (a parent row is next to its children).
*/
- for (const DataChangedParams &dataChange : qAsConst(m_queuedDataChanged)) {
+ for (const DataChangedParams &dataChange : std::as_const(m_queuedDataChanged)) {
int startRow = dataChange.topLeft.row();
int endRow = dataChange.bottomRight.row();
bool merged = false;
diff --git a/src/qmlmodels/qqmltreemodeltotablemodel_p_p.h b/src/qmlmodels/qqmltreemodeltotablemodel_p_p.h
index dd5857e3a6..55ef45912a 100644
--- a/src/qmlmodels/qqmltreemodeltotablemodel_p_p.h
+++ b/src/qmlmodels/qqmltreemodeltotablemodel_p_p.h
@@ -165,6 +165,7 @@ private:
QList<TreeItem> m_itemsToExpand;
mutable int m_lastItemIndex = 0;
bool m_visibleRowsMoved = false;
+ bool m_modelLayoutChanged = false;
int m_signalAggregatorStack = 0;
QVector<DataChangedParams> m_queuedDataChanged;
int m_column = 0;
diff --git a/src/qmlmodels/qquickpackage.cpp b/src/qmlmodels/qquickpackage.cpp
index a7532a49df..70a3a6c19b 100644
--- a/src/qmlmodels/qquickpackage.cpp
+++ b/src/qmlmodels/qquickpackage.cpp
@@ -80,7 +80,7 @@ public:
}
static qsizetype data_count(QQmlListProperty<QObject> *prop) {
QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- return list->count();
+ return list->size();
}
static void data_replace(QQmlListProperty<QObject> *prop, qsizetype index, QObject *o) {
QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
@@ -135,7 +135,7 @@ QQmlListProperty<QObject> QQuickPackage::data()
bool QQuickPackage::hasPart(const QString &name)
{
Q_D(QQuickPackage);
- for (int ii = 0; ii < d->dataList.count(); ++ii) {
+ for (int ii = 0; ii < d->dataList.size(); ++ii) {
QObject *obj = d->dataList.at(ii);
QQuickPackageAttached *a = QQuickPackageAttached::attached.value(obj);
if (a && a->name() == name)
@@ -150,7 +150,7 @@ QObject *QQuickPackage::part(const QString &name)
if (name.isEmpty() && !d->dataList.isEmpty())
return d->dataList.at(0);
- for (int ii = 0; ii < d->dataList.count(); ++ii) {
+ for (int ii = 0; ii < d->dataList.size(); ++ii) {
QObject *obj = d->dataList.at(ii);
QQuickPackageAttached *a = QQuickPackageAttached::attached.value(obj);
if (a && a->name() == name)
diff --git a/src/qmltest/TestCase.qml b/src/qmltest/TestCase.qml
index b8937fc2e7..a69c2fe6f6 100644
--- a/src/qmltest/TestCase.qml
+++ b/src/qmltest/TestCase.qml
@@ -631,6 +631,9 @@ Item {
throw new Error("QtQuickTest::fail");
}
+ if (parent === undefined)
+ parent = null
+
var object = component.createObject(parent, properties ? properties : ({}));
qtest_temporaryObjects.push(object);
return object;
@@ -1146,23 +1149,36 @@ Item {
\qmlmethod TestCase::failOnWarning(message)
\since 6.3
- Fails the test if a warning \a message appears during the test run.
- Similar to \c{QTest::failOnWarning(message)} in C++.
+ Appends a test failure to the test log for each warning that matches
+ \a message. The test function will continue execution when a failure
+ is added.
\a message can be either a string, or a regular expression providing a
- pattern of messages. In the latter case, the first encountered message
- would fail the test.
+ pattern of messages. In the latter case, for each warning encountered,
+ the first pattern that matches will cause a failure, and the remaining
+ patterns will be ignored.
+
+ All patterns are cleared at the end of each test function.
- For example, the following snippet will fail a test if a warning is
- produced:
+ For example, the following snippet will fail a test if a warning with
+ the text "Something bad happened" is produced:
\qml
failOnWarning("Something bad happened")
\endqml
- And the following snippet will fail a test if any warning matching a
- pattern is encountered:
+ The following snippet will fail a test if any warning matching the
+ given pattern is encountered:
+ \qml
+ failOnWarning(/[0-9]+ bad things happened/)
+ \endqml
+
+ To fail every test that triggers a given warning, pass a suitable regular
+ expression to this function in \l init():
+
\qml
- failOnWarning(new RegExp("[0-9]+ bad things happened"))
+ function init() {
+ failOnWarning(/.?/)
+ }
\endqml
\note Despite being a JavaScript RegExp object, it will not be
@@ -1173,7 +1189,7 @@ Item {
warnings that match a pattern given to both \c ignoreMessage() and \c
failOnWarning() will be ignored.
- \sa warn()
+ \sa QTest::failOnWarning(), warn()
*/
function failOnWarning(msg) {
if (msg === undefined)
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index a048c43e76..9ecaa42f14 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -161,8 +161,8 @@ bool QQuickTest::qWaitForPolish(const QQuickWindow *window, int timeout)
static inline QString stripQuotes(const QString &s)
{
- if (s.length() >= 2 && s.startsWith(QLatin1Char('"')) && s.endsWith(QLatin1Char('"')))
- return s.mid(1, s.length() - 2);
+ if (s.size() >= 2 && s.startsWith(QLatin1Char('"')) && s.endsWith(QLatin1Char('"')))
+ return s.mid(1, s.size() - 2);
else
return s;
}
@@ -541,15 +541,15 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
// Scan through all of the "tst_*.qml" files and run each of them
// in turn with a separate QQuickView (for test isolation).
- for (const QString &file : qAsConst(files)) {
+ for (const QString &file : std::as_const(files)) {
const QFileInfo fi(file);
if (!fi.exists())
continue;
QQmlEngine engine;
- for (const QString &path : qAsConst(imports))
+ for (const QString &path : std::as_const(imports))
engine.addImportPath(path);
- for (const QString &path : qAsConst(pluginPaths))
+ for (const QString &path : std::as_const(pluginPaths))
engine.addPluginPath(path);
if (!fileSelectors.isEmpty()) {
@@ -654,9 +654,9 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
// Check that all test functions passed on the command line were found
if (!commandLineTestFunctions.isEmpty()) {
qWarning() << "Could not find the following test functions:";
- for (const QString &functionName : qAsConst(commandLineTestFunctions))
+ for (const QString &functionName : std::as_const(commandLineTestFunctions))
qWarning(" %s()", qUtf8Printable(functionName));
- return commandLineTestFunctions.count();
+ return commandLineTestFunctions.size();
}
// Return the number of failures as the exit code.
diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp
index 28d6c073fd..b1b8e60eab 100644
--- a/src/qmltest/quicktestevent.cpp
+++ b/src/qmltest/quicktestevent.cpp
@@ -57,7 +57,7 @@ bool QuickTestEvent::keyClick(int key, int modifiers, int delay)
bool QuickTestEvent::keyPressChar(const QString &character, int modifiers, int delay)
{
- QTEST_ASSERT(character.length() == 1);
+ QTEST_ASSERT(character.size() == 1);
QWindow *window = activeWindow();
if (!window)
return false;
@@ -67,7 +67,7 @@ bool QuickTestEvent::keyPressChar(const QString &character, int modifiers, int d
bool QuickTestEvent::keyReleaseChar(const QString &character, int modifiers, int delay)
{
- QTEST_ASSERT(character.length() == 1);
+ QTEST_ASSERT(character.size() == 1);
QWindow *window = activeWindow();
if (!window)
return false;
@@ -77,7 +77,7 @@ bool QuickTestEvent::keyReleaseChar(const QString &character, int modifiers, int
bool QuickTestEvent::keyClickChar(const QString &character, int modifiers, int delay)
{
- QTEST_ASSERT(character.length() == 1);
+ QTEST_ASSERT(character.size() == 1);
QWindow *window = activeWindow();
if (!window)
return false;
diff --git a/src/qmltyperegistrar/metatypesjsonprocessor.cpp b/src/qmltyperegistrar/metatypesjsonprocessor.cpp
index 49088400b4..d167b75afd 100644
--- a/src/qmltyperegistrar/metatypesjsonprocessor.cpp
+++ b/src/qmltyperegistrar/metatypesjsonprocessor.cpp
@@ -326,6 +326,7 @@ void MetaTypesJsonProcessor::processTypes(const QJsonObject &types)
if (!include.endsWith(QLatin1String(".h"))
&& !include.endsWith(QLatin1String(".hpp"))
&& !include.endsWith(QLatin1String(".hxx"))
+ && !include.endsWith(QLatin1String(".hh"))
&& !include.endsWith(u".py")
&& include.contains(QLatin1Char('.'))) {
fprintf(stderr,
diff --git a/src/qmlworkerscript/qv4serialize.cpp b/src/qmlworkerscript/qv4serialize.cpp
index 1906d164f6..d445299828 100644
--- a/src/qmlworkerscript/qv4serialize.cpp
+++ b/src/qmlworkerscript/qv4serialize.cpp
@@ -106,7 +106,7 @@ static inline void *popPtr(const char *&data)
#define ALIGN(size) (((size) + 3) & ~3)
static inline void serializeString(QByteArray &data, const QString &str, Type type)
{
- int length = str.length();
+ int length = str.size();
if (length > 0xFFFFFF) {
push(data, valueheader(WorkerUndefined));
return;
@@ -174,7 +174,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
} else if (const RegExpObject *re = v.as<RegExpObject>()) {
quint32 flags = re->flags();
QString pattern = re->source();
- int length = pattern.length() + 1;
+ int length = pattern.size() + 1;
if (length > 0xFFFFFF) {
push(data, valueheader(WorkerUndefined));
return;
diff --git a/src/qmlxmllistmodel/qqmlxmllistmodel.cpp b/src/qmlxmllistmodel/qqmlxmllistmodel.cpp
index 72c3b21e87..2f40bd525b 100644
--- a/src/qmlxmllistmodel/qqmlxmllistmodel.cpp
+++ b/src/qmlxmllistmodel/qqmlxmllistmodel.cpp
@@ -363,7 +363,7 @@ QVariant QQmlXmlListModel::data(const QModelIndex &index, int role) const
QHash<int, QByteArray> QQmlXmlListModel::roleNames() const
{
QHash<int, QByteArray> roleNames;
- for (int i = 0; i < m_roles.count(); ++i)
+ for (int i = 0; i < m_roles.size(); ++i)
roleNames.insert(m_roles.at(i), m_roleNames.at(i).toUtf8());
return roleNames;
}
@@ -437,7 +437,7 @@ QQmlListProperty<QQmlXmlListModelRole> QQmlXmlListModel::roleObjects()
void QQmlXmlListModel::appendRole(QQmlXmlListModelRole *role)
{
if (role) {
- int i = m_roleObjects.count();
+ int i = m_roleObjects.size();
m_roleObjects.append(role);
if (m_roleNames.contains(role->name())) {
qmlWarning(role)
@@ -519,7 +519,7 @@ QQmlXmlListModelQueryJob QQmlXmlListModel::createJob(const QByteArray &data)
job.data = data;
job.query = m_query;
- for (int i = 0; i < m_roleObjects.count(); i++) {
+ for (int i = 0; i < m_roleObjects.size(); i++) {
if (!m_roleObjects.at(i)->isValid()) {
job.roleNames << QString();
job.elementNames << QString();
@@ -744,7 +744,7 @@ void QQmlXmlListModel::dataCleared()
void QQmlXmlListModel::queryError(void *object, const QString &error)
{
- for (int i = 0; i < m_roleObjects.count(); i++) {
+ for (int i = 0; i < m_roleObjects.size(); i++) {
if (m_roleObjects.at(i) == static_cast<QQmlXmlListModelRole *>(object)) {
qmlWarning(m_roleObjects.at(i))
<< QQmlXmlListModel::tr("Query error: \"%1\"").arg(error);
@@ -760,7 +760,7 @@ void QQmlXmlListModel::queryCompleted(const QQmlXmlListModelQueryResult &result)
return;
int origCount = m_size;
- bool sizeChanged = result.data.count() != m_size;
+ bool sizeChanged = result.data.size() != m_size;
if (m_source.isEmpty())
m_status = Null;
@@ -773,7 +773,7 @@ void QQmlXmlListModel::queryCompleted(const QQmlXmlListModelQueryResult &result)
beginRemoveRows(QModelIndex(), 0, origCount - 1);
endRemoveRows();
}
- m_size = result.data.count();
+ m_size = result.data.size();
m_data = result.data;
if (m_size > 0) {
@@ -841,10 +841,10 @@ void QQmlXmlListModelQueryRunnable::doQueryJob(QQmlXmlListModelQueryResult *curr
while (!reader.atEnd() && !m_promise.isCanceled()) {
int i = 0;
- while (i < items.count()) {
+ while (i < items.size()) {
if (reader.readNextStartElement()) {
if (reader.name() == items.at(i)) {
- if (i != items.count() - 1) {
+ if (i != items.size() - 1) {
i++;
continue;
} else {
diff --git a/src/quick/accessible/qaccessiblequickitem.cpp b/src/quick/accessible/qaccessiblequickitem.cpp
index e891b5c132..c47a94e3aa 100644
--- a/src/quick/accessible/qaccessiblequickitem.cpp
+++ b/src/quick/accessible/qaccessiblequickitem.cpp
@@ -46,7 +46,7 @@ public:
QString anchor() const override
{
const QVector<QQuickTextPrivate::LinkDesc> links = QQuickTextPrivate::get(textItem())->getLinks();
- if (linkIndex < links.count())
+ if (linkIndex < links.size())
return links.at(linkIndex).m_anchor;
return QString();
}
@@ -54,7 +54,7 @@ public:
QString anchorTarget() const override
{
const QVector<QQuickTextPrivate::LinkDesc> links = QQuickTextPrivate::get(textItem())->getLinks();
- if (linkIndex < links.count())
+ if (linkIndex < links.size())
return links.at(linkIndex).m_anchorTarget;
return QString();
}
@@ -62,7 +62,7 @@ public:
int startIndex() const override
{
const QVector<QQuickTextPrivate::LinkDesc> links = QQuickTextPrivate::get(textItem())->getLinks();
- if (linkIndex < links.count())
+ if (linkIndex < links.size())
return links.at(linkIndex).m_startIndex;
return -1;
}
@@ -70,7 +70,7 @@ public:
int endIndex() const override
{
const QVector<QQuickTextPrivate::LinkDesc> links = QQuickTextPrivate::get(textItem())->getLinks();
- if (linkIndex < links.count())
+ if (linkIndex < links.size())
return links.at(linkIndex).m_endIndex;
return -1;
}
@@ -113,7 +113,7 @@ QWindow *QAccessibleHyperlink::window() const
QRect QAccessibleHyperlink::rect() const
{
const QVector<QQuickTextPrivate::LinkDesc> links = QQuickTextPrivate::get(textItem())->getLinks();
- if (linkIndex < links.count()) {
+ if (linkIndex < links.size()) {
const QPoint tl = itemScreenRect(textItem()).topLeft();
return links.at(linkIndex).rect.translated(tl);
}
@@ -232,9 +232,9 @@ int QAccessibleQuickItem::childCount() const
// see comment in QAccessibleQuickItem::child() as to why we do this
int cc = 0;
if (QQuickText *textItem = qobject_cast<QQuickText*>(item())) {
- cc = QQuickTextPrivate::get(textItem)->getLinks().count();
+ cc = QQuickTextPrivate::get(textItem)->getLinks().size();
}
- cc += childItems().count();
+ cc += childItems().size();
return cc;
}
@@ -271,7 +271,7 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
// special case for text interfaces
if (QQuickText *textItem = qobject_cast<QQuickText*>(item())) {
- const auto hyperLinkChildCount = QQuickTextPrivate::get(textItem)->getLinks().count();
+ const auto hyperLinkChildCount = QQuickTextPrivate::get(textItem)->getLinks().size();
for (auto i = 0; i < hyperLinkChildCount; i++) {
QAccessibleInterface *iface = child(i);
if (iface->rect().contains(x,y)) {
@@ -282,7 +282,7 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
// general item hit test
const QList<QQuickItem*> kids = accessibleUnignoredChildren(item(), true);
- for (int i = kids.count() - 1; i >= 0; --i) {
+ for (int i = kids.size() - 1; i >= 0; --i) {
QAccessibleInterface *childIface = QAccessible::queryAccessibleInterface(kids.at(i));
if (QAccessibleInterface *childChild = childIface->childAt(x, y))
return childChild;
@@ -344,7 +344,7 @@ QAccessibleInterface *QAccessibleQuickItem::child(int index) const
if (QQuickText *textItem = qobject_cast<QQuickText*>(item())) {
- const int hyperLinkChildCount = QQuickTextPrivate::get(textItem)->getLinks().count();
+ const int hyperLinkChildCount = QQuickTextPrivate::get(textItem)->getLinks().size();
if (index < hyperLinkChildCount) {
auto it = m_childToId.constFind(index);
if (it != m_childToId.constEnd())
@@ -359,7 +359,7 @@ QAccessibleInterface *QAccessibleQuickItem::child(int index) const
}
QList<QQuickItem *> children = childItems();
- if (index < children.count()) {
+ if (index < children.size()) {
QQuickItem *child = children.at(index);
return QAccessible::queryAccessibleInterface(child);
}
@@ -370,7 +370,7 @@ int QAccessibleQuickItem::indexOfChild(const QAccessibleInterface *iface) const
{
int hyperLinkChildCount = 0;
if (QQuickText *textItem = qobject_cast<QQuickText*>(item())) {
- hyperLinkChildCount = QQuickTextPrivate::get(textItem)->getLinks().count();
+ hyperLinkChildCount = QQuickTextPrivate::get(textItem)->getLinks().size();
if (QAccessibleHyperlinkInterface *hyperLinkIface = const_cast<QAccessibleInterface *>(iface)->hyperlinkInterface()) {
// ### assumes that there is only one subclass implementing QAccessibleHyperlinkInterface
// Alternatively, we could simply iterate with child() and do a linear search for it
diff --git a/src/quick/accessible/qaccessiblequickview.cpp b/src/quick/accessible/qaccessiblequickview.cpp
index 3f327619c8..5cd93b9613 100644
--- a/src/quick/accessible/qaccessiblequickview.cpp
+++ b/src/quick/accessible/qaccessiblequickview.cpp
@@ -28,7 +28,7 @@ QList<QQuickItem *> QAccessibleQuickWindow::rootItems() const
int QAccessibleQuickWindow::childCount() const
{
- return rootItems().count();
+ return rootItems().size();
}
QAccessibleInterface *QAccessibleQuickWindow::parent() const
@@ -40,7 +40,7 @@ QAccessibleInterface *QAccessibleQuickWindow::parent() const
QAccessibleInterface *QAccessibleQuickWindow::child(int index) const
{
const QList<QQuickItem*> &kids = rootItems();
- if (index >= 0 && index < kids.count())
+ if (index >= 0 && index < kids.size())
return QAccessible::queryAccessibleInterface(kids.at(index));
return nullptr;
}
@@ -109,7 +109,7 @@ int QAccessibleQuickWindow::indexOfChild(const QAccessibleInterface *iface) cons
int i = -1;
if (iface) {
const QList<QQuickItem *> &roots = rootItems();
- i = roots.count() - 1;
+ i = roots.size() - 1;
while (i >= 0) {
if (iface->object() == roots.at(i))
break;
diff --git a/src/quick/designer/qqmldesignermetaobject.cpp b/src/quick/designer/qqmldesignermetaobject.cpp
index 4bd221481b..e368f5f443 100644
--- a/src/quick/designer/qqmldesignermetaobject.cpp
+++ b/src/quick/designer/qqmldesignermetaobject.cpp
@@ -17,7 +17,7 @@ static void (*notifyPropertyChangeCallBack)(QObject*, const QQuickDesignerSuppor
struct MetaPropertyData {
inline QPair<QVariant, bool> &getDataRef(int idx) {
- while (m_data.count() <= idx)
+ while (m_data.size() <= idx)
m_data << QPair<QVariant, bool>(QVariant(), false);
return m_data[idx];
}
@@ -32,12 +32,12 @@ struct MetaPropertyData {
}
inline bool hasData(int idx) const {
- if (idx >= m_data.count())
+ if (idx >= m_data.size())
return false;
return m_data[idx].second;
}
- inline int count() { return m_data.count(); }
+ inline int count() { return m_data.size(); }
QVector<QPair<QVariant, bool> > m_data;
};
diff --git a/src/quick/designer/qquickdesignersupportitems.cpp b/src/quick/designer/qquickdesignersupportitems.cpp
index 2ee8984ea1..5887ff951f 100644
--- a/src/quick/designer/qquickdesignersupportitems.cpp
+++ b/src/quick/designer/qquickdesignersupportitems.cpp
@@ -118,7 +118,7 @@ void QQuickDesignerSupportItems::tweakObjects(QObject *object)
{
QObjectList objectList;
allSubObjects(object, objectList);
- for (QObject* childObject : qAsConst(objectList)) {
+ for (QObject* childObject : std::as_const(objectList)) {
stopAnimation(childObject);
makeLoaderSynchronous(childObject);
if (fixResourcePathsForObjectCallBack)
diff --git a/src/quick/doc/images/pointerHandlers/dragReleaseMenu.webp b/src/quick/doc/images/pointerHandlers/dragReleaseMenu.webp
new file mode 100644
index 0000000000..16aaca4d86
--- /dev/null
+++ b/src/quick/doc/images/pointerHandlers/dragReleaseMenu.webp
Binary files differ
diff --git a/src/quick/doc/images/pointerHandlers/tapHandlerButtonReleaseWithinBounds.webp b/src/quick/doc/images/pointerHandlers/tapHandlerButtonReleaseWithinBounds.webp
new file mode 100644
index 0000000000..3edab7d7a1
--- /dev/null
+++ b/src/quick/doc/images/pointerHandlers/tapHandlerButtonReleaseWithinBounds.webp
Binary files differ
diff --git a/src/quick/doc/images/pointerHandlers/tapHandlerButtonWithinBounds.webp b/src/quick/doc/images/pointerHandlers/tapHandlerButtonWithinBounds.webp
new file mode 100644
index 0000000000..05cb2f2276
--- /dev/null
+++ b/src/quick/doc/images/pointerHandlers/tapHandlerButtonWithinBounds.webp
Binary files differ
diff --git a/src/quick/doc/images/pointerHandlers/tapHandlerOverlappingButtons.webp b/src/quick/doc/images/pointerHandlers/tapHandlerOverlappingButtons.webp
new file mode 100644
index 0000000000..0455097159
--- /dev/null
+++ b/src/quick/doc/images/pointerHandlers/tapHandlerOverlappingButtons.webp
Binary files differ
diff --git a/src/quick/doc/snippets/pointerHandlers/dragReleaseMenu.qml b/src/quick/doc/snippets/pointerHandlers/dragReleaseMenu.qml
new file mode 100644
index 0000000000..e6d2266408
--- /dev/null
+++ b/src/quick/doc/snippets/pointerHandlers/dragReleaseMenu.qml
@@ -0,0 +1,72 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+//![0]
+import QtQuick
+
+Rectangle {
+ id: rect
+ width: 140; height: 100
+
+ //![1]
+ TapHandler {
+ id: menuPopupHandler
+ gesturePolicy: TapHandler.DragWithinBounds
+ onPressedChanged:
+ if (pressed) {
+ menu.x = point.position.x - menu.width / 2
+ menu.y = point.position.y - menu.height / 2
+ } else {
+ feedback.text = menu.highlightedMenuItem
+ selectFlash.start()
+ }
+ onCanceled: feedback.text = "canceled"
+ }
+ //![1]
+
+ Column {
+ id: menu
+ visible: menuPopupHandler.pressed
+ opacity: Math.min(1, menuPopupHandler.timeHeld)
+ property string highlightedMenuItem: ""
+ Repeater {
+ model: [ "top", "middle", "bottom" ]
+ delegate: Rectangle {
+ property bool highlighted: menuPopupHandler.pressed &&
+ contains(mapFromItem(rect, menuPopupHandler.point.position))
+ onHighlightedChanged: {
+ if (highlighted)
+ menu.highlightedMenuItem = menuItemText.text
+ else if (menu.highlightedMenuItem === menuItemText.text)
+ menu.highlightedMenuItem = ""
+ }
+ width: 100
+ height: 20
+ color: highlighted ? "lightsteelblue" : "aliceblue"
+ Text {
+ id: menuItemText
+ anchors.centerIn: parent
+ text: modelData
+ }
+ }
+ }
+ }
+
+ Text {
+ id: feedback
+ y: 6; anchors.horizontalCenter: parent.horizontalCenter
+ textFormat: Text.MarkdownText
+ text: "hold for context menu"
+
+ SequentialAnimation on font.weight {
+ id: selectFlash
+ running: false
+ loops: 3
+ PropertyAction { value: Font.Black }
+ PauseAnimation { duration: 100 }
+ PropertyAction { value: Font.Normal }
+ PauseAnimation { duration: 100 }
+ }
+ }
+}
+//![0]
diff --git a/src/quick/doc/snippets/pointerHandlers/pointHandler.qml b/src/quick/doc/snippets/pointerHandlers/pointHandler.qml
index f5fe29566e..d363150ab5 100644
--- a/src/quick/doc/snippets/pointerHandlers/pointHandler.qml
+++ b/src/quick/doc/snippets/pointerHandlers/pointHandler.qml
@@ -1,8 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
-import QtQuick 2.12
-import QtQuick.Window 2.2
+import QtQuick
Window {
width: 480
@@ -14,6 +13,7 @@ Window {
z: 10000
anchors.fill: parent
+ //![1]
PointHandler {
id: handler
acceptedDevices: PointerDevice.TouchScreen | PointerDevice.TouchPad
@@ -26,6 +26,7 @@ Window {
width: 20; height: width; radius: width / 2
}
}
+ //![1]
}
}
//![0]
diff --git a/src/quick/doc/snippets/pointerHandlers/pointHandlerAcceptedButtons.qml b/src/quick/doc/snippets/pointerHandlers/pointHandlerAcceptedButtons.qml
new file mode 100644
index 0000000000..3eab8b319b
--- /dev/null
+++ b/src/quick/doc/snippets/pointerHandlers/pointHandlerAcceptedButtons.qml
@@ -0,0 +1,21 @@
+// Copyright (C) 2023 Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+//![0]
+import QtQuick
+
+Item {
+ width: 480; height: 320
+
+ Rectangle {
+ color: handler.active ? "tomato" : "wheat"
+ x: handler.point.position.x - width / 2
+ y: handler.point.position.y - height / 2
+ width: 20; height: width; radius: width / 2
+ }
+
+ PointHandler {
+ id: handler
+ acceptedButtons: Qt.MiddleButton | Qt.RightButton
+ }
+}
+//![0]
diff --git a/src/quick/doc/snippets/pointerHandlers/pointHandlerAcceptedModifiers.qml b/src/quick/doc/snippets/pointerHandlers/pointHandlerAcceptedModifiers.qml
new file mode 100644
index 0000000000..9e3cb6f465
--- /dev/null
+++ b/src/quick/doc/snippets/pointerHandlers/pointHandlerAcceptedModifiers.qml
@@ -0,0 +1,36 @@
+// Copyright (C) 2023 Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+//![0]
+import QtQuick
+
+Item {
+ id: feedbackPane
+ width: 480; height: 320
+
+ PointHandler {
+ id: control
+ acceptedModifiers: Qt.ControlModifier
+ cursorShape: Qt.PointingHandCursor
+ target: Rectangle {
+ parent: feedbackPane
+ color: control.active ? "indianred" : "khaki"
+ x: control.point.position.x - width / 2
+ y: control.point.position.y - height / 2
+ width: 20; height: width; radius: width / 2
+ }
+ }
+
+ PointHandler {
+ id: shift
+ acceptedModifiers: Qt.ShiftModifier | Qt.MetaModifier
+ cursorShape: Qt.CrossCursor
+ target: Rectangle {
+ parent: feedbackPane
+ color: shift.active ? "darkslateblue" : "lightseagreen"
+ x: shift.point.position.x - width / 2
+ y: shift.point.position.y - height / 2
+ width: 30; height: width; radius: width / 2
+ }
+ }
+}
+//![0]
diff --git a/src/quick/doc/snippets/pointerHandlers/pointHandlerCanvasDrawing.qml b/src/quick/doc/snippets/pointerHandlers/pointHandlerCanvasDrawing.qml
new file mode 100644
index 0000000000..d04bd4f149
--- /dev/null
+++ b/src/quick/doc/snippets/pointerHandlers/pointHandlerCanvasDrawing.qml
@@ -0,0 +1,54 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+//![0]
+import QtQuick
+
+Canvas {
+ id: canvas
+ width: 800
+ height: 600
+ antialiasing: true
+ renderTarget: Canvas.FramebufferObject
+ property var points: []
+ onPaint: {
+ if (points.length < 2)
+ return
+ var ctx = canvas.getContext('2d');
+ ctx.save()
+ ctx.strokeStyle = stylusHandler.active ? "blue" : "white"
+ ctx.lineCap = "round"
+ ctx.beginPath()
+ ctx.moveTo(points[0].x, points[0].y)
+ for (var i = 1; i < points.length; i++)
+ ctx.lineTo(points[i].x, points[i].y)
+ ctx.lineWidth = 3
+ ctx.stroke()
+ points = points.slice(points.length - 2, 1)
+ ctx.restore()
+ }
+
+ PointHandler {
+ id: stylusHandler
+ acceptedPointerTypes: PointerDevice.Pen
+ onPointChanged: {
+ canvas.points.push(point.position)
+ canvas.requestPaint()
+ }
+ }
+
+ PointHandler {
+ id: eraserHandler
+ acceptedPointerTypes: PointerDevice.Eraser
+ onPointChanged: {
+ canvas.points.push(point.position)
+ canvas.requestPaint()
+ }
+ }
+
+ Rectangle {
+ width: 10; height: 10
+ color: stylusHandler.active ? "green" : eraserHandler.active ? "red" : "beige"
+ }
+}
+//![0]
diff --git a/src/quick/doc/snippets/pointerHandlers/pointHandlerMargin.qml b/src/quick/doc/snippets/pointerHandlers/pointHandlerMargin.qml
new file mode 100644
index 0000000000..1b66531dbf
--- /dev/null
+++ b/src/quick/doc/snippets/pointerHandlers/pointHandlerMargin.qml
@@ -0,0 +1,36 @@
+// Copyright (C) 2023 Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+//![0]
+import QtQuick
+
+Item {
+ width: 480; height: 320
+
+ Rectangle {
+ anchors.fill: handlingContainer
+ anchors.margins: -handler.margin
+ color: "beige"
+ }
+
+ Rectangle {
+ id: handlingContainer
+ width: 200; height: 200
+ anchors.centerIn: parent
+ border.color: "green"
+ color: handler.active ? "lightsteelblue" : "khaki"
+
+ Text {
+ text: "X"
+ x: handler.point.position.x - width / 2
+ y: handler.point.position.y - height / 2
+ visible: handler.active
+ }
+
+ PointHandler {
+ id: handler
+ margin: 30
+ }
+ }
+
+}
+//![0]
diff --git a/src/quick/doc/snippets/pointerHandlers/tapHandlerButtonReleaseWithinBounds.qml b/src/quick/doc/snippets/pointerHandlers/tapHandlerButtonReleaseWithinBounds.qml
new file mode 100644
index 0000000000..3e8634a605
--- /dev/null
+++ b/src/quick/doc/snippets/pointerHandlers/tapHandlerButtonReleaseWithinBounds.qml
@@ -0,0 +1,51 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+//![0]
+import QtQuick
+
+Item {
+ width: 120; height: 80
+
+ component Button : Rectangle {
+ id: button
+ signal clicked
+ property alias text: buttonLabel.text
+
+ width: 80
+ height: 40
+ radius: 3
+ property color dark: Qt.darker(palette.button, 1.3)
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: tapHandler.pressed ? dark : palette.button }
+ GradientStop { position: 1.0; color: dark }
+ }
+
+ SequentialAnimation on border.width {
+ id: tapFlash
+ running: false
+ loops: 3
+ PropertyAction { value: 2 }
+ PauseAnimation { duration: 100 }
+ PropertyAction { value: 0 }
+ PauseAnimation { duration: 100 }
+ }
+
+ //![1]
+ TapHandler {
+ id: tapHandler
+ gesturePolicy: TapHandler.ReleaseWithinBounds
+ onTapped: tapFlash.start()
+ }
+ //![1]
+
+ Text {
+ id: buttonLabel
+ text: "Click Me"
+ color: palette.buttonText
+ anchors.centerIn: parent
+ }
+ }
+
+ Button { x: 10; y: 10 }
+}
+//![0]
diff --git a/src/quick/doc/snippets/pointerHandlers/tapHandlerButtonWithinBounds.qml b/src/quick/doc/snippets/pointerHandlers/tapHandlerButtonWithinBounds.qml
new file mode 100644
index 0000000000..4563b44014
--- /dev/null
+++ b/src/quick/doc/snippets/pointerHandlers/tapHandlerButtonWithinBounds.qml
@@ -0,0 +1,51 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+//![0]
+import QtQuick
+
+Item {
+ width: 120; height: 80
+
+ component Button : Rectangle {
+ id: button
+ signal clicked
+ property alias text: buttonLabel.text
+
+ width: 80
+ height: 40
+ radius: 3
+ property color dark: Qt.darker(palette.button, 1.3)
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: tapHandler.pressed ? dark : palette.button }
+ GradientStop { position: 1.0; color: dark }
+ }
+
+ SequentialAnimation on border.width {
+ id: tapFlash
+ running: false
+ loops: 3
+ PropertyAction { value: 2 }
+ PauseAnimation { duration: 100 }
+ PropertyAction { value: 0 }
+ PauseAnimation { duration: 100 }
+ }
+
+ //![1]
+ TapHandler {
+ id: tapHandler
+ gesturePolicy: TapHandler.WithinBounds
+ onTapped: tapFlash.start()
+ }
+ //![1]
+
+ Text {
+ id: buttonLabel
+ text: "Click Me"
+ color: palette.buttonText
+ anchors.centerIn: parent
+ }
+ }
+
+ Button { x: 10; y: 10 }
+}
+//![0]
diff --git a/src/quick/doc/snippets/pointerHandlers/tapHandlerOverlappingButtons.qml b/src/quick/doc/snippets/pointerHandlers/tapHandlerOverlappingButtons.qml
new file mode 100644
index 0000000000..917c863e53
--- /dev/null
+++ b/src/quick/doc/snippets/pointerHandlers/tapHandlerOverlappingButtons.qml
@@ -0,0 +1,51 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+//![0]
+import QtQuick
+
+Item {
+ width: 120; height: 80
+
+ component Button : Rectangle {
+ signal clicked
+ property alias text: buttonLabel.text
+
+ width: 80
+ height: 40
+ radius: 3
+ property color dark: Qt.darker(palette.button, 1.3)
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: tapHandler.pressed ? dark : palette.button }
+ GradientStop { position: 1.0; color: dark }
+ }
+
+ SequentialAnimation on border.width {
+ id: tapFlash
+ running: false
+ loops: 3
+ PropertyAction { value: 2 }
+ PauseAnimation { duration: 100 }
+ PropertyAction { value: 0 }
+ PauseAnimation { duration: 100 }
+ }
+
+ //![1]
+ TapHandler {
+ id: tapHandler
+ gesturePolicy: TapHandler.DragThreshold // the default
+ onTapped: tapFlash.start()
+ }
+ //![1]
+
+ Text {
+ id: buttonLabel
+ text: "Click Me"
+ color: palette.buttonText
+ anchors.centerIn: parent
+ }
+ }
+
+ Button { x: 10; y: 10 }
+ Button { x: 30; y: 30 }
+}
+//![0]
diff --git a/src/quick/doc/snippets/qml/item/itemGrab.qml b/src/quick/doc/snippets/qml/item/itemGrab.qml
new file mode 100644
index 0000000000..ef4430175a
--- /dev/null
+++ b/src/quick/doc/snippets/qml/item/itemGrab.qml
@@ -0,0 +1,39 @@
+// Copyright (C) 2014 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick 2.4
+
+Item {
+ width: 320
+ height: 480
+
+//! [grab-to-file]
+Rectangle {
+ id: sourceRectangle
+ width: 100
+ height: 100
+ gradient: Gradient {
+ GradientStop { position: 0; color: "steelblue" }
+ GradientStop { position: 1; color: "black" }
+ }
+
+ Component.onCompleted: {
+ sourceRectangle.grabToImage(function(result) {
+ result.saveToFile("something.png")
+ })
+ }
+}
+//! [grab-to-file]
+
+//! [grab-to-image]
+Image {
+ id: image
+}
+
+Component.onCompleted: {
+ sourceRectangle.grabToImage(function(result) {
+ image.source = result.url
+ }, Qt.size(50, 50))
+}
+//! [grab-to-image]
+}
diff --git a/src/quick/doc/snippets/qml/itemGrab.qml b/src/quick/doc/snippets/qml/itemGrab.qml
deleted file mode 100644
index dd02661894..0000000000
--- a/src/quick/doc/snippets/qml/itemGrab.qml
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (C) 2014 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick 2.4
-
-Item {
- width: 320
- height: 480
-
-//! [grab-source]
-Rectangle {
- id: source
- width: 100
- height: 100
- gradient: Gradient {
- GradientStop { position: 0; color: "steelblue" }
- GradientStop { position: 1; color: "black" }
- }
-}
-//! [grab-source]
-
-//! [grab-image-target]
-Image {
- id: image
-}
-//! [grab-image-target]
- Timer {
- repeat: false
- running: true
- interval: 1000
- onTriggered: {
-//! [grab-to-file]
-
- // ...
- source.grabToImage(function(result) {
- result.saveToFile("something.png");
- });
-//! [grab-to-file]
-
-//! [grab-to-cache]
-
- // ...
- source.grabToImage(function(result) {
- image.source = result.url;
- },
- Qt.size(50, 50));
-//! [grab-to-cache]
- }
- }
-}
diff --git a/src/quick/doc/src/concepts/inputhandlers/qtquickhandlers-index.qdoc b/src/quick/doc/src/concepts/inputhandlers/qtquickhandlers-index.qdoc
index 182773b0f5..1157364df8 100644
--- a/src/quick/doc/src/concepts/inputhandlers/qtquickhandlers-index.qdoc
+++ b/src/quick/doc/src/concepts/inputhandlers/qtquickhandlers-index.qdoc
@@ -70,7 +70,8 @@
PointHandler) can work only with passive grabs; others require exclusive
grabs; and others can "lurk" with passive grabs until they detect that a
gesture is being performed, and then make the transition from passive to
- exclusive grab.
+ exclusive grab. TapHandler's grabbing behavior is
+ \l {TapHandler::gesturePolicy}{configurable}.
When a grab transition is requested, \l PointerHandler::grabPermissions,
\l QQuickItem::keepMouseGrab() and \l QQuickItem::keepTouchGrab() control
diff --git a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
index 505e7b570a..8163cf0dd6 100644
--- a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
+++ b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
@@ -1171,8 +1171,10 @@ with multiple windows.
\row
\li \c QSG_RHI_DEBUG_LAYER
\li \c 1
- \li Where applicable (Vulkan, Direct3D), enables the graphics API implementation's debug
- and/or validation layers, if available.
+ \li Where applicable (Vulkan, Direct3D), enables the graphics API implementation's
+ debug or validation layers, if available, either on the graphics device or the instance
+ object. For Metal on \macos, set the environment variable
+ \c{METAL_DEVICE_WRAPPER_TYPE=1} instead.
\row
\li \c QSG_RHI_PREFER_SOFTWARE_RENDERER
diff --git a/src/quick/doc/src/cppextensionpoints.qdoc b/src/quick/doc/src/cppextensionpoints.qdoc
index 148df0dce8..9a62f8f715 100644
--- a/src/quick/doc/src/cppextensionpoints.qdoc
+++ b/src/quick/doc/src/cppextensionpoints.qdoc
@@ -30,17 +30,16 @@ for more details.
\target scene-graph-related-classes
\section1 Scene Graph-Related Classes
-Qt Quick 2 makes use of a dedicated scene graph based on OpenGL ES 2.0 or OpenGL 2.0
-for its rendering. Using a scene graph for graphics rather than the traditional imperative
-painting systems (QPainter and similar), means the scene to be rendered can be retained
-between frames and the complete set of primitives to render is known before rendering
-starts. This opens up for a number of optimizations, such as batching the OpenGL draw calls
-to minimize state changes or discarding obscured primitives.
-
+Qt Quick 2 makes use of a dedicated scene graph based on graphics APIs such as
+OpenGL ES, OpenGL, Vulkan, Metal, or Direct 3D for its rendering. Using a scene
+graph for graphics rather than the traditional imperative painting systems
+(QPainter and similar), means the scene to be rendered can be retained between
+frames and the complete set of primitives to render is known before rendering
+starts. This opens up for a number of optimizations, such as batching the
+OpenGL draw calls to minimize state changes or discarding obscured primitives.
The \l {Qt Quick C++ Classes}{Qt Quick C++ API} provides various classes to
-enable custom nodes to be created in C++.
-
-See the \l {Qt Quick Scene Graph} documentation for details.
+enable custom nodes to be created in C++. See the \l {Qt Quick Scene Graph}
+documentation for details.
\target pixmap-and-threaded-image-support
\section1 Pixmap and Threaded Image Support
diff --git a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
index e3c64a85a1..bce8a2e11c 100644
--- a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
+++ b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
@@ -28,11 +28,16 @@ options that align with the latest UI design trends. If these UI controls do not
satisfy your application's needs, only then it is recommended to create a
custom control.
+You can use the controls when you design UIs in Qt Design Studio. In addition,
+it provides timeline-based animations, visual effects, layouts, and a
+live-preview for prototyping applications.
\section2 Related Information
\list
\li \l{Qt Quick Controls}
+\li \l{Customizing Qt Quick Controls}
\li \l{Qt Quick}
+\li \l{Qt Design Studio Manual}
\endlist
\omit
@@ -93,7 +98,7 @@ All QML files listed under \c {QML_FILES} will automatically get compiled \l {Ah
\li \l{The Qt Resource System}
\endlist
-\section1 Separate UI from Logic
+\section1 Separate UI from Business Logic
One of the key goals that most application developers want to achieve is to
create a maintainable application. One of the ways to achieve this goal is
@@ -109,8 +114,8 @@ reasons why an application's UI should be written in QML:
\li JavaScript can easily be used in QML to respond to events.
\endlist
-Being a strongly typed language, C++ is best suited for an application's logic.
-Typically, such code performs tasks such as complex calculations
+Being a strongly typed language, C++ is best suited for an application's
+business logic. Typically, such code performs tasks such as complex calculations
or data processing, which are faster in C++ than QML.
Qt offers various approaches to integrate QML and C++ code in an application.
@@ -154,6 +159,22 @@ see \l {Choosing the Correct Integration Method Between C++ and QML}.
\li \l{Qt Quick Controls - Chat Tutorial}{Chat application tutorial}
\endlist
+\section1 Using Qt Design Studio
+
+Qt Design Studio uses UI files that have the filename extension \e {.ui.qml}
+to separate the visual parts of the UI from the UI logic you implement in
+\e {.qml} files. You should edit UI files only in the \uicontrol {2D} view in
+Qt Design Studio. If you use some other tool to add code that Qt Design Studio
+does not support, it displays error messages. Fix the errors to enable visual
+editing of the UI files again. Typically, you should move the unsupported code
+to a \e {.qml} file.
+
+\section2 Related Information
+
+\list
+ \li \l{Qt Design Studio: UI Files}
+\endlist
+
\section1 Using Qt Quick Layouts
Qt offers Qt Quick Layouts to arrange Qt Quick items visually in a layout.
diff --git a/src/quick/doc/src/guidelines/qtquick-tool-qmllint.qdoc b/src/quick/doc/src/guidelines/qtquick-tool-qmllint.qdoc
index 6ca5f4f47b..0a9d6dbc58 100644
--- a/src/quick/doc/src/guidelines/qtquick-tool-qmllint.qdoc
+++ b/src/quick/doc/src/guidelines/qtquick-tool-qmllint.qdoc
@@ -129,9 +129,9 @@ that take precedence over the warning levels in settings.
\section2 Scripting
-qmllint can output JSON via the \c{--json} option which will return valid JSON
+qmllint can write or output JSON via the \c{--json <file>} option which will return valid JSON
with warning messages, file and line location of warnings, and their severity
-level.
+level. Use the special filename '-' to write to stdout instead of a file.
This can be used to more easily integrate qmllint in your pre-commit hooks or
CI testing.
diff --git a/src/quick/doc/src/qmltypereference.qdoc b/src/quick/doc/src/qmltypereference.qdoc
index 2ad40fc315..c856a42b8a 100644
--- a/src/quick/doc/src/qmltypereference.qdoc
+++ b/src/quick/doc/src/qmltypereference.qdoc
@@ -56,10 +56,10 @@ available when you import \c QtQuick.
*/
/*!
+ \keyword colorvaluetypedocs
\qmlvaluetype color
\ingroup qtquickvaluetypes
\brief an ARGB color value.
- \target colorvaluetypedocs
The \c color type refers to an ARGB color value. It can be specified in a number of ways:
@@ -835,7 +835,7 @@ console.log(c + " " + d); // false true
\qmlvaluetype matrix4x4
\ingroup qtquickvaluetypes
- \brief A matrix4x4 type is a 4-row and 4-column matrix
+ \brief A matrix4x4 type is a 4-row and 4-column matrix.
A \c matrix4x4 type has sixteen values, each accessible via the properties
\c m11 through \c m44 in QML (in row/column order). Values of this type
diff --git a/src/quick/handlers/qquickdraghandler.cpp b/src/quick/handlers/qquickdraghandler.cpp
index f90dd305d9..c31eb13d98 100644
--- a/src/quick/handlers/qquickdraghandler.cpp
+++ b/src/quick/handlers/qquickdraghandler.cpp
@@ -186,7 +186,7 @@ void QQuickDragHandler::handlePointerEventImpl(QPointerEvent *event)
QVector<QEventPoint> chosenPoints;
if (event->isBeginEvent())
- m_pressedInsideTarget = target() && currentPoints().count() > 0;
+ m_pressedInsideTarget = target() && currentPoints().size() > 0;
for (const QQuickHandlerPoint &p : currentPoints()) {
if (!allOverThreshold)
diff --git a/src/quick/handlers/qquickhandlerpoint.cpp b/src/quick/handlers/qquickhandlerpoint.cpp
index 2028c5c8ec..75848c2882 100644
--- a/src/quick/handlers/qquickhandlerpoint.cpp
+++ b/src/quick/handlers/qquickhandlerpoint.cpp
@@ -8,7 +8,7 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcTouchTarget)
/*!
- \qmltype HandlerPoint
+ \qmltype handlerPoint
\instantiates QQuickHandlerPoint
\inqmlmodule QtQuick
\brief An event point.
@@ -30,7 +30,7 @@ Q_DECLARE_LOGGING_CATEGORY(lcTouchTarget)
and reused for subsequent event deliveries. Continuous bindings to its
properties are not possible, and an individual handler cannot rely on it
outside the period when that point is part of an active gesture which that
- handler is handling. HandlerPoint is a Q_GADGET that the handler owns.
+ handler is handling. handlerPoint is a Q_GADGET that the handler owns.
This allows you to make lifetime bindings to its properties.
\sa SinglePointHandler::point, MultiPointHandler::centroid
@@ -105,7 +105,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
qWarning("reset: no points");
return;
}
- if (points.count() == 1) {
+ if (points.size() == 1) {
*this = points.first(); // copy all values
return;
}
@@ -144,7 +144,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty int QtQuick::HandlerPoint::id
+ \qmlproperty int QtQuick::handlerPoint::id
\brief The ID number of the point
During a touch gesture, from the time that the first finger is pressed
@@ -162,7 +162,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty pointingDeviceUniqueId QtQuick::HandlerPoint::uniqueId
+ \qmlproperty pointingDeviceUniqueId QtQuick::handlerPoint::uniqueId
\brief The unique ID of the point, if any
This is normally empty, because touchscreens cannot uniquely identify fingers.
@@ -184,7 +184,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty QPointF QtQuick::HandlerPoint::position
+ \qmlproperty QPointF QtQuick::handlerPoint::position
\brief The position within the \c parent Item
This is the position of the event point relative to the bounds of
@@ -193,7 +193,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty QPointF QtQuick::HandlerPoint::scenePosition
+ \qmlproperty QPointF QtQuick::handlerPoint::scenePosition
\brief The position within the scene
This is the position of the event point relative to the bounds of the Qt
@@ -202,7 +202,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty QPointF QtQuick::HandlerPoint::pressPosition
+ \qmlproperty QPointF QtQuick::handlerPoint::pressPosition
\brief The pressed position within the \c parent Item
This is the position at which this point was pressed, relative to the
@@ -211,7 +211,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty QPointF QtQuick::HandlerPoint::scenePressPosition
+ \qmlproperty QPointF QtQuick::handlerPoint::scenePressPosition
\brief The pressed position within the scene
This is the position at which this point was pressed, in the coordinate
@@ -220,7 +220,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty QPointF QtQuick::HandlerPoint::sceneGrabPosition
+ \qmlproperty QPointF QtQuick::handlerPoint::sceneGrabPosition
\brief The grabbed position within the scene
If this point has been grabbed by a Pointer Handler or an Item, it means
@@ -231,7 +231,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty enumeration QtQuick::HandlerPoint::pressedButtons
+ \qmlproperty enumeration QtQuick::handlerPoint::pressedButtons
\brief Which mouse or stylus buttons are currently pressed
\sa MouseArea::pressedButtons
@@ -239,7 +239,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty enumeration QtQuick::HandlerPoint::modifiers
+ \qmlproperty enumeration QtQuick::handlerPoint::modifiers
\brief Which modifier keys are currently pressed
This property holds the keyboard modifiers that were pressed at the time
@@ -248,7 +248,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty QVector2D QtQuick::HandlerPoint::velocity
+ \qmlproperty QVector2D QtQuick::handlerPoint::velocity
\brief A vector representing the average speed and direction of movement
This is a velocity vector pointing in the direction of movement, in logical
@@ -261,7 +261,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty qreal QtQuick::HandlerPoint::rotation
+ \qmlproperty qreal QtQuick::handlerPoint::rotation
This property holds the rotation angle of the stylus on a graphics tablet
or the contact patch of a touchpoint on a touchscreen.
@@ -272,7 +272,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty qreal QtQuick::HandlerPoint::pressure
+ \qmlproperty qreal QtQuick::handlerPoint::pressure
This property tells how hard the user is pressing the stylus on a graphics
tablet or the finger against a touchscreen, in the range from \c 0 (no
@@ -285,7 +285,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
/*!
\readonly
- \qmlproperty size QtQuick::HandlerPoint::ellipseDiameters
+ \qmlproperty size QtQuick::handlerPoint::ellipseDiameters
This property holds the diameters of the contact patch, if the event
comes from a touchpoint and the device provides this information.
@@ -309,6 +309,13 @@ void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
\sa QtQuick::TouchPoint::ellipseDiameters, QEventPoint::ellipseDiameters
*/
+/*!
+ \readonly
+ \qmlproperty PointerDevice QtQuick::handlerPoint::device
+
+ This property holds the device that the point (and its event) came from.
+*/
+
QT_END_NAMESPACE
#include "moc_qquickhandlerpoint_p.cpp"
diff --git a/src/quick/handlers/qquickhandlerpoint_p.h b/src/quick/handlers/qquickhandlerpoint_p.h
index 79a05765c8..7a01aedca1 100644
--- a/src/quick/handlers/qquickhandlerpoint_p.h
+++ b/src/quick/handlers/qquickhandlerpoint_p.h
@@ -38,6 +38,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickHandlerPoint {
Q_PROPERTY(qreal pressure READ pressure)
Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters)
Q_PROPERTY(QPointingDevice *device READ device)
+ QML_ANONYMOUS
public:
QQuickHandlerPoint();
diff --git a/src/quick/handlers/qquickhoverhandler.cpp b/src/quick/handlers/qquickhoverhandler.cpp
index 59a2775c7b..ea7613550f 100644
--- a/src/quick/handlers/qquickhoverhandler.cpp
+++ b/src/quick/handlers/qquickhoverhandler.cpp
@@ -34,17 +34,64 @@ Q_LOGGING_CATEGORY(lcHoverHandler, "qt.quick.handler.hover")
\sa MouseArea, PointHandler
*/
+class QQuickHoverHandlerPrivate : public QQuickSinglePointHandlerPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickHoverHandler)
+
+public:
+ void onEnabledChanged() override;
+ void onParentChanged(QQuickItem *oldParent, QQuickItem *newParent) override;
+
+ void updateHasHoverInChild(QQuickItem *item, bool hasHover);
+};
+
+void QQuickHoverHandlerPrivate::onEnabledChanged()
+{
+ Q_Q(QQuickHoverHandler);
+
+ if (auto parent = q->parentItem())
+ updateHasHoverInChild(parent, enabled);
+ if (!enabled)
+ q->setHovered(false);
+
+ QQuickSinglePointHandlerPrivate::onEnabledChanged();
+}
+
+void QQuickHoverHandlerPrivate::onParentChanged(QQuickItem *oldParent, QQuickItem *newParent)
+{
+ if (oldParent)
+ updateHasHoverInChild(oldParent, false);
+ if (newParent)
+ updateHasHoverInChild(newParent, true);
+
+ QQuickSinglePointHandlerPrivate::onParentChanged(oldParent, newParent);
+}
+
+void QQuickHoverHandlerPrivate::updateHasHoverInChild(QQuickItem *item, bool hasHover)
+{
+ QQuickItemPrivate *itemPriv = QQuickItemPrivate::get(item);
+ itemPriv->setHasHoverInChild(hasHover);
+ // The DA needs to resolve which items and handlers should now be hovered or unhovered.
+ // Marking the parent item dirty ensures that flushFrameSynchronousEvents() will be called from the render loop,
+ // even if this change is not in response to a mouse event and no item has already marked itself dirty.
+ itemPriv->dirty(QQuickItemPrivate::Content);
+}
+
QQuickHoverHandler::QQuickHoverHandler(QQuickItem *parent)
- : QQuickSinglePointHandler(parent)
+ : QQuickSinglePointHandler(*(new QQuickHoverHandlerPrivate), parent)
{
+ Q_D(QQuickHoverHandler);
// Tell QQuickPointerDeviceHandler::wantsPointerEvent() to ignore button state
- d_func()->acceptedButtons = Qt::NoButton;
+ d->acceptedButtons = Qt::NoButton;
+ if (parent)
+ d->updateHasHoverInChild(parent, true);
}
QQuickHoverHandler::~QQuickHoverHandler()
{
+ Q_D(QQuickHoverHandler);
if (auto parent = parentItem())
- QQuickItemPrivate::get(parent)->setHasHoverInChild(false);
+ d->updateHasHoverInChild(parent, false);
}
/*!
@@ -52,7 +99,7 @@ QQuickHoverHandler::~QQuickHoverHandler()
\since 6.3
Whether this handler prevents other items or handlers behind it from
- being hovered at the same timee. This property is \c false by default.
+ being hovered at the same time. This property is \c false by default.
*/
void QQuickHoverHandler::setBlocking(bool blocking)
{
@@ -81,10 +128,12 @@ bool QQuickHoverHandler::event(QEvent *event)
void QQuickHoverHandler::componentComplete()
{
+ Q_D(QQuickHoverHandler);
QQuickSinglePointHandler::componentComplete();
- if (auto par = parentItem()) {
- par->setAcceptHoverEvents(true);
- QQuickItemPrivate::get(par)->setHasHoverInChild(true);
+
+ if (d->enabled) {
+ if (auto parent = parentItem())
+ d->updateHasHoverInChild(parent, true);
}
}
@@ -108,6 +157,9 @@ bool QQuickHoverHandler::wantsPointerEvent(QPointerEvent *event)
// the hovered property to transition to false prematurely.
// If a QQuickPointerTabletEvent caused the hovered property to become true,
// then only another QQuickPointerTabletEvent can make it become false.
+ // But after kCursorOverrideTimeout ms, QQuickItemPrivate::effectiveCursorHandler()
+ // will ignore it, just in case there is no QQuickPointerTabletEvent to unset it.
+ // For example, a tablet proximity leave event could occur, but we don't deliver it to the window.
if (!(m_hoveredTablet && QQuickDeliveryAgentPrivate::isMouseEvent(event)))
setHovered(false);
@@ -284,6 +336,13 @@ void QQuickHoverHandler::setHovered(bool hovered)
\sa Qt::CursorShape, QQuickItem::cursor()
*/
+/*!
+ \internal
+ \qmlproperty flags HoverHandler::dragThreshold
+
+ This property is not used in HoverHandler.
+*/
+
QT_END_NAMESPACE
#include "moc_qquickhoverhandler_p.cpp"
diff --git a/src/quick/handlers/qquickhoverhandler_p.h b/src/quick/handlers/qquickhoverhandler_p.h
index 39ceb3df21..354a846428 100644
--- a/src/quick/handlers/qquickhoverhandler_p.h
+++ b/src/quick/handlers/qquickhoverhandler_p.h
@@ -22,6 +22,8 @@
QT_BEGIN_NAMESPACE
+class QQuickHoverHandlerPrivate;
+
class Q_QUICK_PRIVATE_EXPORT QQuickHoverHandler : public QQuickSinglePointHandler
{
Q_OBJECT
@@ -50,6 +52,8 @@ protected:
bool wantsPointerEvent(QPointerEvent *event) override;
void handleEventPoint(QPointerEvent *ev, QEventPoint &point) override;
+ Q_DECLARE_PRIVATE(QQuickHoverHandler)
+
private:
void setHovered(bool hovered);
diff --git a/src/quick/handlers/qquickmultipointhandler.cpp b/src/quick/handlers/qquickmultipointhandler.cpp
index aaee15d2f0..c50de437cd 100644
--- a/src/quick/handlers/qquickmultipointhandler.cpp
+++ b/src/quick/handlers/qquickmultipointhandler.cpp
@@ -51,7 +51,7 @@ bool QQuickMultiPointHandler::wantsPointerEvent(QPointerEvent *event)
// currentPoints, because we don't want to lose the pressPosition, and do
// not want to reshuffle the order either).
const auto candidatePoints = eligiblePoints(event);
- if (candidatePoints.count() != d->currentPoints.count()) {
+ if (candidatePoints.size() != d->currentPoints.size()) {
d->currentPoints.clear();
if (active()) {
setActive(false);
@@ -64,7 +64,7 @@ bool QQuickMultiPointHandler::wantsPointerEvent(QPointerEvent *event)
ret = ret || (candidatePoints.size() >= minimumPointCount() && candidatePoints.size() <= maximumPointCount());
if (ret) {
- const int c = candidatePoints.count();
+ const int c = candidatePoints.size();
d->currentPoints.resize(c);
for (int i = 0; i < c; ++i) {
d->currentPoints[i].reset(event, candidatePoints[i]);
@@ -229,7 +229,7 @@ void QQuickMultiPointHandler::setMaximumPointCount(int maximumPointCount)
/*!
\readonly
- \qmlproperty QtQuick::HandlerPoint QtQuick::MultiPointHandler::centroid
+ \qmlproperty QtQuick::handlerPoint QtQuick::MultiPointHandler::centroid
A point exactly in the middle of the currently-pressed touch points.
If only one point is pressed, it's the same as that point.
@@ -265,7 +265,7 @@ bool QQuickMultiPointHandler::hasCurrentPoints(QPointerEvent *event)
return false;
// TODO optimize: either ensure the points are sorted,
// or use std::equal with a predicate
- for (const QQuickHandlerPoint &p : qAsConst(d->currentPoints)) {
+ for (const QQuickHandlerPoint &p : std::as_const(d->currentPoints)) {
const QEventPoint *ep = event->pointById(p.id());
if (!ep)
return false;
@@ -302,7 +302,7 @@ QVector<QQuickMultiPointHandler::PointData> QQuickMultiPointHandler::angles(cons
{
Q_D(const QQuickMultiPointHandler);
QVector<PointData> angles;
- angles.reserve(d->currentPoints.count());
+ angles.reserve(d->currentPoints.size());
for (const QQuickHandlerPoint &p : d->currentPoints) {
qreal angle = QLineF(ref, p.scenePosition()).angle();
angles.append(PointData(p.id(), -angle)); // convert to clockwise, to be consistent with QQuickItem::rotation
@@ -362,7 +362,7 @@ bool QQuickMultiPointHandler::grabPoints(QPointerEvent *event, const QVector<QEv
}
}
if (allowed) {
- for (auto point : points)
+ for (const auto &point : std::as_const(points))
setExclusiveGrab(event, point);
}
return allowed;
diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp
index 1ac08d5354..6cfe8d8936 100644
--- a/src/quick/handlers/qquickpinchhandler.cpp
+++ b/src/quick/handlers/qquickpinchhandler.cpp
@@ -203,8 +203,8 @@ void QQuickPinchHandler::onActiveChanged()
m_startRotation = t->rotation();
m_startPos = t->position();
} else {
- m_startScale = 1;
- m_startRotation = 0;
+ m_startScale = m_accumulatedScale;
+ m_startRotation = 0; // TODO m_accumulatedRotation (QTBUG-94168)
}
qCDebug(lcPinchHandler) << "activated with starting scale" << m_startScale << "rotation" << m_startRotation;
} else {
@@ -236,6 +236,7 @@ void QQuickPinchHandler::handlePointerEventImpl(QPointerEvent *event)
return;
case Qt::ZoomNativeGesture:
m_activeScale *= 1 + gesture->value();
+ m_activeScale = qBound(m_minimumScale, m_activeScale, m_maximumScale);
break;
case Qt::RotateNativeGesture:
m_activeRotation += gesture->value();
@@ -333,9 +334,9 @@ void QQuickPinchHandler::handlePointerEventImpl(QPointerEvent *event)
}
const bool requiredNumberOfPointsDraggedOverThreshold = numberOfPointsDraggedOverThreshold >= minimumPointCount() && numberOfPointsDraggedOverThreshold <= maximumPointCount();
- accumulatedMovementMagnitude /= currentPoints().count();
+ accumulatedMovementMagnitude /= currentPoints().size();
- QVector2D avgDrag = accumulatedDrag / currentPoints().count();
+ QVector2D avgDrag = accumulatedDrag / currentPoints().size();
if (!xAxis()->enabled())
avgDrag.setX(0);
if (!yAxis()->enabled())
@@ -425,8 +426,15 @@ void QQuickPinchHandler::handlePointerEventImpl(QPointerEvent *event)
}
/*!
+ \internal
+ \qmlproperty flags QtQuick::PinchHandler::acceptedButtons
+
+ This property is not used in PinchHandler.
+*/
+
+/*!
\readonly
- \qmlproperty QtQuick::HandlerPoint QtQuick::PinchHandler::centroid
+ \qmlproperty QtQuick::handlerPoint QtQuick::PinchHandler::centroid
A point exactly in the middle of the currently-pressed touch points.
The \l target will be rotated around this point.
@@ -471,6 +479,9 @@ void QQuickPinchHandler::handlePointerEventImpl(QPointerEvent *event)
The translation of the gesture \l centroid. It is \c (0, 0) when the
gesture begins.
+
+ \note On some touchpads, such as on a \macos trackpad, native gestures do
+ not generate any translation values, and this property stays at \c (0, 0).
*/
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickpointerdevicehandler.cpp b/src/quick/handlers/qquickpointerdevicehandler.cpp
index 78e94d8c96..5da7849a44 100644
--- a/src/quick/handlers/qquickpointerdevicehandler.cpp
+++ b/src/quick/handlers/qquickpointerdevicehandler.cpp
@@ -31,7 +31,7 @@ QQuickPointerDeviceHandler::QQuickPointerDeviceHandler(QQuickPointerDeviceHandle
{
}
-QPointingDevice::DeviceTypes QQuickPointerDeviceHandler::acceptedDevices() const
+QInputDevice::DeviceTypes QQuickPointerDeviceHandler::acceptedDevices() const
{
Q_D(const QQuickPointerDeviceHandler);
return d->acceptedDevices;
@@ -139,7 +139,7 @@ void QQuickPointerDeviceHandler::setAcceptedDevices(QPointingDevice::DeviceTypes
By default, this property is set to
\l {QPointingDevice::PointerType} {PointerDevice.AllPointerTypes}.
If you set it to an OR combination of device types, it will ignore events
- from non-matching events.
+ from non-matching \l {PointerDevice}{devices}.
For example, a control could be made to respond to mouse, touch, and stylus clicks
in some way, but delete itself if tapped with an eraser tool on a graphics tablet,
diff --git a/src/quick/handlers/qquickpointerdevicehandler_p.h b/src/quick/handlers/qquickpointerdevicehandler_p.h
index 259b8a5ae7..1a62194d78 100644
--- a/src/quick/handlers/qquickpointerdevicehandler_p.h
+++ b/src/quick/handlers/qquickpointerdevicehandler_p.h
@@ -23,7 +23,8 @@ class QQuickPointerDeviceHandlerPrivate;
class Q_QUICK_PRIVATE_EXPORT QQuickPointerDeviceHandler : public QQuickPointerHandler
{
Q_OBJECT
- Q_PROPERTY(QPointingDevice::DeviceTypes acceptedDevices READ acceptedDevices WRITE setAcceptedDevices NOTIFY acceptedDevicesChanged)
+ Q_PROPERTY(QInputDevice::DeviceTypes acceptedDevices READ acceptedDevices WRITE
+ setAcceptedDevices NOTIFY acceptedDevicesChanged)
Q_PROPERTY(QPointingDevice::PointerTypes acceptedPointerTypes READ acceptedPointerTypes WRITE setAcceptedPointerTypes NOTIFY acceptedPointerTypesChanged)
Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
Q_PROPERTY(Qt::KeyboardModifiers acceptedModifiers READ acceptedModifiers WRITE setAcceptedModifiers NOTIFY acceptedModifiersChanged)
@@ -31,13 +32,13 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerDeviceHandler : public QQuickPointerHa
public:
explicit QQuickPointerDeviceHandler(QQuickItem *parent = nullptr);
- QPointingDevice::DeviceTypes acceptedDevices() const;
+ QInputDevice::DeviceTypes acceptedDevices() const;
QPointingDevice::PointerTypes acceptedPointerTypes() const;
Qt::MouseButtons acceptedButtons() const;
Qt::KeyboardModifiers acceptedModifiers() const;
public Q_SLOTS:
- void setAcceptedDevices(QPointingDevice::DeviceTypes acceptedDevices);
+ void setAcceptedDevices(QInputDevice::DeviceTypes acceptedDevices);
void setAcceptedPointerTypes(QPointingDevice::PointerTypes acceptedPointerTypes);
void setAcceptedButtons(Qt::MouseButtons buttons);
void setAcceptedModifiers(Qt::KeyboardModifiers acceptedModifiers);
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp
index 018a09fcc2..a851334b0e 100644
--- a/src/quick/handlers/qquickpointerhandler.cpp
+++ b/src/quick/handlers/qquickpointerhandler.cpp
@@ -401,6 +401,8 @@ bool QQuickPointerHandler::approveGrabTransition(QPointerEvent *event, const QEv
This handler can take the exclusive grab from another handler of the same class.
\value PointerHandler.CanTakeOverFromHandlersOfDifferentType
This handler can take the exclusive grab from any kind of handler.
+ \value PointerHandler.CanTakeOverFromItems
+ This handler can take the exclusive grab from any type of Item.
\value PointerHandler.CanTakeOverFromAnything
This handler can take the exclusive grab from any type of Item or Handler.
\value PointerHandler.ApprovesTakeOverByHandlersOfSameType
@@ -553,6 +555,8 @@ void QQuickPointerHandler::setEnabled(bool enabled)
return;
d->enabled = enabled;
+ d->onEnabledChanged();
+
emit enabledChanged();
}
@@ -593,15 +597,18 @@ QQuickItem *QQuickPointerHandler::parentItem() const
void QQuickPointerHandler::setParentItem(QQuickItem *p)
{
+ Q_D(QQuickPointerHandler);
if (QObject::parent() == p)
return;
qCDebug(lcHandlerParent) << "reparenting handler" << this << ":" << parent() << "->" << p;
- if (auto *oldParent = static_cast<QQuickItem *>(QObject::parent()))
+ auto *oldParent = static_cast<QQuickItem *>(QObject::parent());
+ if (oldParent)
QQuickItemPrivate::get(oldParent)->removePointerHandler(this);
setParent(p);
if (p)
QQuickItemPrivate::get(p)->addPointerHandler(this);
+ d->onParentChanged(oldParent, p);
emit parentChanged();
}
@@ -645,6 +652,7 @@ void QQuickPointerHandler::handlePointerEvent(QPointerEvent *event)
d->currentEvent = event;
if (wants) {
handlePointerEventImpl(event);
+ d->lastEventTime = event->timestamp();
} else {
#if QT_CONFIG(gestures)
if (event->type() != QEvent::NativeGesture)
diff --git a/src/quick/handlers/qquickpointerhandler_p_p.h b/src/quick/handlers/qquickpointerhandler_p_p.h
index 8823bcb897..aa09f4edb7 100644
--- a/src/quick/handlers/qquickpointerhandler_p_p.h
+++ b/src/quick/handlers/qquickpointerhandler_p_p.h
@@ -38,11 +38,15 @@ public:
bool dragOverThreshold(QVector2D delta) const;
bool dragOverThreshold(const QEventPoint &point) const;
+ virtual void onParentChanged(QQuickItem * /*oldParent*/, QQuickItem * /*newParent*/) {}
+ virtual void onEnabledChanged() {}
+
static QVector<QObject *> &deviceDeliveryTargets(const QInputDevice *device);
QPointerEvent *currentEvent = nullptr;
QQuickItem *target = nullptr;
qreal m_margin = 0;
+ quint64 lastEventTime = 0;
qint16 dragThreshold = -1; // -1 means use the platform default
uint8_t grabPermissions : 8;
Qt::CursorShape cursorShape : 6;
diff --git a/src/quick/handlers/qquickpointhandler.cpp b/src/quick/handlers/qquickpointhandler.cpp
index 1c5f36b6dd..2a9e0ff9bb 100644
--- a/src/quick/handlers/qquickpointhandler.cpp
+++ b/src/quick/handlers/qquickpointhandler.cpp
@@ -66,7 +66,8 @@ QT_BEGIN_NAMESPACE
PointHandler will not automatically manipulate the \c target item in any way.
You need to use bindings to make it react to the \l point.
- \note On macOS, PointHandler does not react to the trackpad by default.
+ \note On macOS, PointHandler does not react to multiple fingers on the
+ trackpad by default, although it does react to a pressed point (mouse position).
That is because macOS can provide either native gesture recognition, or raw
touchpoints, but not both. We prefer to use the native gesture event in
PinchHandler, so we do not want to disable it by enabling touch. However
@@ -75,7 +76,7 @@ QT_BEGIN_NAMESPACE
want to react to all the touchpoints but do not require the smooth
native-gesture experience.
- \sa MultiPointTouchArea
+ \sa MultiPointTouchArea, HoverHandler, {Pointer Handlers Example}
*/
QQuickPointHandler::QQuickPointHandler(QQuickItem *parent)
@@ -128,6 +129,127 @@ QVector2D QQuickPointHandler::translation() const
return QVector2D(point().position() - point().pressPosition());
}
+/*!
+ \qmlproperty flags PointHandler::acceptedButtons
+
+ The mouse buttons that can activate this PointHandler.
+
+ By default, this property is set to \l {QtQuick::MouseEvent::button} {Qt.LeftButton}.
+ It can be set to an OR combination of mouse buttons, and will ignore events
+ in which other buttons are pressed or held.
+
+ \snippet pointerHandlers/pointHandlerAcceptedButtons.qml 0
+
+ \note On a touchscreen, there are no buttons, so this property does not
+ prevent PointHandler from reacting to touchpoints.
+*/
+
+/*!
+ \qmlproperty flags PointHandler::acceptedDevices
+
+ The types of pointing devices that can activate this PointHandler.
+
+ By default, this property is set to
+ \l{QInputDevice::DeviceType}{PointerDevice.AllDevices}.
+ If you set it to an OR combination of device types, it will ignore events
+ from non-matching \l {PointerDevice}{devices}:
+
+ \snippet pointerHandlers/pointHandler.qml 1
+*/
+
+/*!
+ \qmlproperty flags PointHandler::acceptedPointerTypes
+
+ The types of pointing instruments (finger, stylus, eraser, etc.)
+ that can activate this PointHandler.
+
+ By default, this property is set to
+ \l {QPointingDevice::PointerType} {PointerDevice.AllPointerTypes}.
+ If you set it to an OR combination of device types, it will ignore events
+ from non-matching \l {PointerDevice}{devices}:
+
+ \snippet pointerHandlers/pointHandlerCanvasDrawing.qml 0
+
+ The \l {Pointer Handlers Example} includes a more complex example for
+ drawing on a Canvas with a graphics tablet.
+*/
+
+/*!
+ \qmlproperty flags PointHandler::acceptedModifiers
+
+ If this property is set, PointHandler requires the given keyboard modifiers
+ to be pressed in order to react to \l {PointerEvent}{PointerEvents}, and
+ otherwise ignores them.
+
+ If this property is set to \c Qt.KeyboardModifierMask (the default value),
+ then PointHandler ignores the modifier keys.
+
+ For example, an \l [QML] Item could have two handlers, one of which is
+ enabled only if the required keyboard modifier is pressed:
+
+ \snippet pointerHandlers/pointHandlerAcceptedModifiers.qml 0
+
+ If you set \c acceptedModifiers to an OR combination of modifier keys,
+ it means \e all of those modifiers must be pressed to activate the handler.
+
+ The available modifiers are as follows:
+
+ \value NoModifier No modifier key is allowed.
+ \value ShiftModifier A Shift key on the keyboard must be pressed.
+ \value ControlModifier A Ctrl key on the keyboard must be pressed.
+ \value AltModifier An Alt key on the keyboard must be pressed.
+ \value MetaModifier A Meta key on the keyboard must be pressed.
+ \value KeypadModifier A keypad button must be pressed.
+ \value GroupSwitchModifier X11 only (unless activated on Windows by a command line argument).
+ A Mode_switch key on the keyboard must be pressed.
+ \value KeyboardModifierMask The handler does not care which modifiers are pressed.
+
+ \sa Qt::KeyboardModifier
+*/
+
+/*!
+ \readonly
+ \qmlproperty bool PointHandler::active
+
+ This holds \c true whenever the constraints are satisfied and this
+ PointHandler is reacting. This means that it is keeping its properties
+ up-to-date according to the movements of the \l {eventPoint}{eventPoints}
+ that satisfy the constraints.
+*/
+
+/*!
+ \internal
+ \qmlproperty flags PointHandler::dragThreshold
+
+ This property is not used in PointHandler.
+*/
+
+/*!
+ \qmlproperty real PointHandler::margin
+
+ The margin beyond the bounds of the \l {PointerHandler::parent}{parent}
+ item within which an \l eventPoint can activate this handler.
+
+ The default value is \c 0.
+
+ \snippet pointerHandlers/pointHandlerMargin.qml 0
+*/
+
+/*!
+ \qmlproperty real PointHandler::target
+
+ A property that can conveniently hold an Item to be manipulated or to show
+ feedback. Unlike other \l {Qt Quick Input Handlers}{Pointer Handlers},
+ PointHandler does not do anything with the \c target on its own: you
+ usually need to create reactive bindings to properties such as
+ \l SinglePointHandler::point and \l PointHandler::active. If you declare
+ an Item instance here, you need to explicitly set its \l {Item::}{parent},
+ because PointHandler is not an Item.
+
+ By default, it is the same as the \l {PointerHandler::}{parent}, the Item
+ within which the handler is declared.
+*/
+
QT_END_NAMESPACE
#include "moc_qquickpointhandler_p.cpp"
diff --git a/src/quick/handlers/qquicksinglepointhandler.cpp b/src/quick/handlers/qquicksinglepointhandler.cpp
index c732a2562e..c7b642a7bc 100644
--- a/src/quick/handlers/qquicksinglepointhandler.cpp
+++ b/src/quick/handlers/qquicksinglepointhandler.cpp
@@ -171,7 +171,7 @@ QQuickHandlerPoint QQuickSinglePointHandler::point() const
/*!
\readonly
- \qmlproperty HandlerPoint QtQuick::SinglePointHandler::point
+ \qmlproperty handlerPoint QtQuick::SinglePointHandler::point
The event point currently being handled. When no point is currently being
handled, this object is reset to default values (all coordinates are 0).
diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp
index 0ec7c0ab65..96c67aa778 100644
--- a/src/quick/handlers/qquicktaphandler.cpp
+++ b/src/quick/handlers/qquicktaphandler.cpp
@@ -117,24 +117,14 @@ bool QQuickTapHandler::wantsEventPoint(const QPointerEvent *event, const QEventP
void QQuickTapHandler::handleEventPoint(QPointerEvent *event, QEventPoint &point)
{
+ const bool isTouch = QQuickDeliveryAgentPrivate::isTouchEvent(event);
switch (point.state()) {
case QEventPoint::Pressed:
setPressed(true, false, event, point);
break;
case QEventPoint::Released: {
- // If the point has an exclusive grabber Item, then if it got the grab by filtering (like Flickable does),
- // it's OK for DragHandler to react in spite of that. But in other cases, if an exclusive grab
- // still exists at the time of release, TapHandler should not react, because it would be redundant:
- // some other item is already reacting, i.e. acting as if it has been clicked or tapped.
- // So in that case we cancel the pressed state and do not emit tapped().
- bool nonFilteringExclusiveGrabber = false;
- if (auto g = qmlobject_cast<QQuickItem *>(event->exclusiveGrabber(point))) {
- if (!g->filtersChildMouseEvents())
- nonFilteringExclusiveGrabber = true;
- }
- if (QQuickDeliveryAgentPrivate::isTouchEvent(event) ||
- (static_cast<const QSinglePointEvent *>(event)->buttons() & acceptedButtons()) == Qt::NoButton)
- setPressed(false, nonFilteringExclusiveGrabber, event, point);
+ if (isTouch || (static_cast<const QSinglePointEvent *>(event)->buttons() & acceptedButtons()) == Qt::NoButton)
+ setPressed(false, false, event, point);
break;
}
default:
@@ -142,6 +132,11 @@ void QQuickTapHandler::handleEventPoint(QPointerEvent *event, QEventPoint &point
}
QQuickSinglePointHandler::handleEventPoint(event, point);
+
+ // If TapHandler only needs a passive grab, it should not block other items and handlers from reacting.
+ // If the point is accepted, QQuickItemPrivate::localizedTouchEvent() would skip it.
+ if (isTouch && m_gesturePolicy == DragThreshold)
+ point.setAccepted(false);
}
/*!
@@ -194,16 +189,41 @@ void QQuickTapHandler::timerEvent(QTimerEvent *event)
The \c gesturePolicy also affects grab behavior as described below.
- \value TapHandler.DragThreshold
- (the default value) The event point must not move significantly.
- If the mouse, finger or stylus moves past the system-wide drag
- threshold (QStyleHints::startDragDistance), the tap gesture is
- canceled, even if the button or finger is still pressed. This policy
- can be useful whenever TapHandler needs to cooperate with other
- input handlers (for example \l DragHandler) or event-handling Items
- (for example QtQuick Controls), because in this case TapHandler
- will not take the exclusive grab, but merely a
- \l {QPointerEvent::addPassiveGrabber()}{passive grab}.
+ \table
+ \header
+ \li Constant
+ \li Description
+ \row
+ \li \c TapHandler.DragThreshold
+ \image pointerHandlers/tapHandlerOverlappingButtons.webp
+ Grab on press: \e passive
+ \li (the default value) The \l eventPoint must not move significantly.
+ If the mouse, finger or stylus moves past the system-wide drag
+ threshold (QStyleHints::startDragDistance), the tap gesture is
+ canceled, even if the device or finger is still pressed. This policy
+ can be useful whenever TapHandler needs to cooperate with other
+ input handlers (for example \l DragHandler) or event-handling Items
+ (for example \l {Qt Quick Controls}), because in this case TapHandler
+ will not take the exclusive grab, but merely a
+ \l {QPointerEvent::addPassiveGrabber()}{passive grab}.
+ That is, \c DragThreshold is especially useful to \e augment
+ existing behavior: it reacts to tap/click/long-press even when
+ another item or handler is already reacting, perhaps even in a
+ different layer of the UI. The following snippet shows one
+ TapHandler as used in one component; but if we stack up two
+ instances of the component, you will see the handlers in both of them
+ react simultaneously when a press occurs over both of them, because
+ the passive grab does not stop event propagation:
+ \quotefromfile pointerHandlers/tapHandlerOverlappingButtons.qml
+ \skipto Item
+ \printuntil component Button
+ \skipto TapHandler
+ \printuntil }
+ \skipuntil Text {
+ \skipuntil }
+ \printuntil Button
+ \printuntil Button
+ \printuntil }
\value TapHandler.WithinBounds
If the event point leaves the bounds of the \c parent Item, the tap
@@ -212,31 +232,47 @@ void QQuickTapHandler::timerEvent(QTimerEvent *event)
press, but will release the grab as soon as the boundary constraint
is no longer satisfied.
- \value TapHandler.ReleaseWithinBounds
- At the time of release (the mouse button is released or the finger
- is lifted), if the event point is outside the bounds of the
- \c parent Item, a tap gesture is not recognized. This corresponds to
- typical behavior for button widgets: you can cancel a click by
- dragging outside the button, and you can also change your mind by
- dragging back inside the button before release. Note that it's
- necessary for TapHandler to take the
- \l {QPointerEvent::setExclusiveGrabber}{exclusive grab} on press
- and retain it until release in order to detect this gesture.
-
- \value TapHandler.DragWithinBounds
- On press, TapHandler takes the
- \l {QPointerEvent::setExclusiveGrabber}{exclusive grab}; after that,
- the event point can be dragged within the bounds of the \c parent
- item, while the \l timeHeld property keeps counting, and the
- \l longPressed() signal will be emitted regardless of drag distance.
- However, like \c WithinBounds, if the point leaves the bounds,
- the tap gesture is \l {PointerHandler::}{canceled()}, \l active()
- becomes \c false, and \l timeHeld stops counting. This is suitable
- for implementing press-drag-release components, such as menus, in
- which a single TapHandler detects press, \c timeHeld drives an
- "opening" animation, and then the user can drag to a menu item and
- release, while never leaving the bounds of the parent scene containing
- the menu. This value was added in Qt 6.3.
+ \row
+ \li \c TapHandler.ReleaseWithinBounds
+ \image pointerHandlers/tapHandlerButtonReleaseWithinBounds.webp
+ Grab on press: \e exclusive
+ \li At the time of release (the mouse button is released or the finger
+ is lifted), if the \l eventPoint is outside the bounds of the
+ \c parent Item, a tap gesture is not recognized. This corresponds to
+ typical behavior for button widgets: you can cancel a click by
+ dragging outside the button, and you can also change your mind by
+ dragging back inside the button before release. Note that it's
+ necessary for TapHandler to take the
+ \l {QPointerEvent::setExclusiveGrabber}{exclusive grab} on press
+ and retain it until release in order to detect this gesture.
+ \snippet pointerHandlers/tapHandlerButtonReleaseWithinBounds.qml 1
+
+ \row
+ \li \c TapHandler.DragWithinBounds
+ \image pointerHandlers/dragReleaseMenu.webp
+ Grab on press: \e exclusive
+ \li On press, TapHandler takes the
+ \l {QPointerEvent::setExclusiveGrabber}{exclusive grab}; after that,
+ the \l eventPoint can be dragged within the bounds of the \c parent
+ item, while the \l timeHeld property keeps counting, and the
+ \l longPressed() signal will be emitted regardless of drag distance.
+ However, like \c WithinBounds, if the point leaves the bounds,
+ the tap gesture is \l {PointerHandler::}{canceled()}, \l active()
+ becomes \c false, and \l timeHeld stops counting. This is suitable
+ for implementing press-drag-release components, such as menus, in
+ which a single TapHandler detects press, \c timeHeld drives an
+ "opening" animation, and then the user can drag to a menu item and
+ release, while never leaving the bounds of the parent scene containing
+ the menu. This value was added in Qt 6.3.
+ \snippet pointerHandlers/dragReleaseMenu.qml 1
+ \endtable
+
+ \note If you find that TapHandler is reacting in cases that conflict with
+ some other behavior, the first thing you should try is to think about which
+ \c gesturePolicy is appropriate. If you cannot fix it by changing \c gesturePolicy,
+ some cases are better served by adjusting \l {PointerHandler::}{grabPermissions},
+ either in this handler, or in another handler that should \e prevent TapHandler
+ from reacting.
*/
void QQuickTapHandler::setGesturePolicy(QQuickTapHandler::GesturePolicy gesturePolicy)
{
diff --git a/src/quick/handlers/qquickwheelhandler.cpp b/src/quick/handlers/qquickwheelhandler.cpp
index ced584b0ad..84a3a69405 100644
--- a/src/quick/handlers/qquickwheelhandler.cpp
+++ b/src/quick/handlers/qquickwheelhandler.cpp
@@ -55,7 +55,7 @@ QQuickWheelHandler::QQuickWheelHandler(QQuickItem *parent)
}
/*!
- \qmlproperty enum QtQuick::WheelHandler::orientation
+ \qmlproperty enumeration QtQuick::WheelHandler::orientation
Which wheel to react to. The default is \c Qt.Vertical.
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index a6d58fec2c..0eb4fe40d3 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -616,6 +616,10 @@ void QQuickCanvasItem::invalidateSceneGraph()
d->textureProvider = nullptr;
delete d->nodeTexture;
d->nodeTexture = nullptr;
+
+ // As we can expect(/hope) that the SG will be "good again", we can requestPaint ( which does 'markDirty(canvasWindow);' )
+ // Otherwise this Canvas will be "blank" when SG comes back
+ requestPaint();
}
void QQuickCanvasItem::schedulePolish()
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index d2e24a8b30..d053da4766 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -101,7 +101,7 @@ Q_QUICK_PRIVATE_EXPORT QColor qt_color_from_string(const QV4::Value &name)
QByteArray str = name.toQString().toUtf8();
char *p = str.data();
- int len = str.length();
+ int len = str.size();
//rgb/hsl color string has at least 7 characters
if (!p || len > 255 || len <= 7)
return QColor::fromString(p);
diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
index 3c18c68856..52ba4896ed 100644
--- a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
+++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
@@ -168,7 +168,7 @@ public:
inline void setLineDash(const QVector<qreal> &pattern)
{
commands << QQuickContext2D::LineDash;
- reals << pattern.length();
+ reals << pattern.size();
for (qreal r : pattern)
reals << r;
}
diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp
index 0dd95a9095..2dadae3ef7 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture.cpp
+++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp
@@ -113,7 +113,7 @@ bool QQuickContext2DTexture::setDirtyRect(const QRect &r)
{
bool doDirty = false;
if (m_tiledCanvas) {
- for (QQuickContext2DTile* t : qAsConst(m_tiles)) {
+ for (QQuickContext2DTile* t : std::as_const(m_tiles)) {
bool dirty = t->rect().intersected(r).isValid();
t->markDirty(dirty);
if (dirty)
@@ -197,7 +197,7 @@ void QQuickContext2DTexture::paint(QQuickContext2DCommandBuffer *ccb)
QRect tiledRegion = createTiles(m_canvasWindow.intersected(QRect(QPoint(0, 0), m_canvasSize)));
if (!tiledRegion.isEmpty()) {
QRect dirtyRect;
- for (QQuickContext2DTile* tile : qAsConst(m_tiles)) {
+ for (QQuickContext2DTile* tile : std::as_const(m_tiles)) {
if (tile->dirty()) {
if (dirtyRect.isEmpty())
dirtyRect = tile->rect();
@@ -208,7 +208,7 @@ void QQuickContext2DTexture::paint(QQuickContext2DCommandBuffer *ccb)
if (beginPainting()) {
QQuickContext2D::State oldState = m_state;
- for (QQuickContext2DTile* tile : qAsConst(m_tiles)) {
+ for (QQuickContext2DTile* tile : std::as_const(m_tiles)) {
if (tile->dirty()) {
ccb->replay(tile->createPainter(m_smooth, m_antialiasing), oldState, scaleFactor());
tile->drawFinished();
diff --git a/src/quick/items/qquickaccessibleattached.cpp b/src/quick/items/qquickaccessibleattached.cpp
index 45219dc69c..865fb8bf11 100644
--- a/src/quick/items/qquickaccessibleattached.cpp
+++ b/src/quick/items/qquickaccessibleattached.cpp
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
This property sets an accessible description.
Similar to the name it describes the item. The description
can be a little more verbose and tell what the item does,
- for example the functionallity of the button it describes.
+ for example the functionality of the button it describes.
*/
/*!
@@ -312,11 +312,33 @@ QQuickAccessibleAttached::QQuickAccessibleAttached(QObject *parent)
QAccessibleEvent ev(item(), QAccessible::ObjectCreated);
QAccessible::updateAccessibility(&ev);
- if (!parent->property("value").isNull()) {
- connect(parent, SIGNAL(valueChanged()), this, SLOT(valueChanged()));
- }
- if (!parent->property("cursorPosition").isNull()) {
- connect(parent, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged()));
+ if (const QMetaObject *pmo = parent->metaObject()) {
+ auto connectPropertyChangeSignal = [parent, pmo, this](
+ const char *propertyName, const char *signalName, int slotIndex)
+ {
+ // basically does this:
+ // if the parent has the property \a propertyName with the associated \a signalName:
+ // connect(parent, signalName, this, slotIndex)
+
+ // Note that we explicitly want to only connect to standard property/signal naming
+ // convention: "value" & "valueChanged"
+ // (e.g. avoid a compound property with e.g. a signal notifier named "updated()")
+ int idxProperty = pmo->indexOfProperty(propertyName);
+ if (idxProperty != -1) {
+ const QMetaProperty property = pmo->property(idxProperty);
+ const QMetaMethod signal = property.notifySignal();
+ if (signal.name() == signalName)
+ QMetaObject::connect(parent, signal.methodIndex(), this, slotIndex);
+ }
+ return;
+ };
+ const QMetaObject &smo = staticMetaObject;
+ static const int valueChangedIndex = smo.indexOfSlot("valueChanged()");
+ connectPropertyChangeSignal("value", "valueChanged", valueChangedIndex);
+
+ static const int cursorPositionChangedIndex = smo.indexOfSlot("cursorPositionChanged()");
+ connectPropertyChangeSignal("cursorPosition", "cursorPositionChanged",
+ cursorPositionChangedIndex);
}
if (!sigPress.isValid()) {
diff --git a/src/quick/items/qquickcolorgroup.cpp b/src/quick/items/qquickcolorgroup.cpp
index fd913aba7a..273ee31fa2 100644
--- a/src/quick/items/qquickcolorgroup.cpp
+++ b/src/quick/items/qquickcolorgroup.cpp
@@ -45,6 +45,8 @@ QT_BEGIN_NAMESPACE
base: "green"
}
\endcode
+
+ The \l Palette type exposes color groups for each QML item state.
*/
/*!
@@ -180,8 +182,6 @@ QT_BEGIN_NAMESPACE
Additional signal indicates that the current state of this color group
has been changed. Usually it means that one of the colors is changed.
-
- \sa Palette
*/
/*!
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index 4d54a28d8a..6c1f56de63 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -446,7 +446,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
\qmlattachedproperty stringlist QtQuick::Drag::mimeData
\since 5.2
- This property holds a map of mimeData that is used during startDrag.
+ This property holds a map from mime type to data that is used during startDrag.
+ The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
+ according to the mime type.
*/
QVariantMap QQuickDragAttached::mimeData() const
@@ -731,8 +733,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
QDrag *drag = new QDrag(source ? source : q);
QMimeData *mimeData = new QMimeData();
- for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
- mimeData->setData(it.key(), it.value().toString().toUtf8());
+ for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
+ if (it.value().typeId() == QMetaType::QByteArray)
+ mimeData->setData(it.key(), it.value().toByteArray());
+ else
+ mimeData->setData(it.key(), it.value().toString().toUtf8());
+ }
drag->setMimeData(mimeData);
if (pixmapLoader.isReady()) {
diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h
index 611ed5df8f..806dbc7602 100644
--- a/src/quick/items/qquickdrag_p.h
+++ b/src/quick/items/qquickdrag_p.h
@@ -72,9 +72,12 @@ public:
void grab(QQuickItem *item) { m_items.insert(new Item(item)); }
iterator release(iterator at) { Item *item = *at; at = at.erase(); delete item; return at; }
+ auto& ignoreList() { return m_ignoreDragItems; }
+
private:
ItemList m_items;
+ QVarLengthArray<QQuickItem *, 4> m_ignoreDragItems;
QObject *m_target;
};
diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp
index a553d758c5..1c865a6327 100644
--- a/src/quick/items/qquickdroparea.cpp
+++ b/src/quick/items/qquickdroparea.cpp
@@ -125,7 +125,7 @@ void QQuickDropArea::setKeys(const QStringList &keys)
d->keyRegExp = QRegularExpression();
} else {
QString pattern = QLatin1Char('(') + QRegularExpression::escape(keys.first());
- for (int i = 1; i < keys.count(); ++i)
+ for (int i = 1; i < keys.size(); ++i)
pattern += QLatin1Char('|') + QRegularExpression::escape(keys.at(i));
pattern += QLatin1Char(')');
d->keyRegExp = QRegularExpression(
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index b1d274cb98..fdb294cdfc 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -318,7 +318,7 @@ void QQuickFlickablePrivate::AxisData::updateVelocity()
}
}
-void QQuickFlickablePrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &)
+void QQuickFlickablePrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeom)
{
Q_Q(QQuickFlickable);
if (item == contentItem) {
@@ -327,8 +327,14 @@ void QQuickFlickablePrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometr
orient |= Qt::Horizontal;
if (change.yChange())
orient |= Qt::Vertical;
- if (orient)
+ if (orient) {
q->viewportMoved(orient);
+ const QPointF deltaMoved = item->position() - oldGeom.topLeft();
+ if (hData.contentPositionChangedExternallyDuringDrag)
+ hData.pressPos += deltaMoved.x();
+ if (vData.contentPositionChangedExternallyDuringDrag)
+ vData.pressPos += deltaMoved.y();
+ }
if (orient & Qt::Horizontal)
emit q->contentXChanged();
if (orient & Qt::Vertical)
@@ -711,7 +717,8 @@ void QQuickFlickablePrivate::updateBeginningEnd()
/*!
\qmlsignal QtQuick::Flickable::flickEnded()
- This signal is emitted when the view stops moving due to a flick.
+ This signal is emitted when the view stops moving after a flick
+ or a series of flicks.
*/
/*!
@@ -788,8 +795,11 @@ void QQuickFlickable::setContentX(qreal pos)
d->hData.vTime = d->timeline.time();
if (isMoving() || isFlicking())
movementEnding(true, false);
- if (!qFuzzyCompare(-pos, d->hData.move.value()))
+ if (!qFuzzyCompare(-pos, d->hData.move.value())) {
+ d->hData.contentPositionChangedExternallyDuringDrag = d->hData.dragging;
d->hData.move.setValue(-pos);
+ d->hData.contentPositionChangedExternallyDuringDrag = false;
+ }
}
qreal QQuickFlickable::contentY() const
@@ -806,8 +816,11 @@ void QQuickFlickable::setContentY(qreal pos)
d->vData.vTime = d->timeline.time();
if (isMoving() || isFlicking())
movementEnding(false, true);
- if (!qFuzzyCompare(-pos, d->vData.move.value()))
+ if (!qFuzzyCompare(-pos, d->vData.move.value())) {
+ d->vData.contentPositionChangedExternallyDuringDrag = d->vData.dragging;
d->vData.move.setValue(-pos);
+ d->vData.contentPositionChangedExternallyDuringDrag = false;
+ }
}
/*!
@@ -1103,7 +1116,9 @@ void QQuickFlickablePrivate::maybeBeginDrag(qint64 currentTimestamp, const QPoin
pressPos = pressPosn;
hData.pressPos = hData.move.value();
vData.pressPos = vData.move.value();
- bool wasFlicking = hData.flicking || vData.flicking;
+ const bool wasFlicking = hData.flicking || vData.flicking;
+ hData.flickingWhenDragBegan = hData.flicking;
+ vData.flickingWhenDragBegan = vData.flicking;
if (hData.flicking) {
hData.flicking = false;
emit q->flickingHorizontallyChanged();
@@ -1434,8 +1449,15 @@ void QQuickFlickablePrivate::handleReleaseEvent(QPointerEvent *event)
fixupX();
flickingStarted(flickedHorizontally, flickedVertically);
- if (!isViewMoving())
+ if (!isViewMoving()) {
q->movementEnding();
+ } else {
+ if (flickedVertically)
+ vMoved = true;
+ if (flickedHorizontally)
+ hMoved = true;
+ q->movementStarting();
+ }
}
void QQuickFlickable::mousePressEvent(QMouseEvent *event)
@@ -2515,6 +2537,18 @@ bool QQuickFlickable::filterPointerEvent(QQuickItem *receiver, QPointerEvent *ev
if (isTouch && static_cast<QTouchEvent *>(event)->touchPointStates().testFlag(QEventPoint::State::Pressed))
d->stealMouse = false;
const auto &firstPoint = event->points().first();
+
+ if (event->pointCount() == 1 && event->exclusiveGrabber(firstPoint) == this) {
+ // We have an exclusive grab (since we're e.g dragging), but at the same time, we have
+ // a child with a passive grab (which is why this filter is being called). And because
+ // of that, we end up getting the same pointer events twice; First in our own event
+ // handlers (because of the grab), then once more in here, since we filter the child.
+ // To avoid processing the event twice (e.g avoid calling handleReleaseEvent once more
+ // from below), we mark the event as filtered, and simply return.
+ event->setAccepted(true);
+ return true;
+ }
+
QPointF localPos = mapFromScene(firstPoint.scenePosition());
bool receiverDisabled = receiver && !receiver->isEnabled();
bool stealThisEvent = d->stealMouse;
@@ -2884,6 +2918,12 @@ void QQuickFlickable::movementStarting()
if (!wasMoving && (d->hData.moving || d->vData.moving)) {
emit movingChanged();
emit movementStarted();
+#if QT_CONFIG(accessibility)
+ if (QAccessible::isActive()) {
+ QAccessibleEvent ev(this, QAccessible::ScrollingStart);
+ QAccessible::updateAccessibility(&ev);
+ }
+#endif
}
}
@@ -2897,7 +2937,7 @@ void QQuickFlickable::movementEnding(bool hMovementEnding, bool vMovementEnding)
Q_D(QQuickFlickable);
// emit flicking signals
- bool wasFlicking = d->hData.flicking || d->vData.flicking;
+ const bool wasFlicking = d->hData.flicking || d->vData.flicking;
if (hMovementEnding && d->hData.flicking) {
d->hData.flicking = false;
emit flickingHorizontallyChanged();
@@ -2909,6 +2949,10 @@ void QQuickFlickable::movementEnding(bool hMovementEnding, bool vMovementEnding)
if (wasFlicking && (!d->hData.flicking || !d->vData.flicking)) {
emit flickingChanged();
emit flickEnded();
+ } else if (d->hData.flickingWhenDragBegan || d->vData.flickingWhenDragBegan) {
+ d->hData.flickingWhenDragBegan = !hMovementEnding;
+ d->vData.flickingWhenDragBegan = !vMovementEnding;
+ emit flickEnded();
}
// emit moving signals
@@ -2928,6 +2972,12 @@ void QQuickFlickable::movementEnding(bool hMovementEnding, bool vMovementEnding)
if (wasMoving && !isMoving()) {
emit movingChanged();
emit movementEnded();
+#if QT_CONFIG(accessibility)
+ if (QAccessible::isActive()) {
+ QAccessibleEvent ev(this, QAccessible::ScrollingEnd);
+ QAccessible::updateAccessibility(&ev);
+ }
+#endif
}
if (hMovementEnding) {
diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h
index ed7042ab90..04d27c0b8e 100644
--- a/src/quick/items/qquickflickable_p_p.h
+++ b/src/quick/items/qquickflickable_p_p.h
@@ -71,8 +71,9 @@ public:
, smoothVelocity(fp), atEnd(false), atBeginning(true)
, transitionToSet(false)
, fixingUp(false), inOvershoot(false), inRebound(false), moving(false), flicking(false)
- , dragging(false), extentsChanged(false)
+ , flickingWhenDragBegan(false), dragging(false), extentsChanged(false)
, explicitValue(false), minExtentDirty(true), maxExtentDirty(true)
+ , contentPositionChangedExternallyDuringDrag(false)
, unused(0)
{}
@@ -83,6 +84,7 @@ public:
dragStartOffset = 0;
fixingUp = false;
inOvershoot = false;
+ contentPositionChangedExternallyDuringDrag = false;
}
void markExtentsDirty() {
@@ -120,20 +122,22 @@ public:
int vTime;
QQuickFlickablePrivate::Velocity smoothVelocity;
QPODVector<qreal,10> velocityBuffer;
- bool atEnd : 1;
- bool atBeginning : 1;
- bool transitionToSet : 1;
- bool fixingUp : 1;
- bool inOvershoot : 1;
- bool inRebound : 1;
- bool moving : 1;
- bool flicking : 1;
- bool dragging : 1;
- bool extentsChanged : 1;
- bool explicitValue : 1;
- mutable bool minExtentDirty : 1;
- mutable bool maxExtentDirty : 1;
- uint unused : 19;
+ uint atEnd : 1;
+ uint atBeginning : 1;
+ uint transitionToSet : 1;
+ uint fixingUp : 1;
+ uint inOvershoot : 1;
+ uint inRebound : 1;
+ uint moving : 1;
+ uint flicking : 1;
+ uint flickingWhenDragBegan : 1;
+ uint dragging : 1;
+ uint extentsChanged : 1;
+ uint explicitValue : 1;
+ mutable uint minExtentDirty : 1;
+ mutable uint maxExtentDirty : 1;
+ uint contentPositionChangedExternallyDuringDrag : 1;
+ uint unused : 17;
};
bool flickX(qreal velocity);
diff --git a/src/quick/items/qquickflipable.cpp b/src/quick/items/qquickflipable.cpp
index d599618834..4ea085bb0c 100644
--- a/src/quick/items/qquickflipable.cpp
+++ b/src/quick/items/qquickflipable.cpp
@@ -3,7 +3,7 @@
#include "qquickflipable_p.h"
#include "qquickitem_p.h"
-
+#include "qquicktranslate_p.h"
#include <QtQml/qqmlinfo.h>
@@ -201,9 +201,20 @@ void QQuickFlipable::updatePolish()
d->updateSide();
}
-// determination on the currently visible side of the flipable
-// has to be done on the complete scene transform to give
-// correct results.
+/*! \internal
+ Flipable must use the complete scene transform to correctly determine the
+ currently visible side.
+
+ It must also be independent of camera distance, in case the contents are
+ too wide: for rotation transforms we simply call QMatrix4x4::rotate(),
+ whereas QQuickRotation::applyTo(QMatrix4x4*) calls
+ QMatrix4x4::projectedRotate() which by default assumes the camera distance
+ is 1024 virtual pixels. So for example if contents inside Flipable are to
+ be flipped around the y axis, and are wider than 1024*2, some of the
+ rendering goes behind the "camera". That's expected for rendering (since we
+ didn't provide API to change camera distance), but not ok for deciding when
+ to flip.
+*/
void QQuickFlipablePrivate::updateSide()
{
Q_Q(QQuickFlipable);
@@ -213,8 +224,39 @@ void QQuickFlipablePrivate::updateSide()
sideDirty = false;
- QTransform sceneTransform;
- itemToParentTransform(sceneTransform);
+ QMatrix4x4 sceneTransform;
+
+ const qreal tx = x.value();
+ const qreal ty = y.value();
+ if (!qFuzzyIsNull(tx) || !qFuzzyIsNull(ty))
+ sceneTransform.translate(tx, ty);
+
+ for (const auto *transform : std::as_const(transforms)) {
+ if (const auto *rot = qobject_cast<const QQuickRotation *>(transform)) {
+ // rotation is a special case: we want to call rotate() instead of projectedRotate()
+ const auto angle = rot->angle();
+ const auto axis = rot->axis();
+ if (!(qFuzzyIsNull(angle) || axis.isNull())) {
+ sceneTransform.translate(rot->origin());
+ sceneTransform.rotate(angle, axis.x(), axis.y(), axis.z());
+ sceneTransform.translate(-rot->origin());
+ }
+ } else {
+ transform->applyTo(&sceneTransform);
+ }
+ }
+
+ const bool hasRotation = !qFuzzyIsNull(rotation());
+ const bool hasScale = !qFuzzyCompare(scale(), 1);
+ if (hasScale || hasRotation) {
+ QPointF tp = computeTransformOrigin();
+ sceneTransform.translate(tp.x(), tp.y());
+ if (hasScale)
+ sceneTransform.scale(scale(), scale());
+ if (hasRotation)
+ sceneTransform.rotate(rotation(), 0, 0, 1);
+ sceneTransform.translate(-tp.x(), -tp.y());
+ }
QPointF p1(0, 0);
QPointF p2(1, 0);
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index d3dfe51d11..7f45d45708 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -462,7 +462,7 @@ bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal
{
qreal colPos = colPosAt(visibleIndex);
qreal rowPos = rowPosAt(visibleIndex);
- if (visibleItems.count()) {
+ if (visibleItems.size()) {
FxGridItemSG *lastItem = static_cast<FxGridItemSG*>(visibleItems.constLast());
rowPos = lastItem->rowPos();
int colNum = qFloor((lastItem->colPos()+colSize()/2) / colSize());
@@ -476,7 +476,7 @@ bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal
int modelIndex = findLastVisibleIndex();
modelIndex = modelIndex < 0 ? visibleIndex : modelIndex + 1;
- if (visibleItems.count() && (bufferFrom > rowPos + rowSize()*2
+ if (visibleItems.size() && (bufferFrom > rowPos + rowSize()*2
|| bufferTo < rowPosAt(visibleIndex) - rowSize())) {
// We've jumped more than a page. Estimate which items are now
// visible and fill from there.
@@ -520,7 +520,7 @@ bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal
return changed;
// Find first column
- if (visibleItems.count()) {
+ if (visibleItems.size()) {
FxGridItemSG *firstItem = static_cast<FxGridItemSG*>(visibleItems.constFirst());
rowPos = firstItem->rowPos();
colPos = firstItem->colPos();
@@ -569,7 +569,7 @@ bool QQuickGridViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal buffer
FxGridItemSG *item = nullptr;
bool changed = false;
- while (visibleItems.count() > 1
+ while (visibleItems.size() > 1
&& (item = static_cast<FxGridItemSG*>(visibleItems.constFirst()))
&& item->rowPos()+rowSize()-1 < bufferFrom - rowSize()*(item->colPos()/colSize()+1)/(columns+1)) {
if (item->attached->delayRemove())
@@ -581,12 +581,12 @@ bool QQuickGridViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal buffer
removeItem(item);
changed = true;
}
- while (visibleItems.count() > 1
+ while (visibleItems.size() > 1
&& (item = static_cast<FxGridItemSG*>(visibleItems.constLast()))
&& item->rowPos() > bufferTo + rowSize()*(columns - item->colPos()/colSize())/(columns+1)) {
if (item->attached->delayRemove())
break;
- qCDebug(lcItemViewDelegateLifecycle) << "refill: remove last" << visibleIndex+visibleItems.count()-1;
+ qCDebug(lcItemViewDelegateLifecycle) << "refill: remove last" << visibleIndex+visibleItems.size()-1;
visibleItems.removeLast();
removeItem(item);
changed = true;
@@ -603,7 +603,7 @@ void QQuickGridViewPrivate::updateViewport()
void QQuickGridViewPrivate::layoutVisibleItems(int fromModelIndex)
{
- if (visibleItems.count()) {
+ if (visibleItems.size()) {
const qreal from = isContentFlowReversed() ? -position()-displayMarginBeginning-size() : position()-displayMarginBeginning;
const qreal to = isContentFlowReversed() ? -position()+displayMarginEnd : position()+size()+displayMarginEnd;
@@ -616,7 +616,7 @@ void QQuickGridViewPrivate::layoutVisibleItems(int fromModelIndex)
firstItem->setPosition(colPos, rowPos);
}
firstItem->setVisible(firstItem->rowPos() + rowSize() >= from && firstItem->rowPos() <= to);
- for (int i = 1; i < visibleItems.count(); ++i) {
+ for (int i = 1; i < visibleItems.size(); ++i) {
FxGridItemSG *item = static_cast<FxGridItemSG*>(visibleItems.at(i));
if (++col >= columns) {
col = 0;
@@ -669,7 +669,7 @@ void QQuickGridViewPrivate::resetFirstItemPosition(qreal pos)
void QQuickGridViewPrivate::adjustFirstItem(qreal forwards, qreal backwards, int changeBeforeVisible)
{
- if (!visibleItems.count())
+ if (!visibleItems.size())
return;
int moveCount = (forwards - backwards) / rowSize();
@@ -802,7 +802,7 @@ void QQuickGridViewPrivate::updateFooter()
else
rowOffset += gridItem->item->height() - cellHeight;
}
- if (visibleItems.count()) {
+ if (visibleItems.size()) {
qreal endPos = lastPosition();
if (findLastVisibleIndex() == model->count()-1) {
gridItem->setPosition(colOffset, endPos + rowOffset);
@@ -855,7 +855,7 @@ void QQuickGridViewPrivate::updateHeader()
else
rowOffset += gridItem->item->height() - cellHeight;
}
- if (visibleItems.count()) {
+ if (visibleItems.size()) {
qreal startPos = originPosition();
if (visibleIndex == 0) {
gridItem->setPosition(colOffset, startPos + rowOffset);
@@ -2066,7 +2066,7 @@ void QQuickGridView::viewportMoved(Qt::Orientations orient)
// Set visibility of items to eliminate cost of items outside the visible area.
qreal from = d->isContentFlowReversed() ? -d->position()-d->displayMarginBeginning-d->size() : d->position()-d->displayMarginBeginning;
qreal to = d->isContentFlowReversed() ? -d->position()+d->displayMarginEnd : d->position()+d->size()+d->displayMarginEnd;
- for (FxViewItem *item : qAsConst(d->visibleItems)) {
+ for (FxViewItem *item : std::as_const(d->visibleItems)) {
FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(item);
QQuickItemPrivate::get(gridItem->item)->setCulled(gridItem->rowPos() + d->rowSize() < from || gridItem->rowPos() > to);
}
@@ -2359,20 +2359,20 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
int modelIndex = change.index;
int count = change.count;
- int index = visibleItems.count() ? mapFromModel(modelIndex) : 0;
+ int index = visibleItems.size() ? mapFromModel(modelIndex) : 0;
if (index < 0) {
- int i = visibleItems.count() - 1;
+ int i = visibleItems.size() - 1;
while (i > 0 && visibleItems.at(i)->index == -1)
--i;
if (visibleItems.at(i)->index + 1 == modelIndex) {
// Special case of appending an item to the model.
- index = visibleItems.count();
+ index = visibleItems.size();
} else {
if (modelIndex <= visibleIndex) {
// Insert before visible items
visibleIndex += count;
- for (FxViewItem *item : qAsConst(visibleItems)) {
+ for (FxViewItem *item : std::as_const(visibleItems)) {
if (item->index != -1 && item->index >= modelIndex)
item->index += count;
}
@@ -2385,8 +2385,8 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
qreal colPos = 0;
qreal rowPos = 0;
int colNum = 0;
- if (visibleItems.count()) {
- if (index < visibleItems.count()) {
+ if (visibleItems.size()) {
+ if (index < visibleItems.size()) {
FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(visibleItems.at(index));
colPos = gridItem->colPos();
rowPos = gridItem->rowPos();
@@ -2405,7 +2405,7 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
}
// Update the indexes of the following visible items.
- for (FxViewItem *item : qAsConst(visibleItems)) {
+ for (FxViewItem *item : std::as_const(visibleItems)) {
if (item->index != -1 && item->index >= modelIndex) {
item->index += count;
if (change.isMove())
@@ -2415,7 +2415,7 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
}
}
- int prevVisibleCount = visibleItems.count();
+ int prevVisibleCount = visibleItems.size();
if (insertResult->visiblePos.isValid() && rowPos < insertResult->visiblePos) {
// Insert items before the visible item.
int insertionIdx = index;
@@ -2464,7 +2464,7 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
// of the index shift/update done before the insertion just above.
// Find if there is any...
int firstOkIdx = -1;
- for (int i = 0; i <= insertionIdx && i < visibleItems.count() - 1; i++) {
+ for (int i = 0; i <= insertionIdx && i < visibleItems.size() - 1; i++) {
if (visibleItems.at(i)->index + 1 != visibleItems.at(i + 1)->index) {
firstOkIdx = i + 1;
break;
@@ -2520,7 +2520,7 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
updateVisibleIndex();
- return visibleItems.count() > prevVisibleCount;
+ return visibleItems.size() > prevVisibleCount;
}
void QQuickGridViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult)
@@ -2529,7 +2529,7 @@ void QQuickGridViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
return;
int markerItemIndex = -1;
- for (int i=0; i<visibleItems.count(); i++) {
+ for (int i=0; i<visibleItems.size(); i++) {
if (visibleItems.at(i)->index == afterModelIndex) {
markerItemIndex = i;
break;
@@ -2548,7 +2548,7 @@ void QQuickGridViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
countItemsRemoved -= removalResult.countChangeAfterVisibleItems;
- for (int i=markerItemIndex+1; i<visibleItems.count(); i++) {
+ for (int i=markerItemIndex+1; i<visibleItems.size(); i++) {
FxGridItemSG *gridItem = static_cast<FxGridItemSG *>(visibleItems.at(i));
if (gridItem->position() >= viewEndPos)
break;
diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp
index f10446b7b5..78dfecc42a 100644
--- a/src/quick/items/qquickimagebase.cpp
+++ b/src/quick/items/qquickimagebase.cpp
@@ -291,8 +291,10 @@ void QQuickImageBase::loadPixmap(const QUrl &url, LoadPixmapOptions loadOptions)
const qreal targetDevicePixelRatio = (window() ? window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio());
d->devicePixelRatio = 1.0;
bool updatedDevicePixelRatio = false;
- if (d->sourcesize.isValid() || isScalableImageFormat(d->url))
+ if (d->sourcesize.isValid()
+ || (isScalableImageFormat(d->url) && d->url.scheme() != QLatin1String("image"))) {
updatedDevicePixelRatio = d->updateDevicePixelRatio(targetDevicePixelRatio);
+ }
if (!updatedDevicePixelRatio) {
// (possible) local file: loadUrl and d->devicePixelRatio will be modified if
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index dc1386fff9..b9f757dd78 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -61,6 +61,10 @@ Q_DECLARE_LOGGING_CATEGORY(lcPtr)
Q_DECLARE_LOGGING_CATEGORY(lcTransient)
Q_LOGGING_CATEGORY(lcHandlerParent, "qt.quick.handler.parent")
Q_LOGGING_CATEGORY(lcVP, "qt.quick.viewport")
+Q_LOGGING_CATEGORY(lcChangeListeners, "qt.quick.item.changelisteners")
+
+// after 100ms, a mouse/non-mouse cursor conflict is resolved in favor of the mouse handler
+static const quint64 kCursorOverrideTimeout = 100;
void debugFocusTree(QQuickItem *item, QQuickItem *scope = nullptr, int depth = 1)
{
@@ -319,6 +323,8 @@ void QQuickItemKeyFilter::shortcutOverride(QKeyEvent *event)
{
if (m_next)
m_next->shortcutOverride(event);
+ else
+ event->ignore();
}
void QQuickItemKeyFilter::componentComplete()
@@ -2614,6 +2620,12 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
\e {QObject parent}. An item's visual parent may not necessarily be the
same as its object parent. See \l {Concepts - Visual Parent in Qt Quick}
for more details.
+
+ \note The notification signal for this property gets emitted during destruction
+ of the visual parent. C++ signal handlers cannot assume that items in the
+ visual parent hierarchy are still fully constructed. Use \l qobject_cast to
+ verify that items in the parent hierarchy can be used safely as the expected
+ type.
*/
QQuickItem *QQuickItem::parentItem() const
{
@@ -3362,7 +3374,7 @@ void QQuickItemPrivate::resources_clear(QQmlListProperty<QObject> *prop)
QQuickItem *quickItem = static_cast<QQuickItem *>(prop->object);
QQuickItemPrivate *quickItemPrivate = QQuickItemPrivate::get(quickItem);
if (quickItemPrivate->extra.isAllocated()) {//If extra is not allocated resources is empty.
- for (QObject *object : qAsConst(quickItemPrivate->extra->resourcesList)) {
+ for (QObject *object : std::as_const(quickItemPrivate->extra->resourcesList)) {
qmlobject_disconnect(object, QObject, SIGNAL(destroyed(QObject*)),
quickItem, QQuickItem, SLOT(_q_resourceObjectDeleted(QObject*)));
}
@@ -3890,9 +3902,23 @@ void QQuickItem::updatePolish()
{
}
+#define PRINT_LISTENERS() \
+do { \
+ qDebug().nospace() << q_func() << " (" << this \
+ << ") now has the following listeners:"; \
+ for (const auto &listener : std::as_const(changeListeners)) { \
+ const auto objectPrivate = dynamic_cast<QObjectPrivate*>(listener.listener); \
+ qDebug().nospace() << "- " << listener << " (QObject: " << (objectPrivate ? objectPrivate->q_func() : nullptr) << ")"; \
+ } \
+} \
+while (false)
+
void QQuickItemPrivate::addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types)
{
changeListeners.append(ChangeListener(listener, types));
+
+ if (lcChangeListeners().isDebugEnabled())
+ PRINT_LISTENERS();
}
void QQuickItemPrivate::updateOrAddItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types)
@@ -3903,12 +3929,18 @@ void QQuickItemPrivate::updateOrAddItemChangeListener(QQuickItemChangeListener *
changeListeners[index].types = changeListener.types;
else
changeListeners.append(changeListener);
+
+ if (lcChangeListeners().isDebugEnabled())
+ PRINT_LISTENERS();
}
void QQuickItemPrivate::removeItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types)
{
ChangeListener change(listener, types);
changeListeners.removeOne(change);
+
+ if (lcChangeListeners().isDebugEnabled())
+ PRINT_LISTENERS();
}
void QQuickItemPrivate::updateOrAddGeometryChangeListener(QQuickItemChangeListener *listener,
@@ -3920,6 +3952,9 @@ void QQuickItemPrivate::updateOrAddGeometryChangeListener(QQuickItemChangeListen
changeListeners[index].gTypes = change.gTypes; //we may have different GeometryChangeTypes
else
changeListeners.append(change);
+
+ if (lcChangeListeners().isDebugEnabled())
+ PRINT_LISTENERS();
}
void QQuickItemPrivate::updateOrRemoveGeometryChangeListener(QQuickItemChangeListener *listener,
@@ -3933,6 +3968,9 @@ void QQuickItemPrivate::updateOrRemoveGeometryChangeListener(QQuickItemChangeLis
if (index > -1)
changeListeners[index].gTypes = change.gTypes; //we may have different GeometryChangeTypes
}
+
+ if (lcChangeListeners().isDebugEnabled())
+ PRINT_LISTENERS();
}
/*!
@@ -5192,6 +5230,13 @@ void QQuickItem::componentComplete()
d->addToDirtyList();
QQuickWindowPrivate::get(d->window)->dirtyItem(this);
}
+
+#if QT_CONFIG(accessibility)
+ if (d->isAccessible && d->effectiveVisible) {
+ QAccessibleEvent ev(this, QAccessible::ObjectShow);
+ QAccessible::updateAccessibility(&ev);
+ }
+#endif
}
QQuickStateGroup *QQuickItemPrivate::_states()
@@ -5477,9 +5522,10 @@ void QQuickItemPrivate::deliverInputMethodEvent(QInputMethodEvent *e)
void QQuickItemPrivate::deliverShortcutOverrideEvent(QKeyEvent *event)
{
- if (extra.isAllocated() && extra->keyHandler) {
+ if (extra.isAllocated() && extra->keyHandler)
extra->keyHandler->shortcutOverride(event);
- }
+ else
+ event->ignore();
}
bool QQuickItemPrivate::anyPointerHandlerWants(const QPointerEvent *event, const QEventPoint &point) const
@@ -5496,8 +5542,8 @@ bool QQuickItemPrivate::anyPointerHandlerWants(const QPointerEvent *event, const
/*!
\internal
Deliver the \a event to all this item's PointerHandlers, but skip
- HoverHandlers if the event is a QMouseEvent (they are visited in
- QQuickDeliveryAgentPrivate::deliverHoverEventToItem()), and skip handlers
+ HoverHandlers if the event is a QMouseEvent or QWheelEvent (they are visited
+ in QQuickDeliveryAgentPrivate::deliverHoverEventToItem()), and skip handlers
that are in QQuickPointerHandlerPrivate::deviceDeliveryTargets().
If \a avoidGrabbers is true, also skip delivery to any handler that
is exclusively or passively grabbing any point within \a event
@@ -5509,7 +5555,7 @@ bool QQuickItemPrivate::handlePointerEvent(QPointerEvent *event, bool avoidGrabb
if (extra.isAllocated()) {
for (QQuickPointerHandler *handler : extra->pointerHandlers) {
bool avoidThisHandler = false;
- if (QQuickDeliveryAgentPrivate::isMouseEvent(event) &&
+ if (QQuickDeliveryAgentPrivate::isMouseOrWheelEvent(event) &&
qmlobject_cast<const QQuickHoverHandler *>(handler)) {
avoidThisHandler = true;
} else if (avoidGrabbers) {
@@ -6247,6 +6293,12 @@ void QQuickItem::setOpacity(qreal newOpacity)
the parent's \c visible property. It does not change, for example, if this
item moves off-screen, or if the \l opacity changes to 0.
+ \note The notification signal for this property gets emitted during destruction
+ of the visual parent. C++ signal handlers cannot assume that items in the
+ visual parent hierarchy are still fully constructed. Use \l qobject_cast to
+ verify that items in the parent hierarchy can be used safely as the expected
+ type.
+
\sa opacity, enabled
*/
bool QQuickItem::isVisible() const
@@ -6305,6 +6357,15 @@ void QQuickItem::setVisible(bool v)
Setting this property to \c false automatically causes \l activeFocus to be
set to \c false, and this item will longer receive keyboard events.
+ \note Hover events are enabled separately by \l setAcceptHoverEvents().
+ Thus, a disabled item can continue to receive hover events, even when this
+ property is \c false. This makes it possible to show informational feedback
+ (such as \l ToolTip) even when an interactive item is disabled.
+ The same is also true for any \l {HoverHandlers}{QQuickHoverHandler}
+ added as children of the item. A HoverHandler can, however, be
+ \l{disabled}{QQuickHoverHandler::enabled} explicitly, or for example
+ be bound to the \c enabled state of the item.
+
\sa visible
*/
bool QQuickItem::isEnabled() const
@@ -7788,6 +7849,10 @@ void QQuickItem::setAcceptHoverEvents(bool enabled)
Q_D(QQuickItem);
d->hoverEnabled = enabled;
d->setHasHoverInChild(enabled);
+ // The DA needs to resolve which items and handlers should now be hovered or unhovered.
+ // Marking this item dirty ensures that flushFrameSynchronousEvents() will be called from the render loop,
+ // even if this change is not in response to a mouse event and no item has already marked itself dirty.
+ d->dirty(QQuickItemPrivate::Content);
}
/*!
@@ -7830,7 +7895,7 @@ void QQuickItemPrivate::setHasCursorInChild(bool hc)
if (!hc && subtreeCursorEnabled) {
if (hasCursor)
return; // nope! sorry, I have a cursor myself
- for (QQuickItem *otherChild : qAsConst(childItems)) {
+ for (QQuickItem *otherChild : std::as_const(childItems)) {
QQuickItemPrivate *otherChildPrivate = QQuickItemPrivate::get(otherChild);
if (otherChildPrivate->subtreeCursorEnabled || otherChildPrivate->hasCursor)
return; // nope! sorry, something else wants it kept on.
@@ -7857,11 +7922,14 @@ void QQuickItemPrivate::setHasHoverInChild(bool hasHover)
if (!hasHover && subtreeHoverEnabled) {
if (hoverEnabled)
return; // nope! sorry, I need hover myself
- for (QQuickItem *otherChild : qAsConst(childItems)) {
+ if (hasEnabledHoverHandlers())
+ return; // nope! sorry, this item has enabled HoverHandlers
+
+ for (QQuickItem *otherChild : std::as_const(childItems)) {
QQuickItemPrivate *otherChildPrivate = QQuickItemPrivate::get(otherChild);
if (otherChildPrivate->subtreeHoverEnabled || otherChildPrivate->hoverEnabled)
return; // nope! sorry, something else wants it kept on.
- if (otherChildPrivate->hasHoverHandlers())
+ if (otherChildPrivate->hasEnabledHoverHandlers())
return; // nope! sorry, we have pointer handlers which are interested.
}
}
@@ -7910,6 +7978,7 @@ void QQuickItem::setCursor(const QCursor &cursor)
Q_D(QQuickItem);
Qt::CursorShape oldShape = d->extra.isAllocated() ? d->extra->cursor.shape() : Qt::ArrowCursor;
+ qCDebug(lcHoverTrace) << oldShape << "->" << cursor.shape();
if (oldShape != cursor.shape() || oldShape >= Qt::LastCursor || cursor.shape() >= Qt::LastCursor) {
d->extra.value().cursor = cursor;
@@ -7946,6 +8015,7 @@ void QQuickItem::setCursor(const QCursor &cursor)
void QQuickItem::unsetCursor()
{
Q_D(QQuickItem);
+ qCDebug(lcHoverTrace) << "clearing cursor";
if (!d->hasCursor)
return;
d->hasCursor = false;
@@ -7997,27 +8067,82 @@ QCursor QQuickItemPrivate::effectiveCursor(const QQuickPointerHandler *handler)
Returns the Pointer Handler that is currently attempting to set the cursor shape,
or null if there is no such handler.
+ If there are multiple handlers attempting to set the cursor:
+ \list
+ \li an active handler has the highest priority (e.g. a DragHandler being dragged)
+ \li any HoverHandler that is reacting to a non-mouse device has priority for
+ kCursorOverrideTimeout ms (a tablet stylus is jittery so that's enough)
+ \li otherwise a HoverHandler that is reacting to the mouse, if any
+ \endlist
+
+ Within each category, if there are multiple handlers, the last-added one wins
+ (the one that is declared at the bottom wins, because users may intuitively
+ think it's "on top" even though there is no Z-order; or, one that is added
+ in a specific use case overrides an imported component).
+
\sa QtQuick::PointerHandler::cursor
*/
QQuickPointerHandler *QQuickItemPrivate::effectiveCursorHandler() const
{
if (!hasPointerHandlers())
return nullptr;
- QQuickPointerHandler *retHoverHandler = nullptr;
+ QQuickPointerHandler* activeHandler = nullptr;
+ QQuickPointerHandler* mouseHandler = nullptr;
+ QQuickPointerHandler* nonMouseHandler = nullptr;
for (QQuickPointerHandler *h : extra->pointerHandlers) {
if (!h->isCursorShapeExplicitlySet())
continue;
QQuickHoverHandler *hoverHandler = qmlobject_cast<QQuickHoverHandler *>(h);
- // For now, we don't expect multiple hover handlers in one Item, so we choose the first one found;
- // but a future use case could be to have different cursors for different tablet stylus devices.
- // In that case, this function needs more information: which device did the event come from.
- // TODO Qt 6: add QPointerDevice* as argument to this function? (it doesn't exist yet in Qt 5)
- if (!retHoverHandler && hoverHandler)
- retHoverHandler = hoverHandler;
+ // Prioritize any HoverHandler that is reacting to a non-mouse device.
+ // Otherwise, choose the first hovered handler that is found.
+ // TODO maybe: there was an idea to add QPointerDevice* as argument to this function
+ // and check the device type, but why? HoverHandler already does that.
+ if (!activeHandler && hoverHandler && hoverHandler->isHovered()) {
+ qCDebug(lcHoverTrace) << hoverHandler << hoverHandler->acceptedDevices() << "wants to set cursor" << hoverHandler->cursorShape();
+ if (hoverHandler->acceptedDevices().testFlag(QPointingDevice::DeviceType::Mouse)) {
+ // If there's a conflict, the last-added HoverHandler wins. Maybe the user is overriding a default...
+ if (mouseHandler && mouseHandler->cursorShape() != hoverHandler->cursorShape()) {
+ qCDebug(lcHoverTrace) << "mouse cursor conflict:" << mouseHandler << "wants" << mouseHandler->cursorShape()
+ << "but" << hoverHandler << "wants" << hoverHandler->cursorShape();
+ }
+ mouseHandler = hoverHandler;
+ } else {
+ // If there's a conflict, the last-added HoverHandler wins.
+ if (nonMouseHandler && nonMouseHandler->cursorShape() != hoverHandler->cursorShape()) {
+ qCDebug(lcHoverTrace) << "non-mouse cursor conflict:" << nonMouseHandler << "wants" << nonMouseHandler->cursorShape()
+ << "but" << hoverHandler << "wants" << hoverHandler->cursorShape();
+ }
+ nonMouseHandler = hoverHandler;
+ }
+ }
if (!hoverHandler && h->active())
- return h;
+ activeHandler = h;
+ }
+ if (activeHandler) {
+ qCDebug(lcHoverTrace) << "active handler choosing cursor" << activeHandler << activeHandler->cursorShape();
+ return activeHandler;
+ }
+ // Mouse events are often synthetic; so if a HoverHandler for a non-mouse device wanted to set the cursor,
+ // let it win, unless more than kCursorOverrideTimeout ms have passed
+ // since the last time the non-mouse handler actually reacted to an event.
+ // We could miss the fact that a tablet stylus has left proximity, because we don't deliver proximity events to windows.
+ if (nonMouseHandler) {
+ if (mouseHandler) {
+ const bool beforeTimeout =
+ QQuickPointerHandlerPrivate::get(mouseHandler)->lastEventTime <
+ QQuickPointerHandlerPrivate::get(nonMouseHandler)->lastEventTime + kCursorOverrideTimeout;
+ QQuickPointerHandler *winner = (beforeTimeout ? nonMouseHandler : mouseHandler);
+ qCDebug(lcHoverTrace) << "non-mouse handler reacted last time:" << QQuickPointerHandlerPrivate::get(nonMouseHandler)->lastEventTime
+ << "and mouse handler reacted at time:" << QQuickPointerHandlerPrivate::get(mouseHandler)->lastEventTime
+ << "choosing cursor according to" << winner << winner->cursorShape();
+ return winner;
+ }
+ qCDebug(lcHoverTrace) << "non-mouse handler choosing cursor" << nonMouseHandler << nonMouseHandler->cursorShape();
+ return nonMouseHandler;
}
- return retHoverHandler;
+ if (mouseHandler)
+ qCDebug(lcHoverTrace) << "mouse handler choosing cursor" << mouseHandler << mouseHandler->cursorShape();
+ return mouseHandler;
}
#endif
@@ -8667,18 +8792,18 @@ bool QQuickItem::event(QEvent *ev)
#endif // gestures
case QEvent::LanguageChange:
case QEvent::LocaleChange:
- for (QQuickItem *item : qAsConst(d->childItems))
+ for (QQuickItem *item : std::as_const(d->childItems))
QCoreApplication::sendEvent(item, ev);
break;
case QEvent::WindowActivate:
case QEvent::WindowDeactivate:
if (d->providesPalette())
d->setCurrentColorGroup();
- for (QQuickItem *item : qAsConst(d->childItems))
+ for (QQuickItem *item : std::as_const(d->childItems))
QCoreApplication::sendEvent(item, ev);
break;
case QEvent::ApplicationPaletteChange:
- for (QQuickItem *item : qAsConst(d->childItems))
+ for (QQuickItem *item : std::as_const(d->childItems))
QCoreApplication::sendEvent(item, ev);
break;
default:
@@ -8873,8 +8998,8 @@ void QQuickItemPrivate::localizedTouchEvent(const QTouchEvent *event, bool isFil
// So hopefully if we start from one passive grabber and go up the parent chain from there,
// we will find any filtering parent items that exist.
auto handler = qmlobject_cast<QQuickPointerHandler *>(pg.first());
- Q_ASSERT(handler);
- pointGrabber = handler->parentItem();
+ if (handler)
+ pointGrabber = handler->parentItem();
}
}
@@ -8935,12 +9060,12 @@ bool QQuickItemPrivate::hasPointerHandlers() const
return extra.isAllocated() && !extra->pointerHandlers.isEmpty();
}
-bool QQuickItemPrivate::hasHoverHandlers() const
+bool QQuickItemPrivate::hasEnabledHoverHandlers() const
{
if (!hasPointerHandlers())
return false;
for (QQuickPointerHandler *h : extra->pointerHandlers)
- if (qmlobject_cast<QQuickHoverHandler *>(h))
+ if (auto *hh = qmlobject_cast<QQuickHoverHandler *>(h); hh && hh->enabled())
return true;
return false;
}
@@ -9460,7 +9585,8 @@ void QQuickItemLayer::itemSiblingOrderChanged(QQuickItem *)
void QQuickItemLayer::itemVisibilityChanged(QQuickItem *)
{
QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
- Q_ASSERT(l);
+ if (!l)
+ return;
l->setVisible(m_item->isVisible());
}
@@ -9469,21 +9595,24 @@ void QQuickItemLayer::updateZ()
if (!m_componentComplete || !m_enabled)
return;
QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
- Q_ASSERT(l);
+ if (!l)
+ return;
l->setZ(m_item->z());
}
void QQuickItemLayer::updateOpacity()
{
QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
- Q_ASSERT(l);
+ if (!l)
+ return;
l->setOpacity(m_item->opacity());
}
void QQuickItemLayer::updateGeometry()
{
QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
- Q_ASSERT(l);
+ if (!l)
+ return;
// Avoid calling QQuickImage::boundingRect() or other overrides
// which may not be up-to-date at this time (QTBUG-104442, 104536)
QRectF bounds = m_item->QQuickItem::boundingRect();
@@ -9498,7 +9627,8 @@ void QQuickItemLayer::updateMatrix()
if (!m_componentComplete || !m_enabled)
return;
QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
- Q_ASSERT(l);
+ if (!l)
+ return;
QQuickItemPrivate *ld = QQuickItemPrivate::get(l);
l->setScale(m_item->scale());
l->setRotation(m_item->rotation());
@@ -9558,7 +9688,7 @@ void QV4::Heap::QQuickItemWrapper::markObjects(QV4::Heap::Base *that, QV4::MarkS
{
QObjectWrapper *This = static_cast<QObjectWrapper *>(that);
if (QQuickItem *item = static_cast<QQuickItem*>(This->object())) {
- for (QQuickItem *child : qAsConst(QQuickItemPrivate::get(item)->childItems))
+ for (QQuickItem *child : std::as_const(QQuickItemPrivate::get(item)->childItems))
QV4::QObjectWrapper::markWrapper(child, markStack);
}
QObjectWrapper::markObjects(that, markStack);
@@ -9569,6 +9699,13 @@ quint64 QQuickItemPrivate::_q_createJSWrapper(QV4::ExecutionEngine *engine)
return (engine->memoryManager->allocate<QQuickItemWrapper>(q_func()))->asReturnedValue();
}
+QDebug operator<<(QDebug debug, const QQuickItemPrivate::ChangeListener &listener)
+{
+ QDebugStateSaver stateSaver(debug);
+ debug.nospace() << "ChangeListener listener=" << listener.listener << " types=" << listener.types;
+ return debug;
+}
+
QT_END_NAMESPACE
#include <moc_qquickitem.cpp>
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index 4e5e5bb34a..428878c45d 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -248,7 +248,7 @@ public:
void localizedTouchEvent(const QTouchEvent *event, bool isFiltering, QMutableTouchEvent *localized);
bool hasPointerHandlers() const;
- bool hasHoverHandlers() const;
+ bool hasEnabledHoverHandlers() const;
virtual void addPointerHandler(QQuickPointerHandler *h);
virtual void removePointerHandler(QQuickPointerHandler *h);
@@ -323,6 +323,11 @@ public:
QQuickItemChangeListener *listener;
ChangeTypes types;
QQuickGeometryChange gTypes; //NOTE: not used for ==
+
+#ifndef QT_NO_DEBUG_STREAM
+ private:
+ friend QDebug operator<<(QDebug debug, const QQuickItemPrivate::ChangeListener &listener);
+#endif // QT_NO_DEBUG_STREAM
};
// call QQuickItemChangeListener PMF
diff --git a/src/quick/items/qquickitemanimation.cpp b/src/quick/items/qquickitemanimation.cpp
index 2a79908a3e..51fd2a3588 100644
--- a/src/quick/items/qquickitemanimation.cpp
+++ b/src/quick/items/qquickitemanimation.cpp
@@ -173,7 +173,7 @@ struct QQuickParentAnimationData : public QAbstractAnimationAction
QList<QQuickParentChange *> pc;
void doAction() override
{
- for (int ii = 0; ii < actions.count(); ++ii) {
+ for (int ii = 0; ii < actions.size(); ++ii) {
const QQuickStateAction &action = actions.at(ii);
if (reverse)
action.event->reverse();
@@ -329,7 +329,7 @@ QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &act
}
}
- if (data->actions.count()) {
+ if (data->actions.size()) {
QSequentialAnimationGroupJob *topLevelGroup = new QSequentialAnimationGroupJob;
QActionAnimation *viaAction = d->via ? new QActionAnimation : nullptr;
QActionAnimation *targetAction = new QActionAnimation;
@@ -343,7 +343,7 @@ QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &act
//take care of any child animations
bool valid = d->defaultProperty.isValid();
QAbstractAnimationJob* anim;
- for (int ii = 0; ii < d->animations.count(); ++ii) {
+ for (int ii = 0; ii < d->animations.size(); ++ii) {
if (valid)
d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
anim = d->animations.at(ii)->transition(actions, modified, direction, defaultTarget);
@@ -488,7 +488,7 @@ QAbstractAnimationJob* QQuickAnchorAnimation::transition(QQuickStateActions &act
data->fromIsSourced = false;
data->fromIsDefined = false;
- for (int ii = 0; ii < actions.count(); ++ii) {
+ for (int ii = 0; ii < actions.size(); ++ii) {
QQuickStateAction &action = actions[ii];
if (action.event && action.event->type() == QQuickStateActionEvent::AnchorChanges
&& (d->targets.isEmpty() || d->targets.contains(static_cast<QQuickAnchorChanges*>(action.event)->object()))) {
@@ -497,7 +497,7 @@ QAbstractAnimationJob* QQuickAnchorAnimation::transition(QQuickStateActions &act
}
QQuickBulkValueAnimator *animator = new QQuickBulkValueAnimator;
- if (data->actions.count()) {
+ if (data->actions.size()) {
animator->setAnimValue(data);
animator->setFromIsSourcedValue(&data->fromIsSourced);
} else {
@@ -823,9 +823,9 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio
data->fromIsSourced = false;
data->fromIsDefined = (d->path && d->path->hasStartX() && d->path->hasStartY()) ? true : false;
data->toIsDefined = d->path ? true : false;
- int origModifiedSize = modified.count();
+ int origModifiedSize = modified.size();
- for (int i = 0; i < actions.count(); ++i) {
+ for (int i = 0; i < actions.size(); ++i) {
QQuickStateAction &action = actions[i];
if (action.event)
continue;
@@ -841,7 +841,7 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio
}
}
- if (target && d->path && (modified.count() > origModifiedSize || data->toIsDefined)) {
+ if (target && d->path && (modified.size() > origModifiedSize || data->toIsDefined)) {
data->target = target;
data->path = d->path;
data->path->invalidateSequentialHistory();
diff --git a/src/quick/items/qquickitemgrabresult.cpp b/src/quick/items/qquickitemgrabresult.cpp
index e14a4c25dd..bcd1afc19d 100644
--- a/src/quick/items/qquickitemgrabresult.cpp
+++ b/src/quick/items/qquickitemgrabresult.cpp
@@ -187,7 +187,7 @@ bool QQuickItemGrabResult::saveToFile(const QUrl &filePath) const
*/
bool QQuickItemGrabResult::saveToFile(const QString &fileName)
{
- return qAsConst(*this).saveToFile(fileName);
+ return std::as_const(*this).saveToFile(fileName);
}
#endif
#endif // < Qt 6
@@ -345,17 +345,15 @@ QSharedPointer<QQuickItemGrabResult> QQuickItem::grabToImage(const QSize &target
*
* If the grab could not be initiated, the function returns \c false.
*
- * The following snippet shows how to grab an item and store the results to
- * a file.
+ * The following snippet shows how to grab an item and store the results in
+ * a file:
*
- * \snippet qml/itemGrab.qml grab-source
- * \snippet qml/itemGrab.qml grab-to-file
+ * \snippet qml/item/itemGrab.qml grab-to-file
*
* The following snippet shows how to grab an item and use the results in
- * another image element.
+ * another image element:
*
- * \snippet qml/itemGrab.qml grab-image-target
- * \snippet qml/itemGrab.qml grab-to-cache
+ * \snippet qml/item/itemGrab.qml grab-to-image
*
* \note This function will render the item to an offscreen surface and
* copy that surface from the GPU's memory into the CPU's memory, which can
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 9cff9c4c4f..88136d7fad 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -160,4 +160,138 @@ void QQuickItemsModule::defineModule()
qt_quickitems_defineModule();
}
+/*!
+ \qmltype PointerEvent
+ \instantiates QPointerEvent
+ \inqmlmodule QtQuick
+ \brief QML equivalent for \l QPointerEvent.
+
+ PointerEvent is the QML name of the QPointerEvent class.
+*/
+
+/*!
+ \qmltype PointerDevice
+ \instantiates QPointingDevice
+ \inqmlmodule QtQuick
+ \brief QML equivalent for \l QPointingDevice.
+
+ PointerDevice is the QML name of the QPointingDevice class.
+ It has the same properties and enums as \l QPointingDevice.
+*/
+
+/*!
+ \qmlproperty enumeration PointerDevice::deviceType
+
+ This property tells the type of device that generated a PointerEvent.
+
+ Valid values are:
+
+ \value PointerDevice.Unknown The device cannot be identified.
+ \value PointerDevice.Mouse A mouse.
+ \value PointerDevice.TouchScreen A touchscreen.
+ \value PointerDevice.TouchPad A touchpad or trackpad.
+ \value PointerDevice.Stylus A stylus on a graphics tablet.
+ \value PointerDevice.Airbrush An airbrush on a graphics tablet.
+ \value PointerDevice.Puck A digitizer with crosshairs, on a graphics tablet.
+
+ \sa QInputDevice::DeviceType, PointerDeviceHandler::acceptedDevices
+*/
+
+/*!
+ \qmlproperty enumeration PointerDevice::pointerType
+
+ This property tells what is interacting with the PointerDevice.
+
+ There is some redundancy between this property and \l deviceType.
+ For example, if a touchscreen is used, then \c deviceType is
+ \c TouchScreen and \c pointerType is \c Finger. But on a graphics
+ tablet, it's often possible for both ends of the stylus to be used,
+ and programs need to distinguish them.
+ \l PointerDeviceHandler::acceptedDevices and
+ \l PointerDeviceHandler::acceptedPointerTypes can be used in combination
+ to filter the subset of events that a particular handler should react to.
+
+ Valid values are:
+
+ \value PointerDevice.Unknown The device cannot be identified.
+ \value PointerDevice.Generic A mouse or a device that emulates a mouse.
+ \value PointerDevice.Finger A finger on a touchscreen.
+ \value PointerDevice.Pen A stylus on a graphics tablet.
+ \value PointerDevice.Eraser An eraser on a graphics tablet.
+ \value PointerDevice.Cursor A digitizer with crosshairs, on a graphics tablet.
+
+ \sa QPointingDevice::PointerType, PointerDeviceHandler::acceptedPointerTypes
+*/
+
+/*!
+ \qmlproperty int PointerDevice::maximumPoints
+
+ This property tells the maximum number of simultaneous touch points
+ (fingers) that can be detected.
+*/
+
+/*!
+ \qmlproperty int PointerDevice::buttonCount
+
+ This property tells the maximum number of on-device buttons that can be
+ detected.
+*/
+
+/*!
+ \qmltype pointingDeviceUniqueId
+ \instantiates QPointingDeviceUniqueId
+ \inqmlmodule QtQuick
+ \brief QML equivalent for \l QPointingDeviceUniqueId.
+
+ pointingDeviceUniqueId is the QML name of the QPointingDeviceUniqueId class.
+*/
+
+/*!
+ \qmlproperty qint64 pointingDeviceUniqueId::numericId
+
+ This property gives the numeric ID of the \l PointerDevice, if available;
+ otherwise it is \c -1.
+*/
+
+/*!
+ \qmlproperty pointingDeviceUniqueId PointerDevice::uniqueId
+
+ This property may provide a unique ID for the device, if available. For
+ example, a graphics tablet stylus device may have a unique serial number.
+
+ \sa eventPoint, QEventPoint::uniqueId()
+*/
+
+/*!
+ \qmlsignal PointerDevice::grabChanged(QtObject grabber, enumeration transition, PointerEvent event, eventPoint point)
+
+ This signal is emitted when the \a grabber object gains or loses an
+ exclusive or passive grab of \a point during delivery of \a event.
+ The \a transition tells what happened, from the perspective of the
+ \c grabber object, which may be either an \l Item or an
+ \l {Qt Quick Input Handlers}{Input Handler}.
+
+ Valid values for \a transition are:
+
+ \value GrabExclusive
+ The \a grabber has taken primary responsibility for handling the \a point.
+ \value UngrabExclusive
+ The \a grabber has given up its previous exclusive grab.
+ \value CancelGrabExclusive
+ The exclusive grab of \a grabber has been taken over or cancelled.
+ \value GrabPassive
+ The \a grabber has acquired a passive grab, to monitor the \a point.
+ \value UngrabPassive
+ The \a grabber has given up its previous passive grab.
+ \value CancelGrabPassive
+ The previous passive grab has terminated abnormally.
+
+ \note A grab transition from one object to another results in two signals,
+ to notify that one object has lost its grab, and to notify that there is
+ another grabber. In other cases, when transitioning to or from a non-grabbing
+ state, only one signal is emitted.
+
+ \sa QPointerEvent::setExclusiveGrabber(), QPointerEvent::addPassiveGrabber(), QPointerEvent::removePassiveGrabber()
+*/
+
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 627ee1e933..1f3ec79190 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -964,7 +964,7 @@ void QQuickItemViewPrivate::applyPendingChanges()
int QQuickItemViewPrivate::findMoveKeyIndex(QQmlChangeSet::MoveKey key, const QVector<QQmlChangeSet::Change> &changes) const
{
- for (int i=0; i<changes.count(); i++) {
+ for (int i=0; i<changes.size(); i++) {
for (int j=changes[i].index; j<changes[i].index + changes[i].count; j++) {
if (changes[i].moveKey(j) == key)
return j;
@@ -1101,7 +1101,7 @@ void QQuickItemViewPrivate::applyDelegateChange()
void QQuickItemViewPrivate::checkVisible() const
{
int skip = 0;
- for (int i = 0; i < visibleItems.count(); ++i) {
+ for (int i = 0; i < visibleItems.size(); ++i) {
FxViewItem *item = visibleItems.at(i);
if (item->index == -1) {
++skip;
@@ -1353,7 +1353,7 @@ qreal QQuickItemView::maxYExtent() const
{
Q_D(const QQuickItemView);
if (d->layoutOrientation() == Qt::Horizontal)
- return height();
+ return QQuickFlickable::maxYExtent();
if (d->vData.maxExtentDirty) {
d->maxExtent = d->maxExtentForAxis(d->vData, false);
@@ -1381,7 +1381,7 @@ qreal QQuickItemView::maxXExtent() const
{
Q_D(const QQuickItemView);
if (d->layoutOrientation() == Qt::Vertical)
- return width();
+ return QQuickFlickable::maxXExtent();
if (d->hData.maxExtentDirty) {
d->maxExtent = d->maxExtentForAxis(d->hData, true);
@@ -1564,8 +1564,8 @@ int QQuickItemViewPrivate::findLastVisibleIndex(int defaultValue) const
}
FxViewItem *QQuickItemViewPrivate::visibleItem(int modelIndex) const {
- if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) {
- for (int i = modelIndex - visibleIndex; i < visibleItems.count(); ++i) {
+ if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.size()) {
+ for (int i = modelIndex - visibleIndex; i < visibleItems.size(); ++i) {
FxViewItem *item = visibleItems.at(i);
if (item->index == modelIndex)
return item;
@@ -1580,7 +1580,7 @@ FxViewItem *QQuickItemViewPrivate::firstItemInView() const {
if (item->index != -1 && item->endPosition() > pos)
return item;
}
- return visibleItems.count() ? visibleItems.first() : 0;
+ return visibleItems.size() ? visibleItems.first() : 0;
}
int QQuickItemViewPrivate::findLastIndexInView() const
@@ -1599,9 +1599,9 @@ int QQuickItemViewPrivate::findLastIndexInView() const
// e.g. doing a removal animation
int QQuickItemViewPrivate::mapFromModel(int modelIndex) const
{
- if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count())
+ if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.size())
return -1;
- for (int i = 0; i < visibleItems.count(); ++i) {
+ for (int i = 0; i < visibleItems.size(); ++i) {
FxViewItem *item = visibleItems.at(i);
if (item->index == modelIndex)
return i;
@@ -1682,7 +1682,7 @@ void QQuickItemViewPrivate::clear(bool onDestruction)
releaseVisibleItems(QQmlInstanceModel::NotReusable);
visibleIndex = 0;
- for (FxViewItem *item : qAsConst(releasePendingTransition)) {
+ for (FxViewItem *item : std::as_const(releasePendingTransition)) {
item->releaseAfterTransition = false;
releaseItem(item, QQmlInstanceModel::NotReusable);
}
@@ -1832,7 +1832,7 @@ void QQuickItemViewPrivate::layout()
// viewBounds contains bounds before any add/remove/move operation to the view
QRectF viewBounds(q->contentX(), q->contentY(), q->width(), q->height());
- if (!isValid() && !visibleItems.count()) {
+ if (!isValid() && !visibleItems.size()) {
clear();
setPosition(contentStartOffset());
updateViewport();
@@ -1846,7 +1846,7 @@ void QQuickItemViewPrivate::layout()
&& transitioner->canTransition(QQuickItemViewTransitioner::RemoveTransition, false)) {
// assume that any items moving now are moving due to the remove - if they schedule
// a different transition, that will override this one anyway
- for (int i=0; i<visibleItems.count(); i++)
+ for (int i=0; i<visibleItems.size(); i++)
visibleItems[i]->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, false);
}
@@ -1866,7 +1866,7 @@ void QQuickItemViewPrivate::layout()
// Give the view one more chance to refill itself,
// in case its size is changed such that more delegates become visible after component completed
refill();
- for (FxViewItem *item : qAsConst(visibleItems)) {
+ for (FxViewItem *item : std::as_const(visibleItems)) {
if (!item->transitionScheduledOrRunning())
item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::PopulateTransition, true);
}
@@ -1903,14 +1903,14 @@ void QQuickItemViewPrivate::layout()
prepareVisibleItemTransitions();
// We cannot use iterators here as erasing from a container invalidates them.
- for (int i = 0, count = releasePendingTransition.count(); i < count;) {
+ for (int i = 0, count = releasePendingTransition.size(); i < count;) {
auto success = prepareNonVisibleItemTransition(releasePendingTransition[i], viewBounds);
// prepareNonVisibleItemTransition() may remove items while in fast flicking.
// Invisible animating items are kicked in or out the viewPort.
// Recheck count to test if the item got removed. In that case the same index points
// to a different item now.
const int old_count = count;
- count = releasePendingTransition.count();
+ count = releasePendingTransition.size();
if (old_count > count)
continue;
@@ -1923,15 +1923,18 @@ void QQuickItemViewPrivate::layout()
}
}
- for (int i=0; i<visibleItems.count(); i++)
+ for (int i=0; i<visibleItems.size(); i++)
visibleItems[i]->startTransition(transitioner);
- for (int i=0; i<releasePendingTransition.count(); i++)
+ for (int i=0; i<releasePendingTransition.size(); i++)
releasePendingTransition[i]->startTransition(transitioner);
transitioner->setPopulateTransitionEnabled(false);
transitioner->resetTargetLists();
}
+ if (!currentItem)
+ updateCurrent(currentIndex);
+
runDelayedRemoveTransition = false;
inLayout = false;
}
@@ -1949,9 +1952,9 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
updateUnrequestedIndexes();
- FxViewItem *prevVisibleItemsFirst = visibleItems.count() ? *visibleItems.constBegin() : nullptr;
+ FxViewItem *prevVisibleItemsFirst = visibleItems.size() ? *visibleItems.constBegin() : nullptr;
int prevItemCount = itemCount;
- int prevVisibleItemsCount = visibleItems.count();
+ int prevVisibleItemsCount = visibleItems.size();
bool visibleAffected = false;
bool viewportChanged = !currentChanges.pendingChanges.removes().isEmpty()
|| !currentChanges.pendingChanges.inserts().isEmpty();
@@ -1963,7 +1966,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
prevFirstItemInViewPos = prevFirstItemInView->position();
prevFirstItemInViewIndex = prevFirstItemInView->index;
}
- qreal prevVisibleItemsFirstPos = visibleItems.count() ? firstVisibleItemPosition : 0.0;
+ qreal prevVisibleItemsFirstPos = visibleItems.size() ? firstVisibleItemPosition : 0.0;
totalInsertionResult->visiblePos = prevFirstItemInViewPos;
totalRemovalResult->visiblePos = prevFirstItemInViewPos;
@@ -2016,7 +2019,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
QList<FxViewItem *> newItems;
QList<MovedItem> movingIntoView;
- for (int i=0; i<insertions.count(); i++) {
+ for (int i=0; i<insertions.size(); i++) {
bool wasEmpty = visibleItems.isEmpty();
if (applyInsertionChange(insertions[i], &insertionResult, &newItems, &movingIntoView))
visibleAffected = true;
@@ -2027,14 +2030,14 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
*totalInsertionResult += insertionResult;
// set positions correctly for the next insertion
- if (i < insertions.count() - 1) {
+ if (i < insertions.size() - 1) {
repositionFirstItem(prevVisibleItemsFirst, prevVisibleItemsFirstPos, prevFirstItemInView, &insertionResult, &removalResult);
layoutVisibleItems(insertions[i].index);
storeFirstVisibleItemPosition();
}
itemCount += insertions[i].count;
}
- for (FxViewItem *item : qAsConst(newItems)) {
+ for (FxViewItem *item : std::as_const(newItems)) {
if (item->attached)
item->attached->emitAdd();
}
@@ -2043,7 +2046,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
// find the index it was moved from in order to set its initial position, so that we
// can transition it from this "original" position to its new position in the view
if (transitioner && transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, true)) {
- for (const MovedItem &m : qAsConst(movingIntoView)) {
+ for (const MovedItem &m : std::as_const(movingIntoView)) {
int fromIndex = findMoveKeyIndex(m.moveKey, removals);
if (fromIndex >= 0) {
if (prevFirstItemInViewIndex >= 0 && fromIndex < prevFirstItemInViewIndex)
@@ -2099,7 +2102,7 @@ bool QQuickItemViewPrivate::applyRemovalChange(const QQmlChangeSet::Change &remo
Q_Q(QQuickItemView);
bool visibleAffected = false;
- if (visibleItems.count() && removal.index + removal.count > visibleItems.constLast()->index) {
+ if (visibleItems.size() && removal.index + removal.count > visibleItems.constLast()->index) {
if (removal.index > visibleItems.constLast()->index)
removeResult->countChangeAfterVisibleItems += removal.count;
else
@@ -2177,7 +2180,7 @@ void QQuickItemViewPrivate::repositionFirstItem(FxViewItem *prevVisibleItemsFirs
const QQmlNullableValue<qreal> prevViewPos = insertionResult->visiblePos;
// reposition visibleItems.first() correctly so that the content y doesn't jump
- if (visibleItems.count()) {
+ if (visibleItems.size()) {
if (prevVisibleItemsFirst && insertionResult->changedFirstItem)
resetFirstItemPosition(prevVisibleItemsFirstPos);
@@ -2224,7 +2227,7 @@ void QQuickItemViewPrivate::prepareVisibleItemTransitions()
// must call for every visible item to init or discard transitions
QRectF viewBounds(q->contentX(), q->contentY(), q->width(), q->height());
- for (int i=0; i<visibleItems.count(); i++)
+ for (int i=0; i<visibleItems.size(); i++)
visibleItems[i]->prepareTransition(transitioner, viewBounds);
}
@@ -2276,7 +2279,7 @@ bool QQuickItemViewPrivate::prepareNonVisibleItemTransition(FxViewItem *item, co
void QQuickItemViewPrivate::viewItemTransitionFinished(QQuickItemViewTransitionableItem *item)
{
- for (int i=0; i<releasePendingTransition.count(); i++) {
+ for (int i=0; i<releasePendingTransition.size(); i++) {
if (releasePendingTransition.at(i)->transitionableItem == item) {
releaseItem(releasePendingTransition.takeAt(i), reusableFlag);
return;
@@ -2296,7 +2299,7 @@ FxViewItem *QQuickItemViewPrivate::createItem(int modelIndex, QQmlIncubator::Inc
if (requestedIndex == modelIndex && incubationMode == QQmlIncubator::Asynchronous)
return nullptr;
- for (int i=0; i<releasePendingTransition.count(); i++) {
+ for (int i=0; i<releasePendingTransition.size(); i++) {
if (releasePendingTransition.at(i)->index == modelIndex
&& !releasePendingTransition.at(i)->isPendingRemoval()) {
releasePendingTransition[i]->releaseAfterTransition = false;
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 9ea4624997..043c5e08d3 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -451,7 +451,7 @@ FxViewItem *QQuickListViewPrivate::itemBefore(int modelIndex) const
return nullptr;
int idx = 1;
int lastIndex = -1;
- while (idx < visibleItems.count()) {
+ while (idx < visibleItems.size()) {
FxViewItem *item = visibleItems.at(idx);
if (item->index != -1)
lastIndex = item->index;
@@ -497,7 +497,7 @@ qreal QQuickListViewPrivate::lastPosition() const
if (!visibleItems.isEmpty()) {
int invisibleCount = INT_MIN;
int delayRemovedCount = 0;
- for (int i = visibleItems.count()-1; i >= 0; --i) {
+ for (int i = visibleItems.size()-1; i >= 0; --i) {
FxViewItem *item = visibleItems.at(i);
if (item->index != -1) {
// Find the invisible count after the last visible item with known index
@@ -576,7 +576,7 @@ qreal QQuickListViewPrivate::snapPosAt(qreal pos)
{
if (FxListItemSG *snapItem = static_cast<FxListItemSG*>(snapItemAt(pos)))
return snapItem->itemPosition();
- if (visibleItems.count()) {
+ if (visibleItems.size()) {
qreal firstPos = (*visibleItems.constBegin())->position();
qreal endPos = (*(visibleItems.constEnd() - 1))->position();
if (pos < firstPos) {
@@ -593,7 +593,7 @@ FxViewItem *QQuickListViewPrivate::snapItemAt(qreal pos)
FxViewItem *snapItem = nullptr;
FxViewItem *prevItem = nullptr;
qreal prevItemSize = 0;
- for (FxViewItem *item : qAsConst(visibleItems)) {
+ for (FxViewItem *item : std::as_const(visibleItems)) {
if (item->index == -1)
continue;
@@ -721,7 +721,7 @@ bool QQuickListViewPrivate::releaseItem(FxViewItem *item, QQmlInstanceModel::Reu
bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer)
{
qreal itemEnd = visiblePos;
- if (visibleItems.count()) {
+ if (visibleItems.size()) {
visiblePos = (*visibleItems.constBegin())->position();
itemEnd = (*(visibleItems.constEnd() - 1))->endPosition() + spacing;
}
@@ -807,7 +807,7 @@ bool QQuickListViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal buffer
// removed, otherwise a zero-sized item is infinitely added and removed over and
// over by refill().
int index = 0;
- while (visibleItems.count() > 1 && index < visibleItems.count()
+ while (visibleItems.size() > 1 && index < visibleItems.size()
&& (item = visibleItems.at(index)) && item->endPosition() < bufferFrom) {
if (item->attached->delayRemove())
break;
@@ -830,10 +830,10 @@ bool QQuickListViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal buffer
}
}
- while (visibleItems.count() > 1 && (item = visibleItems.constLast()) && item->position() > bufferTo) {
+ while (visibleItems.size() > 1 && (item = visibleItems.constLast()) && item->position() > bufferTo) {
if (item->attached->delayRemove())
break;
- qCDebug(lcItemViewDelegateLifecycle) << "refill: remove last" << visibleIndex+visibleItems.count()-1 << item->position() << (QObject *)(item->item);
+ qCDebug(lcItemViewDelegateLifecycle) << "refill: remove last" << visibleIndex+visibleItems.size()-1 << item->position() << (QObject *)(item->item);
visibleItems.removeLast();
removeItem(item);
changed = true;
@@ -844,7 +844,7 @@ bool QQuickListViewPrivate::removeNonVisibleItems(qreal bufferFrom, qreal buffer
void QQuickListViewPrivate::visibleItemsChanged()
{
- if (visibleItems.count())
+ if (visibleItems.size())
visiblePos = (*visibleItems.constBegin())->position();
updateAverage();
if (currentIndex >= 0 && currentItem && !visibleItem(currentIndex)) {
@@ -874,7 +874,7 @@ void QQuickListViewPrivate::layoutVisibleItems(int fromModelIndex)
if (firstItem->section())
firstItem->setPosition(firstItem->position());
- for (int i=1; i < visibleItems.count(); ++i) {
+ for (int i=1; i < visibleItems.size(); ++i) {
FxListItemSG *item = static_cast<FxListItemSG*>(visibleItems.at(i));
if (item->index >= fromModelIndex) {
item->setPosition(pos);
@@ -884,7 +884,7 @@ void QQuickListViewPrivate::layoutVisibleItems(int fromModelIndex)
sum += item->size();
fixedCurrent = fixedCurrent || (currentItem && item->item == currentItem->item);
}
- averageSize = qRound(sum / visibleItems.count());
+ averageSize = qRound(sum / visibleItems.size());
// move current item if it is not a visible item.
if (currentIndex >= 0 && currentItem && !fixedCurrent)
@@ -929,7 +929,7 @@ void QQuickListViewPrivate::resetFirstItemPosition(qreal pos)
void QQuickListViewPrivate::adjustFirstItem(qreal forwards, qreal backwards, int)
{
- if (!visibleItems.count())
+ if (!visibleItems.size())
return;
qreal diff = forwards - backwards;
static_cast<FxListItemSG*>(visibleItems.constFirst())->setPosition(visibleItems.constFirst()->position() + diff);
@@ -1114,7 +1114,7 @@ void QQuickListViewPrivate::releaseSectionItem(QQuickItem *item)
void QQuickListViewPrivate::releaseSectionItems()
{
- for (FxViewItem *item : qAsConst(visibleItems)) {
+ for (FxViewItem *item : std::as_const(visibleItems)) {
FxListItemSG *listItem = static_cast<FxListItemSG *>(item);
if (listItem->section()) {
qreal pos = listItem->position();
@@ -1166,7 +1166,7 @@ void QQuickListViewPrivate::updateStickySections()
QQuickItem *sectionItem = nullptr;
QQuickItem *lastSectionItem = nullptr;
int index = 0;
- while (index < visibleItems.count()) {
+ while (index < visibleItems.size()) {
if (QQuickItem *section = static_cast<FxListItemSG *>(visibleItems.at(index))->section()) {
// Find the current section header and last visible section header
// and hide them if they will overlap a static section header.
@@ -1193,7 +1193,7 @@ void QQuickListViewPrivate::updateStickySections()
}
// Current section header
- if (sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart && isValid() && visibleItems.count()) {
+ if (sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart && isValid() && visibleItems.size()) {
if (!currentSectionItem) {
currentSectionItem = getSectionItem(currentSection);
} else if (QString::compare(currentStickySection, currentSection, Qt::CaseInsensitive)) {
@@ -1227,7 +1227,7 @@ void QQuickListViewPrivate::updateStickySections()
}
// Next section footer
- if (sectionCriteria->labelPositioning() & QQuickViewSection::NextLabelAtEnd && isValid() && visibleItems.count()) {
+ if (sectionCriteria->labelPositioning() & QQuickViewSection::NextLabelAtEnd && isValid() && visibleItems.size()) {
if (!nextSectionItem) {
nextSectionItem = getSectionItem(nextSection);
} else if (QString::compare(nextStickySection, nextSection, Qt::CaseInsensitive)) {
@@ -1274,7 +1274,7 @@ void QQuickListViewPrivate::updateSections()
QQuickListViewAttached *prevAtt = nullptr;
int prevIdx = -1;
int idx = -1;
- for (FxViewItem *item : qAsConst(visibleItems)) {
+ for (FxViewItem *item : std::as_const(visibleItems)) {
QQuickListViewAttached *attached = static_cast<QQuickListViewAttached*>(item->attached);
attached->setPrevSection(prevSection);
if (item->index != -1) {
@@ -1315,7 +1315,7 @@ void QQuickListViewPrivate::updateCurrentSection()
qreal startPos = hasStickyHeader() ? header->endPosition() : viewPos;
int index = 0;
int modelIndex = visibleIndex;
- while (index < visibleItems.count()) {
+ while (index < visibleItems.size()) {
FxViewItem *item = visibleItems.at(index);
if (item->endPosition() > startPos)
break;
@@ -1325,7 +1325,7 @@ void QQuickListViewPrivate::updateCurrentSection()
}
QString newSection = currentSection;
- if (index < visibleItems.count())
+ if (index < visibleItems.size())
newSection = visibleItems.at(index)->attached->section();
else
newSection = (*visibleItems.constBegin())->attached->section();
@@ -1344,7 +1344,7 @@ void QQuickListViewPrivate::updateCurrentSection()
qreal endPos = hasStickyFooter() ? footer->position() : viewPos + size();
if (nextSectionItem && !inlineSections)
endPos -= orient == QQuickListView::Vertical ? nextSectionItem->height() : nextSectionItem->width();
- while (index < visibleItems.count()) {
+ while (index < visibleItems.size()) {
FxListItemSG *listItem = static_cast<FxListItemSG *>(visibleItems.at(index));
if (listItem->itemPosition() >= endPos)
break;
@@ -1379,7 +1379,7 @@ void QQuickListViewPrivate::initializeCurrentItem()
// don't reposition the item if it is already in the visibleItems list
FxViewItem *actualItem = visibleItem(currentIndex);
if (!actualItem) {
- if (currentIndex == visibleIndex - 1 && visibleItems.count()) {
+ if (currentIndex == visibleIndex - 1 && visibleItems.size()) {
// We can calculate exact postion in this case
listItem->setPosition(visibleItems.constFirst()->position() - currentItem->size() - spacing);
} else {
@@ -1396,12 +1396,12 @@ void QQuickListViewPrivate::initializeCurrentItem()
void QQuickListViewPrivate::updateAverage()
{
- if (!visibleItems.count())
+ if (!visibleItems.size())
return;
qreal sum = 0.0;
- for (FxViewItem *item : qAsConst(visibleItems))
+ for (FxViewItem *item : std::as_const(visibleItems))
sum += item->size();
- averageSize = qRound(sum / visibleItems.count());
+ averageSize = qRound(sum / visibleItems.size());
}
qreal QQuickListViewPrivate::headerSize() const
@@ -1440,10 +1440,12 @@ void QQuickListViewPrivate::updateFooter()
FxListItemSG *listItem = static_cast<FxListItemSG*>(footer);
if (footerPositioning == QQuickListView::OverlayFooter) {
listItem->setPosition(isContentFlowReversed() ? -position() - footerSize() : position() + size() - footerSize());
- } else if (visibleItems.count()) {
+ } else if (visibleItems.size()) {
if (footerPositioning == QQuickListView::PullBackFooter) {
qreal viewPos = isContentFlowReversed() ? -position() : position() + size();
- qreal clampedPos = qBound(originPosition() - footerSize() + size(), listItem->position(), lastPosition());
+ // using qBound() would throw an assert here, because max < min is a valid case
+ // here, if the list's delegates do not fill the whole view
+ qreal clampedPos = qMax(originPosition() - footerSize() + size(), qMin(listItem->position(), lastPosition()));
listItem->setPosition(qBound(viewPos - footerSize(), clampedPos, viewPos));
} else {
qreal endPos = lastPosition();
@@ -1473,7 +1475,7 @@ void QQuickListViewPrivate::fixupHeader()
{
FxListItemSG *listItem = static_cast<FxListItemSG*>(header);
const bool fixingUp = (orient == QQuickListView::Vertical ? vData : hData).fixingUp;
- if (fixingUp && headerPositioning == QQuickListView::PullBackHeader && visibleItems.count()) {
+ if (fixingUp && headerPositioning == QQuickListView::PullBackHeader && visibleItems.size()) {
int fixupDura = timeline.duration();
if (fixupDura < 0)
fixupDura = fixupDuration/2;
@@ -1504,7 +1506,7 @@ void QQuickListViewPrivate::updateHeader()
FxListItemSG *listItem = static_cast<FxListItemSG*>(header);
if (headerPositioning == QQuickListView::OverlayHeader) {
listItem->setPosition(isContentFlowReversed() ? -position() - size() : position());
- } else if (visibleItems.count()) {
+ } else if (visibleItems.size()) {
const bool fixingUp = (orient == QQuickListView::Vertical ? vData : hData).fixingUp;
if (headerPositioning == QQuickListView::PullBackHeader) {
qreal headerPosition = listItem->position();
@@ -1512,7 +1514,9 @@ void QQuickListViewPrivate::updateHeader()
// Make sure the header is not shown if we absolutely do not have any plans to show it
if (fixingUp && !headerNeedsSeparateFixup)
headerPosition = viewPos - headerSize();
- qreal clampedPos = qBound(originPosition() - headerSize(), headerPosition, lastPosition() - size());
+ // using qBound() would throw an assert here, because max < min is a valid case
+ // here, if the list's delegates do not fill the whole view
+ qreal clampedPos = qMax(originPosition() - headerSize(), qMin(headerPosition, lastPosition() - size()));
listItem->setPosition(qBound(viewPos - headerSize(), clampedPos, viewPos));
} else {
qreal startPos = originPosition();
@@ -1573,7 +1577,7 @@ void QQuickListViewPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometry
// if visibleItems.first() has resized, adjust its pos since it is used to
// position all subsequent items
- if (visibleItems.count() && item == visibleItems.constFirst()->item) {
+ if (visibleItems.size() && item == visibleItems.constFirst()->item) {
FxListItemSG *listItem = static_cast<FxListItemSG*>(visibleItems.constFirst());
if (listItem->transitionScheduledOrRunning())
return;
@@ -1619,7 +1623,7 @@ void QQuickListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte
}
// update footer if all visible items have been removed
- if (visibleItems.count() == 0)
+ if (visibleItems.size() == 0)
updateFooter();
correctFlick = false;
@@ -1824,15 +1828,15 @@ bool QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
return QQuickItemViewPrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity);
}
qreal maxDistance = 0;
- qreal dataValue = isContentFlowReversed() ? -data.move.value()+size() : data.move.value();
+ const qreal dataValue =
+ isContentFlowReversed() ? -data.move.value() + size() : data.move.value();
// -ve velocity means list is moving up/left
if (velocity > 0) {
if (data.move.value() < minExtent) {
if (snapMode == QQuickListView::SnapOneItem && !hData.flicking && !vData.flicking) {
- // if we've been dragged < averageSize/2 then bias towards the next item
- qreal dist = data.move.value() - data.pressPos;
- qreal bias = dist < averageSize/2 ? averageSize/2 : 0;
+ // averageSize/2 + 1 - next item
+ qreal bias = averageSize / 2 + 1 - (pressed ? data.pressPos : 0);
if (isContentFlowReversed())
bias = -bias;
data.flickTarget = -snapPosAt(-(dataValue - highlightRangeStart) - bias) + highlightRangeStart;
@@ -1847,12 +1851,12 @@ bool QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
} else {
if (data.move.value() > maxExtent) {
if (snapMode == QQuickListView::SnapOneItem && !hData.flicking && !vData.flicking) {
- // if we've been dragged < averageSize/2 then bias towards the next item
- qreal dist = data.move.value() - data.pressPos;
- qreal bias = -dist < averageSize/2 ? averageSize/2 : 0;
+ // averageSize/2 + 1 - next item
+ qreal bias = averageSize / 2 + 1 - (pressed ? data.pressPos : 0);
if (isContentFlowReversed())
bias = -bias;
- data.flickTarget = -snapPosAt(-(dataValue - highlightRangeStart) + bias) + highlightRangeStart;
+ data.flickTarget =
+ -snapPosAt(-(dataValue - highlightRangeStart) + bias) + highlightRangeStart;
maxDistance = qAbs(data.flickTarget - data.move.value());
velocity = -maxVelocity;
} else {
@@ -2707,7 +2711,8 @@ void QQuickListView::setOrientation(QQuickListView::Orientation orientation)
\c section.delegate holds the delegate component for each section. The
default \l {QQuickItem::z}{stacking order} of section delegate instances
- is \c 2.
+ is \c 2. If you declare a \c required property named "section" in it,
+ that property will contain the section's title.
\c section.labelPositioning determines whether the current and/or
next section labels stick to the start/end of the view, and whether
@@ -3385,7 +3390,7 @@ void QQuickListView::viewportMoved(Qt::Orientations orient)
// Set visibility of items to eliminate cost of items outside the visible area.
qreal from = d->isContentFlowReversed() ? -d->position()-d->displayMarginBeginning-d->size() : d->position()-d->displayMarginBeginning;
qreal to = d->isContentFlowReversed() ? -d->position()+d->displayMarginEnd : d->position()+d->size()+d->displayMarginEnd;
- for (FxViewItem *item : qAsConst(d->visibleItems)) {
+ for (FxViewItem *item : std::as_const(d->visibleItems)) {
if (item->item)
QQuickItemPrivate::get(item->item)->setCulled(item->endPosition() < from || item->position() > to);
}
@@ -3610,25 +3615,25 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
int count = change.count;
qreal tempPos = isContentFlowReversed() ? -position()-size() : position();
- int index = visibleItems.count() ? mapFromModel(modelIndex) : 0;
+ int index = visibleItems.size() ? mapFromModel(modelIndex) : 0;
qreal lastVisiblePos = buffer + displayMarginEnd + tempPos + size();
if (index < 0) {
- int i = visibleItems.count() - 1;
+ int i = visibleItems.size() - 1;
while (i > 0 && visibleItems.at(i)->index == -1)
--i;
if (i == 0 && visibleItems.constFirst()->index == -1) {
// there are no visible items except items marked for removal
- index = visibleItems.count();
+ index = visibleItems.size();
} else if (visibleItems.at(i)->index + 1 == modelIndex
&& visibleItems.at(i)->endPosition() <= lastVisiblePos) {
// Special case of appending an item to the model.
- index = visibleItems.count();
+ index = visibleItems.size();
} else {
if (modelIndex < visibleIndex) {
// Insert before visible items
visibleIndex += count;
- for (FxViewItem *item : qAsConst(visibleItems)) {
+ for (FxViewItem *item : std::as_const(visibleItems)) {
if (item->index != -1 && item->index >= modelIndex)
item->index += count;
}
@@ -3639,13 +3644,13 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
// index can be the next item past the end of the visible items list (i.e. appended)
qreal pos = 0;
- if (visibleItems.count()) {
- pos = index < visibleItems.count() ? visibleItems.at(index)->position()
+ if (visibleItems.size()) {
+ pos = index < visibleItems.size() ? visibleItems.at(index)->position()
: visibleItems.constLast()->endPosition() + spacing;
}
// Update the indexes of the following visible items.
- for (FxViewItem *item : qAsConst(visibleItems)) {
+ for (FxViewItem *item : std::as_const(visibleItems)) {
if (item->index != -1 && item->index >= modelIndex) {
item->index += count;
if (change.isMove())
@@ -3698,7 +3703,7 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
}
int firstOkIdx = -1;
- for (int i = 0; i <= insertionIdx && i < visibleItems.count() - 1; i++) {
+ for (int i = 0; i <= insertionIdx && i < visibleItems.size() - 1; i++) {
if (visibleItems.at(i)->index + 1 != visibleItems.at(i + 1)->index) {
firstOkIdx = i + 1;
break;
@@ -3749,13 +3754,13 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
}
it.disconnect();
- if (0 < index && index < visibleItems.count()) {
+ if (0 < index && index < visibleItems.size()) {
FxViewItem *prevItem = visibleItems.at(index - 1);
FxViewItem *item = visibleItems.at(index);
if (prevItem->index != item->index - 1) {
int i = index;
qreal prevPos = prevItem->position();
- while (i < visibleItems.count()) {
+ while (i < visibleItems.size()) {
FxListItemSG *nvItem = static_cast<FxListItemSG *>(visibleItems.takeLast());
insertResult->sizeChangesAfterVisiblePos -= nvItem->size() + spacing;
addedItems->removeOne(nvItem);
@@ -3780,7 +3785,7 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
return;
int markerItemIndex = -1;
- for (int i=0; i<visibleItems.count(); i++) {
+ for (int i=0; i<visibleItems.size(); i++) {
if (visibleItems.at(i)->index == afterModelIndex) {
markerItemIndex = i;
break;
@@ -3793,7 +3798,7 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
qreal sizeRemoved = -removalResult.sizeChangesAfterVisiblePos
- (removalResult.countChangeAfterVisibleItems * (averageSize + spacing));
- for (int i=markerItemIndex+1; i<visibleItems.count(); i++) {
+ for (int i=markerItemIndex+1; i<visibleItems.size(); i++) {
FxListItemSG *listItem = static_cast<FxListItemSG *>(visibleItems.at(i));
if (listItem->position() >= viewEndPos)
break;
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index 7bb21a6d9d..d33e06a273 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -768,7 +768,7 @@ void QQuickLoader::componentComplete()
{
Q_D(QQuickLoader);
QQuickItem::componentComplete();
- if (active()) {
+ if (active() && (status() != Ready)) {
if (d->loadingFromSource)
d->createComponent();
d->load();
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index 53ce213a3c..31c74765f7 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -24,7 +24,7 @@ DEFINE_BOOL_CONFIG_OPTION(qmlVisualTouchDebugging, QML_VISUAL_TOUCH_DEBUGGING)
Q_DECLARE_LOGGING_CATEGORY(lcHoverTrace)
QQuickMouseAreaPrivate::QQuickMouseAreaPrivate()
-: enabled(true), scrollGestureEnabled(true), hovered(false), longPress(false),
+: enabled(true), hoverEnabled(false), scrollGestureEnabled(true), hovered(false), longPress(false),
moved(false), stealMouse(false), doubleClick(false), preventStealing(false),
propagateComposedEvents(false), overThreshold(false),
pressAndHoldInterval(-1)
@@ -117,7 +117,7 @@ bool QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent *ev, QQuickItem *i
}
QList<QQuickItem *> children = itemPrivate->paintOrderChildItems();
- for (int ii = children.count() - 1; ii >= 0; --ii) {
+ for (int ii = children.size() - 1; ii >= 0; --ii) {
QQuickItem *child = children.at(ii);
if (!child->isVisible() || !child->isEnabled())
continue;
@@ -453,6 +453,7 @@ void QQuickMouseArea::setEnabled(bool a)
Q_D(QQuickMouseArea);
if (a != d->enabled) {
d->enabled = a;
+ setAcceptHoverEvents(a && d->hoverEnabled);
emit enabledChanged();
}
}
@@ -767,7 +768,7 @@ void QQuickMouseArea::mouseReleaseEvent(QMouseEvent *event)
d->drag->setActive(false);
#endif
// If we don't accept hover, we need to reset containsMouse.
- if (!acceptHoverEvents())
+ if (!hoverEnabled())
setHovered(false);
QQuickWindow *w = window();
if (w && w->mouseGrabberItem() == this)
@@ -802,6 +803,14 @@ void QQuickMouseArea::hoverEnterEvent(QHoverEvent *event)
{
Q_D(QQuickMouseArea);
if (!d->enabled && !d->pressed) {
+ // Note: The fact that MouseArea doesn't update 'containsMouse' when it's disabled, is a
+ // legacy behavior that is different from how hover events are supposed to work; Hover
+ // events are always delivered to both enabled and disabled items (when they explicitly
+ // subscribe for them), to open up for hover effects, like showing tooltips. Because of
+ // this difference, you cannot use a MouseArea to e.g trigger a tooltop on a parent that
+ // is disabled. But since MouseArea has always worked this way, it should (probably) stay
+ // that way to avoid regressions. HoverHandlers do not suffer from this limitation, and
+ // can therefore be used as a replacement to solve such cases.
QQuickItem::hoverEnterEvent(event);
} else {
d->lastPos = event->position();
@@ -843,7 +852,7 @@ void QQuickMouseArea::hoverMoveEvent(QHoverEvent *event)
void QQuickMouseArea::hoverLeaveEvent(QHoverEvent *event)
{
Q_D(QQuickMouseArea);
- if (!d->enabled && !d->pressed)
+ if (!d->enabled && !d->pressed && !d->hovered)
QQuickItem::hoverLeaveEvent(event);
else
setHovered(false);
@@ -1030,13 +1039,43 @@ void QQuickMouseArea::itemChange(ItemChange change, const ItemChangeData &value)
Q_D(QQuickMouseArea);
switch (change) {
case ItemVisibleHasChanged:
- if (d->effectiveEnable && d->enabled && acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse())) {
- if (!d->hovered) {
- QPointF cursorPos = QGuiApplicationPrivate::lastCursorPosition;
- d->lastScenePos = d->window->mapFromGlobal(cursorPos.toPoint());
- d->lastPos = mapFromScene(d->lastScenePos);
+ if (d->effectiveEnable && d->enabled && hoverEnabled()
+ && d->hovered != (isVisible() && isUnderMouse())) {
+ if (d->hovered) {
+ // If hovered but no longer under the mouse then un-hover.
+ setHovered(false);
+ } else {
+ // If under the mouse but not hovered then hover the QQuickMouseArea if it is
+ // marked as a hovered item under the windows QQuickDeliveryAgentPrivate instance.
+ // This is required as this QQuickMouseArea may be masked by another hoverable
+ // QQuickMouseArea higher up in the scenes z-index ordering.
+ QPointF globalPos{ QGuiApplicationPrivate::lastCursorPosition.toPoint() };
+ QPointF scenePos{ d->window->mapFromGlobal(globalPos) };
+
+ QQuickWindowPrivate *wd = QQuickWindowPrivate::get(d->window);
+ QQuickDeliveryAgentPrivate *dap = wd->deliveryAgentPrivate();
+
+ // If the QQuickDeliveryAgentPrivate has not already found a hovered leaf
+ // item then attempt to find one.
+ if (!dap->hoveredLeafItemFound) {
+ dap->deliverHoverEvent(scenePos, scenePos, Qt::NoModifier,
+ QDateTime::currentSecsSinceEpoch());
+ }
+
+ // Now if the QQuickDeliveryAgentPrivate has found a hovered leaf item check
+ // that this QQuickMouseArea item was one of the hovered items.
+ if (dap->hoveredLeafItemFound) {
+ for (auto hoverItem : dap->hoverItems) {
+ if (hoverItem.first == this) {
+ // Found a match so update the hover state.
+ d->lastScenePos = scenePos;
+ d->lastPos = mapFromScene(d->lastScenePos);
+ setHovered(true);
+ break;
+ }
+ }
+ }
}
- setHovered(!d->hovered);
}
if (d->pressed && (!isVisible())) {
// This happens when the mouse area sets itself disabled or hidden
@@ -1065,15 +1104,18 @@ void QQuickMouseArea::itemChange(ItemChange change, const ItemChangeData &value)
*/
bool QQuickMouseArea::hoverEnabled() const
{
- return acceptHoverEvents();
+ return d_func()->hoverEnabled;
}
void QQuickMouseArea::setHoverEnabled(bool h)
{
- if (h == acceptHoverEvents())
+ Q_D(QQuickMouseArea);
+ if (h == d->hoverEnabled)
return;
- setAcceptHoverEvents(h);
+ d->hoverEnabled = h;
+ setAcceptHoverEvents(h && d->enabled);
+
emit hoverEnabledChanged();
}
@@ -1082,8 +1124,10 @@ void QQuickMouseArea::setHoverEnabled(bool h)
\qmlproperty bool QtQuick::MouseArea::containsMouse
This property holds whether the mouse is currently inside the mouse area.
- \warning If hoverEnabled is false, containsMouse will only be valid
+ \warning If hoverEnabled is \c false, \c containsMouse will be \c true
when the mouse is pressed while the mouse cursor is inside the MouseArea.
+ But if you set \c {mouse.accepted = false} in an \c onPressed handler,
+ \c containsMouse will remain \c false because the press was rejected.
*/
bool QQuickMouseArea::hovered() const
{
@@ -1193,6 +1237,8 @@ bool QQuickMouseArea::setPressed(Qt::MouseButton button, bool p, Qt::MouseEventS
if (!me.isAccepted()) {
d->pressed = Qt::NoButton;
+ if (!hoverEnabled())
+ setHovered(false);
}
if (!oldPressed) {
diff --git a/src/quick/items/qquickmousearea_p_p.h b/src/quick/items/qquickmousearea_p_p.h
index 25287671a2..ede16e110b 100644
--- a/src/quick/items/qquickmousearea_p_p.h
+++ b/src/quick/items/qquickmousearea_p_p.h
@@ -51,6 +51,7 @@ public:
#endif
bool enabled : 1;
+ bool hoverEnabled : 1;
bool scrollGestureEnabled : 1;
bool hovered : 1;
bool longPress : 1;
diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp
index d594861ee7..fc994fd18c 100644
--- a/src/quick/items/qquickmultipointtoucharea.cpp
+++ b/src/quick/items/qquickmultipointtoucharea.cpp
@@ -419,7 +419,7 @@ QQuickMultiPointTouchArea::QQuickMultiPointTouchArea(QQuickItem *parent)
QQuickMultiPointTouchArea::~QQuickMultiPointTouchArea()
{
clearTouchLists();
- for (QObject *obj : qAsConst(_touchPoints)) {
+ for (QObject *obj : std::as_const(_touchPoints)) {
QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj);
if (!dtp->isQmlDefined())
delete dtp;
@@ -578,9 +578,9 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event, RemapEventPoints
break;
}
- int numTouchPoints = touchPoints.count();
+ int numTouchPoints = touchPoints.size();
//always remove released touches, and make sure we handle all releases before adds.
- for (const QEventPoint &p : qAsConst(touchPoints)) {
+ for (const QEventPoint &p : std::as_const(touchPoints)) {
QEventPoint::State touchPointState = p.state();
int id = p.id();
if (touchPointState & QEventPoint::State::Released) {
@@ -625,7 +625,7 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event, RemapEventPoints
if (!_stealMouse /* !ignoring gesture*/) {
bool offerGrab = false;
const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
- for (const QEventPoint &p : qAsConst(touchPoints)) {
+ for (const QEventPoint &p : std::as_const(touchPoints)) {
if (p.state() == QEventPoint::State::Released)
continue;
const QPointF &currentPos = p.scenePosition();
@@ -659,7 +659,7 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event, RemapEventPoints
void QQuickMultiPointTouchArea::clearTouchLists()
{
- for (QObject *obj : qAsConst(_releasedTouchPoints)) {
+ for (QObject *obj : std::as_const(_releasedTouchPoints)) {
QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj);
if (!dtp->isQmlDefined()) {
_touchPoints.remove(dtp->pointId());
@@ -676,7 +676,7 @@ void QQuickMultiPointTouchArea::clearTouchLists()
void QQuickMultiPointTouchArea::addTouchPoint(const QEventPoint *p)
{
QQuickTouchPoint *dtp = nullptr;
- for (QQuickTouchPoint* tp : qAsConst(_touchPrototypes)) {
+ for (QQuickTouchPoint* tp : std::as_const(_touchPrototypes)) {
if (!tp->inUse()) {
tp->setInUse(true);
dtp = tp;
@@ -696,7 +696,7 @@ void QQuickMultiPointTouchArea::addTouchPoint(const QEventPoint *p)
void QQuickMultiPointTouchArea::addTouchPoint(const QMouseEvent *e)
{
QQuickTouchPoint *dtp = nullptr;
- for (QQuickTouchPoint *tp : qAsConst(_touchPrototypes)) {
+ for (QQuickTouchPoint *tp : std::as_const(_touchPrototypes)) {
if (!tp->inUse()) {
tp->setInUse(true);
dtp = tp;
@@ -743,7 +743,7 @@ void QQuickMultiPointTouchArea::setTouchEventsEnabled(bool enable)
void QQuickMultiPointTouchArea::addTouchPrototype(QQuickTouchPoint *prototype)
{
- int id = _touchPrototypes.count();
+ int id = _touchPrototypes.size();
prototype->setPointId(id);
_touchPrototypes.insert(id, prototype);
}
@@ -796,7 +796,7 @@ void QQuickMultiPointTouchArea::mousePressEvent(QMouseEvent *event)
if (event->source() != Qt::MouseEventNotSynthesized && event->source() != Qt::MouseEventSynthesizedByQt)
return;
- if (_touchPoints.count() >= _minimumTouchPoints - 1 && _touchPoints.count() < _maximumTouchPoints) {
+ if (_touchPoints.size() >= _minimumTouchPoints - 1 && _touchPoints.size() < _maximumTouchPoints) {
updateTouchData(event);
}
}
@@ -844,13 +844,13 @@ void QQuickMultiPointTouchArea::ungrab(bool normalRelease)
if (!normalRelease)
ungrabTouchPoints();
- if (_touchPoints.count()) {
- for (QObject *obj : qAsConst(_touchPoints))
+ if (_touchPoints.size()) {
+ for (QObject *obj : std::as_const(_touchPoints))
static_cast<QQuickTouchPoint*>(obj)->setPressed(false);
if (!normalRelease)
emit canceled(_touchPoints.values());
clearTouchLists();
- for (QObject *obj : qAsConst(_touchPoints)) {
+ for (QObject *obj : std::as_const(_touchPoints)) {
QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj);
if (!dtp->isQmlDefined())
delete dtp;
diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h
index f6d2886716..f92705f28e 100644
--- a/src/quick/items/qquickmultipointtoucharea_p.h
+++ b/src/quick/items/qquickmultipointtoucharea_p.h
@@ -210,7 +210,7 @@ public:
static qsizetype touchPoint_count(QQmlListProperty<QQuickTouchPoint> *list) {
QQuickMultiPointTouchArea *q = static_cast<QQuickMultiPointTouchArea*>(list->object);
- return q->_touchPrototypes.count();
+ return q->_touchPrototypes.size();
}
static QQuickTouchPoint* touchPoint_at(QQmlListProperty<QQuickTouchPoint> *list, qsizetype index) {
diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp
index 83eb88ff3e..d363fbcd31 100644
--- a/src/quick/items/qquickpainteditem.cpp
+++ b/src/quick/items/qquickpainteditem.cpp
@@ -47,6 +47,8 @@ public:
\note It important to understand the performance implications such items
can incur. See QQuickPaintedItem::RenderTarget and
QQuickPaintedItem::renderTarget.
+
+ \sa {Scene Graph - Painted Item}, {Writing QML Extensions with C++}
*/
/*!
diff --git a/src/quick/items/qquickpalette.cpp b/src/quick/items/qquickpalette.cpp
index 9a72807fe1..d8d01a7588 100644
--- a/src/quick/items/qquickpalette.cpp
+++ b/src/quick/items/qquickpalette.cpp
@@ -33,7 +33,7 @@ static constexpr bool is_valid(QPalette::ColorGroup cg) noexcept
\internal
\class QQuickPalette
- \brief The QQuickPalette class contains color groups for each QML item state.
+ \brief Contains color groups for each QML item state.
\inmodule QtQuick
\since 6.0
@@ -48,7 +48,7 @@ static constexpr bool is_valid(QPalette::ColorGroup cg) noexcept
\inherits QQuickColorGroup
\inqmlmodule QtQuick
\ingroup qtquick-visual
- \brief The QQuickPalette class contains color groups for each QML item state.
+ \brief Contains color groups for each QML item state.
A palette consists of three color groups: Active, Disabled, and Inactive.
Active color group is the default group, its colors are used for other groups
@@ -108,7 +108,7 @@ static constexpr bool is_valid(QPalette::ColorGroup cg) noexcept
*/
/*!
- \qmlproperty QQuickColorGroup QtQuick::Palette::active
+ \qmlproperty ColorGroup QtQuick::Palette::active
The Active group is used for windows that are in focus.
@@ -116,7 +116,7 @@ static constexpr bool is_valid(QPalette::ColorGroup cg) noexcept
*/
/*!
- \qmlproperty QQuickColorGroup QtQuick::Palette::inactive
+ \qmlproperty ColorGroup QtQuick::Palette::inactive
The Inactive group is used for windows that have no keyboard focus.
@@ -124,7 +124,7 @@ static constexpr bool is_valid(QPalette::ColorGroup cg) noexcept
*/
/*!
- \qmlproperty QQuickColorGroup QtQuick::Palette::disabled
+ \qmlproperty ColorGroup QtQuick::Palette::disabled
The Disabled group is used for elements that are disabled for some reason.
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index 3b4ced67c3..3e30f410f0 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -210,10 +210,10 @@ void QQuickPathViewPrivate::clear()
currentItem = nullptr;
}
- for (QQuickItem *p : qAsConst(items))
+ for (QQuickItem *p : std::as_const(items))
releaseItem(p);
- for (QQuickItem *p : qAsConst(itemCache))
+ for (QQuickItem *p : std::as_const(itemCache))
releaseItem(p);
if (requestedIndex >= 0) {
@@ -386,7 +386,7 @@ void QQuickPathViewPrivate::setHighlightPosition(qreal pos)
void QQuickPathView::pathUpdated()
{
Q_D(QQuickPathView);
- for (QQuickItem *item : qAsConst(d->items)) {
+ for (QQuickItem *item : std::as_const(d->items)) {
if (QQuickPathViewAttached *att = d->attached(item))
att->m_percent = -1;
}
@@ -1619,21 +1619,21 @@ void QQuickPathView::mousePressEvent(QMouseEvent *event)
void QQuickPathViewPrivate::handleMousePressEvent(QMouseEvent *event)
{
Q_Q(QQuickPathView);
- if (!interactive || !items.count() || !model || !modelCount)
+ if (!interactive || !items.size() || !model || !modelCount)
return;
velocityBuffer.clear();
int idx = 0;
- for (; idx < items.count(); ++idx) {
+ for (; idx < items.size(); ++idx) {
QQuickItem *item = items.at(idx);
if (item->contains(item->mapFromScene(event->scenePosition())))
break;
}
- if (idx == items.count() && qFuzzyIsNull(dragMargin)) // didn't click on an item
+ if (idx == items.size() && qFuzzyIsNull(dragMargin)) // didn't click on an item
return;
startPoint = pointNear(event->position(), &startPc);
startPos = event->position();
- if (idx == items.count()) {
+ if (idx == items.size()) {
qreal distance = qAbs(event->position().x() - startPoint.x()) + qAbs(event->position().y() - startPoint.y());
if (distance > dragMargin)
return;
@@ -1978,7 +1978,7 @@ void QQuickPathView::refill()
bool waiting = false;
if (d->modelCount) {
// add items as needed
- if (d->items.count() < count+d->cacheSize) {
+ if (d->items.size() < count+d->cacheSize) {
int endIdx = 0;
qreal endPos;
int startIdx = 0;
@@ -1989,7 +1989,7 @@ void QQuickPathView::refill()
endPos = -1;
startPos = 2;
- for (QQuickItem * item : qAsConst(d->items)) {
+ for (QQuickItem * item : std::as_const(d->items)) {
int idx = d->model->indexOf(item, nullptr);
qreal curPos = d->positionOfIndex(idx);
if (curPos > endPos) {
@@ -2016,9 +2016,9 @@ void QQuickPathView::refill()
if (idx >= d->modelCount)
idx = 0;
qreal nextPos = d->positionOfIndex(idx);
- while ((d->isInBound(nextPos, endPos, 1 + d->mappedCache) || !d->items.count())
- && d->items.count() < count+d->cacheSize) {
- qCDebug(lcItemViewDelegateLifecycle) << "append" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count();
+ while ((d->isInBound(nextPos, endPos, 1 + d->mappedCache) || !d->items.size())
+ && d->items.size() < count+d->cacheSize) {
+ qCDebug(lcItemViewDelegateLifecycle) << "append" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.size();
QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1);
if (!item) {
waiting = true;
@@ -2049,8 +2049,8 @@ void QQuickPathView::refill()
idx = d->modelCount - 1;
nextPos = d->positionOfIndex(idx);
while (!waiting && d->isInBound(nextPos, d->mappedRange - d->mappedCache, startPos)
- && d->items.count() < count+d->cacheSize) {
- qCDebug(lcItemViewDelegateLifecycle) << "prepend" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count();
+ && d->items.size() < count+d->cacheSize) {
+ qCDebug(lcItemViewDelegateLifecycle) << "prepend" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.size();
QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1);
if (!item) {
waiting = true;
@@ -2078,8 +2078,8 @@ void QQuickPathView::refill()
// new items appear in the middle. This more generic addition iteration handles this
// Since this is the rare case, we try append/prepend first and only do this if
// there are gaps still left to fill.
- if (!waiting && d->items.count() < count+d->cacheSize) {
- qCDebug(lcItemViewDelegateLifecycle) << "Checking for pathview middle inserts, items count was" << d->items.count();
+ if (!waiting && d->items.size() < count+d->cacheSize) {
+ qCDebug(lcItemViewDelegateLifecycle) << "Checking for pathview middle inserts, items count was" << d->items.size();
idx = startIdx;
QQuickItem *lastItem = d->items.at(0);
while (idx != endIdx) {
@@ -2095,7 +2095,7 @@ void QQuickPathView::refill()
if (!d->items.contains(item)) { //We found a hole
qCDebug(lcItemViewDelegateLifecycle) << "middle insert" << idx << "@" << nextPos
<< (d->currentIndex == idx ? "current" : "")
- << "items count was" << d->items.count();
+ << "items count was" << d->items.size();
if (d->currentIndex == idx) {
currentVisible = true;
d->currentItemOffset = nextPos;
@@ -2149,7 +2149,7 @@ void QQuickPathView::refill()
if (QQuickPathViewAttached *att = d->attached(d->highlightItem))
att->setOnPath(currentVisible);
}
- for (QQuickItem *item : qAsConst(d->itemCache))
+ for (QQuickItem *item : std::as_const(d->itemCache))
d->releaseItem(item);
d->itemCache.clear();
@@ -2235,7 +2235,7 @@ void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
d->items.clear();
if (!d->modelCount) {
- for (QQuickItem * item : qAsConst(d->itemCache))
+ for (QQuickItem * item : std::as_const(d->itemCache))
d->releaseItem(item);
d->itemCache.clear();
d->offset = 0;
@@ -2288,7 +2288,7 @@ void QQuickPathView::movementEnding()
int QQuickPathViewPrivate::calcCurrentIndex()
{
int current = 0;
- if (modelCount && model && items.count()) {
+ if (modelCount && model && items.size()) {
offset = std::fmod(offset, qreal(modelCount));
if (offset < 0)
offset += modelCount;
@@ -2305,7 +2305,7 @@ void QQuickPathViewPrivate::createCurrentItem()
return;
bool inItems = false;
- for (QQuickItem *item : qAsConst(items)) {
+ for (QQuickItem *item : std::as_const(items)) {
if (model->indexOf(item, nullptr) == currentIndex) {
inItems = true;
break;
@@ -2360,7 +2360,7 @@ void QQuickPathViewPrivate::fixOffsetCallback(void *d)
void QQuickPathViewPrivate::fixOffset()
{
Q_Q(QQuickPathView);
- if (model && items.count()) {
+ if (model && items.size()) {
if (haveHighlightRange && (highlightRangeMode == QQuickPathView::StrictlyEnforceRange
|| snapMode != QQuickPathView::NoSnap)) {
int curr = calcCurrentIndex();
diff --git a/src/quick/items/qquickpincharea.cpp b/src/quick/items/qquickpincharea.cpp
index 02086bc4bd..d547fae6c9 100644
--- a/src/quick/items/qquickpincharea.cpp
+++ b/src/quick/items/qquickpincharea.cpp
@@ -324,7 +324,7 @@ void QQuickPinchArea::touchEvent(QTouchEvent *event)
void QQuickPinchArea::clearPinch(QTouchEvent *event)
{
Q_D(QQuickPinchArea);
- qCDebug(lcPA, "clear: %" PRIdQSIZETYPE " touchpoints", d->touchPoints.count());
+ qCDebug(lcPA, "clear: %" PRIdQSIZETYPE " touchpoints", d->touchPoints.size());
d->touchPoints.clear();
if (d->inPinch) {
d->inPinch = false;
@@ -354,12 +354,13 @@ void QQuickPinchArea::clearPinch(QTouchEvent *event)
}
}
setKeepTouchGrab(false);
+ setKeepMouseGrab(false);
}
void QQuickPinchArea::cancelPinch(QTouchEvent *event)
{
Q_D(QQuickPinchArea);
- qCDebug(lcPA, "cancel: %" PRIdQSIZETYPE " touchpoints", d->touchPoints.count());
+ qCDebug(lcPA, "cancel: %" PRIdQSIZETYPE " touchpoints", d->touchPoints.size());
d->touchPoints.clear();
if (d->inPinch) {
d->inPinch = false;
@@ -395,15 +396,17 @@ void QQuickPinchArea::cancelPinch(QTouchEvent *event)
event->setExclusiveGrabber(point, nullptr);
}
setKeepTouchGrab(false);
+ setKeepMouseGrab(false);
}
void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering)
{
Q_D(QQuickPinchArea);
- if (d->touchPoints.count() < 2) {
+ if (d->touchPoints.size() < 2) {
// A pinch gesture is not occurring, so stealing the grab is permitted.
setKeepTouchGrab(false);
+ setKeepMouseGrab(false);
// During filtering, there's no need to hold a grab for one point,
// because filtering happens for every event anyway.
// But if we receive the event via direct delivery, and give up the grab,
@@ -414,7 +417,7 @@ void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering)
event->setExclusiveGrabber(d->touchPoints.first(), nullptr);
}
- if (d->touchPoints.count() == 0) {
+ if (d->touchPoints.size() == 0) {
if (d->inPinch) {
d->inPinch = false;
QPointF pinchCenter = mapFromScene(d->sceneLastCenter);
@@ -427,6 +430,8 @@ void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering)
pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
pe.setPoint1(mapFromScene(d->lastPoint1));
pe.setPoint2(mapFromScene(d->lastPoint2));
+ setKeepTouchGrab(false);
+ setKeepMouseGrab(false);
emit pinchFinished(&pe);
d->pinchStartDist = 0;
d->pinchActivated = false;
@@ -439,7 +444,7 @@ void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering)
}
QEventPoint touchPoint1 = d->touchPoints.at(0);
- QEventPoint touchPoint2 = d->touchPoints.at(d->touchPoints. count() >= 2 ? 1 : 0);
+ QEventPoint touchPoint2 = d->touchPoints.at(d->touchPoints.size() >= 2 ? 1 : 0);
if (touchPoint1.state() == QEventPoint::State::Pressed)
d->sceneStartPoint1 = touchPoint1.scenePosition();
@@ -453,7 +458,7 @@ void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering)
// Pinch is not started unless there are exactly two touch points
// AND one or more of the points has just now been pressed (wasn't pressed already)
// AND both points are inside the bounds.
- if (d->touchPoints.count() == 2
+ if (d->touchPoints.size() == 2
&& (touchPoint1.state() == QEventPoint::State::Pressed || touchPoint2.state() == QEventPoint::State::Pressed) &&
bounds.contains(touchPoint1.position()) && bounds.contains(touchPoint2.position())) {
d->id1 = touchPoint1.id();
@@ -463,6 +468,8 @@ void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering)
d->initPinch = true;
event->setExclusiveGrabber(touchPoint1, this);
event->setExclusiveGrabber(touchPoint2, this);
+ setKeepTouchGrab(true);
+ setKeepMouseGrab(true);
}
if (d->pinchActivated && !d->pinchRejected) {
const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
@@ -473,7 +480,7 @@ void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering)
qreal dist = qSqrt(dx*dx + dy*dy);
QPointF sceneCenter = (p1 + p2)/2;
qreal angle = QLineF(p1, p2).angle();
- if (d->touchPoints.count() == 1) {
+ if (d->touchPoints.size() == 1) {
// If we only have one point then just move the center
if (d->id1 == touchPoint1.id())
sceneCenter = d->sceneLastCenter + touchPoint1.scenePosition() - d->lastPoint1;
@@ -487,7 +494,7 @@ void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering)
qCDebug(lcPA, "pinch \u2316 %.1lf,%.1lf \u21e4%.1lf\u21e5 \u2220 %.1lf",
sceneCenter.x(), sceneCenter.y(), dist, angle);
if (!d->inPinch || d->initPinch) {
- if (d->touchPoints.count() >= 2) {
+ if (d->touchPoints.size() >= 2) {
if (d->initPinch) {
if (!d->inPinch)
d->pinchStartDist = dist;
@@ -518,13 +525,16 @@ void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering)
pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
pe.setPoint1(mapFromScene(d->lastPoint1));
pe.setPoint2(mapFromScene(d->lastPoint2));
- pe.setPointCount(d->touchPoints.count());
+ pe.setPointCount(d->touchPoints.size());
emit pinchStarted(&pe);
if (pe.accepted()) {
d->inPinch = true;
event->setExclusiveGrabber(touchPoint1, this);
event->setExclusiveGrabber(touchPoint2, this);
setKeepTouchGrab(true);
+ // So that PinchArea works in PathView, grab mouse events too.
+ // We should be able to remove these setKeepMouseGrab calls when QTBUG-105567 is fixed.
+ setKeepMouseGrab(true);
d->inPinch = true;
if (d->pinch && d->pinch->target()) {
auto targetParent = pinch()->target()->parentItem();
@@ -558,7 +568,7 @@ void QQuickPinchArea::updatePinch(QTouchEvent *event, bool filtering)
pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
pe.setPoint1(touchPoint1.position());
pe.setPoint2(touchPoint2.position());
- pe.setPointCount(d->touchPoints.count());
+ pe.setPointCount(d->touchPoints.size());
d->pinchLastScale = scale;
d->sceneLastCenter = sceneCenter;
d->pinchLastAngle = angle;
diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp
index f7eca278ea..5bb1f4f6d9 100644
--- a/src/quick/items/qquickpositioners.cpp
+++ b/src/quick/items/qquickpositioners.cpp
@@ -223,7 +223,7 @@ void QQuickBasePositioner::componentComplete()
QQuickItem::componentComplete();
if (d->transitioner)
d->transitioner->setPopulateTransitionEnabled(true);
- positionedItems.reserve(childItems().count());
+ positionedItems.reserve(childItems().size());
prePositioning();
if (d->transitioner)
d->transitioner->setPopulateTransitionEnabled(false);
@@ -277,7 +277,7 @@ void QQuickBasePositioner::prePositioning()
unpositionedItems.clear();
int addedIndex = -1;
- for (int ii = 0; ii < children.count(); ++ii) {
+ for (int ii = 0; ii < children.size(); ++ii) {
QQuickItem *child = children.at(ii);
if (QQuickItemPrivate::get(child)->isTransparentForPositioner())
continue;
diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp
index 499856a3d2..7037526264 100644
--- a/src/quick/items/qquickrectangle.cpp
+++ b/src/quick/items/qquickrectangle.cpp
@@ -542,8 +542,13 @@ QSGNode *QQuickRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
if (d->pen && d->pen->isValid()) {
rectangle->setPenColor(d->pen->color());
- rectangle->setPenWidth(d->pen->width());
- rectangle->setAligned(d->pen->pixelAligned());
+ qreal penWidth = d->pen->width();
+ if (d->pen->pixelAligned()) {
+ qreal dpr = window() ? window()->effectiveDevicePixelRatio() : 1.0;
+ penWidth = qRound(penWidth * dpr) / dpr; // Ensures integer width after dpr scaling
+ }
+ rectangle->setPenWidth(penWidth);
+ rectangle->setAligned(false); // width rounding already done, so the Node should not do it
} else {
rectangle->setPenWidth(0);
}
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp
index b12667776c..62cfea12e3 100644
--- a/src/quick/items/qquickrendercontrol.cpp
+++ b/src/quick/items/qquickrendercontrol.cpp
@@ -193,7 +193,7 @@ void QQuickRenderControlPrivate::windowDestroyed()
QQuickWindowPrivate::get(window)->animationController.reset();
#if QT_CONFIG(quick_shadereffect)
- QSGRhiShaderEffectNode::cleanupMaterialTypeCache();
+ QSGRhiShaderEffectNode::cleanupMaterialTypeCache(window);
#endif
window = nullptr;
}
@@ -509,7 +509,7 @@ void QQuickRenderControlPrivate::maybeUpdate()
Reimplemented in subclasses to return the real window this render control
is rendering into.
- If \a offset in non-null, it is set to the offset of the control
+ If \a offset is non-null, it is set to the offset of the control
inside the window.
\note While not mandatory, reimplementing this function becomes essential for
@@ -521,7 +521,7 @@ void QQuickRenderControlPrivate::maybeUpdate()
/*!
Returns the real window that \a win is being rendered to, if any.
- If \a offset in non-null, it is set to the offset of the rendering
+ If \a offset is non-null, it is set to the offset of the rendering
inside its window.
*/
diff --git a/src/quick/items/qquickrendertarget.cpp b/src/quick/items/qquickrendertarget.cpp
index e29e8839ba..460ce7335f 100644
--- a/src/quick/items/qquickrendertarget.cpp
+++ b/src/quick/items/qquickrendertarget.cpp
@@ -591,6 +591,8 @@ QQuickRenderTarget QQuickRenderTarget::fromRhiRenderTarget(QRhiRenderTarget *ren
\note The QQuickRenderTarget does not take ownship of \a device, it is the
caller's responsibility to ensure the object exists as long as necessary.
+ \since 6.4
+
\sa QQuickWindow::setRenderTarget(), QQuickRenderControl
*/
QQuickRenderTarget QQuickRenderTarget::fromPaintDevice(QPaintDevice *device)
diff --git a/src/quick/items/qquickrepeater.cpp b/src/quick/items/qquickrepeater.cpp
index 811ea316fc..2c892a596c 100644
--- a/src/quick/items/qquickrepeater.cpp
+++ b/src/quick/items/qquickrepeater.cpp
@@ -297,7 +297,7 @@ int QQuickRepeater::count() const
QQuickItem *QQuickRepeater::itemAt(int index) const
{
Q_D(const QQuickRepeater);
- if (index >= 0 && index < d->deletables.count())
+ if (index >= 0 && index < d->deletables.size())
return d->deletables[index];
return nullptr;
}
@@ -329,14 +329,14 @@ void QQuickRepeater::clear()
if (d->model) {
// We remove in reverse order deliberately; so that signals are emitted
// with sensible indices.
- for (int i = d->deletables.count() - 1; i >= 0; --i) {
+ for (int i = d->deletables.size() - 1; i >= 0; --i) {
if (QQuickItem *item = d->deletables.at(i)) {
if (complete)
emit itemRemoved(i, item);
d->model->release(item);
}
}
- for (QQuickItem *item : qAsConst(d->deletables)) {
+ for (QQuickItem *item : std::as_const(d->deletables)) {
if (item)
item->setParentItem(nullptr);
}
@@ -441,8 +441,8 @@ void QQuickRepeater::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
int difference = 0;
QHash<int, QVector<QPointer<QQuickItem> > > moved;
for (const QQmlChangeSet::Change &remove : changeSet.removes()) {
- int index = qMin(remove.index, d->deletables.count());
- int count = qMin(remove.index + remove.count, d->deletables.count()) - index;
+ int index = qMin(remove.index, d->deletables.size());
+ int count = qMin(remove.index + remove.count, d->deletables.size()) - index;
if (remove.isMove()) {
moved.insert(remove.moveId, d->deletables.mid(index, count));
d->deletables.erase(
@@ -463,16 +463,16 @@ void QQuickRepeater::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
}
for (const QQmlChangeSet::Change &insert : changeSet.inserts()) {
- int index = qMin(insert.index, d->deletables.count());
+ int index = qMin(insert.index, d->deletables.size());
if (insert.isMove()) {
QVector<QPointer<QQuickItem> > items = moved.value(insert.moveId);
d->deletables = d->deletables.mid(0, index) + items + d->deletables.mid(index);
- QQuickItem *stackBefore = index + items.count() < d->deletables.count()
- ? d->deletables.at(index + items.count())
+ QQuickItem *stackBefore = index + items.size() < d->deletables.size()
+ ? d->deletables.at(index + items.size())
: this;
if (stackBefore) {
- for (int i = index; i < index + items.count(); ++i) {
- if (i < d->deletables.count()) {
+ for (int i = index; i < index + items.size(); ++i) {
+ if (i < d->deletables.size()) {
QPointer<QQuickItem> item = d->deletables.at(i);
if (item)
item->stackBefore(stackBefore);
diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp
index 97d0c581b7..4b6505c998 100644
--- a/src/quick/items/qquickshadereffect.cpp
+++ b/src/quick/items/qquickshadereffect.cpp
@@ -1129,6 +1129,8 @@ QSGNode *QQuickShaderEffectImpl::handleUpdatePaintNode(QSGNode *oldNode, QQuickI
sd.fragment.shader = &m_shaders[Fragment];
sd.fragment.dirtyConstants = &m_dirtyConstants[Fragment];
sd.fragment.dirtyTextures = &m_dirtyTextures[Fragment];
+ sd.materialTypeCacheKey = m_item->window();
+
node->syncMaterial(&sd);
if (m_dirty & QSGShaderEffectNode::DirtyShaderMesh) {
@@ -1207,6 +1209,7 @@ bool QQuickShaderEffectImpl::updateUniformValue(const QByteArray &name, const QV
sd.fragment.shader = &m_shaders[Fragment];
sd.fragment.dirtyConstants = &dirtyConstants[Fragment];
sd.fragment.dirtyTextures = {};
+ sd.materialTypeCacheKey = m_item->window();
node->syncMaterial(&sd);
@@ -1218,7 +1221,7 @@ void QQuickShaderEffectImpl::handleItemChange(QQuickItem::ItemChange change, con
// Move the window ref.
if (change == QQuickItem::ItemSceneChange) {
for (int shaderType = 0; shaderType < NShader; ++shaderType) {
- for (const auto &vd : qAsConst(m_shaders[shaderType].varData)) {
+ for (const auto &vd : std::as_const(m_shaders[shaderType].varData)) {
if (vd.specialType == QSGShaderEffectNode::VariableData::Source) {
QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(vd.value));
if (source) {
@@ -1260,7 +1263,7 @@ void QQuickShaderEffectImpl::disconnectSignals(Shader shaderType)
if (mapper)
QObjectPrivate::disconnect(m_item, mapper->signalIndex(), &a);
}
- for (const auto &vd : qAsConst(m_shaders[shaderType].varData)) {
+ for (const auto &vd : std::as_const(m_shaders[shaderType].varData)) {
if (vd.specialType == QSGShaderEffectNode::VariableData::Source) {
QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(vd.value));
if (source) {
@@ -1274,7 +1277,7 @@ void QQuickShaderEffectImpl::disconnectSignals(Shader shaderType)
void QQuickShaderEffectImpl::clearMappers(QQuickShaderEffectImpl::Shader shaderType)
{
- for (auto *mapper : qAsConst(m_mappers[shaderType])) {
+ for (auto *mapper : std::as_const(m_mappers[shaderType])) {
if (mapper)
mapper->destroyIfLastRef();
}
@@ -1311,7 +1314,7 @@ bool QQuickShaderEffectImpl::updateShader(Shader shaderType, const QUrl &fileUrl
disconnectSignals(shaderType);
- m_shaders[shaderType].shaderInfo = QSGGuiThreadShaderEffectManager::ShaderInfo();
+ m_shaders[shaderType].shaderInfo.variables.clear();
m_shaders[shaderType].varData.clear();
if (!fileUrl.isEmpty()) {
@@ -1348,7 +1351,7 @@ bool QQuickShaderEffectImpl::updateShader(Shader shaderType, const QUrl &fileUrl
// provided and monitored like with an application-provided shader.
QSGGuiThreadShaderEffectManager::ShaderInfo::Variable v;
v.name = QByteArrayLiteral("source");
- v.bindPoint = 0; // fake
+ v.bindPoint = 1; // fake, must match the default source bindPoint in qquickshadereffectnode.cpp
v.type = texturesSeparate ? QSGGuiThreadShaderEffectManager::ShaderInfo::Texture
: QSGGuiThreadShaderEffectManager::ShaderInfo::Sampler;
m_shaders[shaderType].shaderInfo.variables.append(v);
@@ -1399,7 +1402,7 @@ void QQuickShaderEffectImpl::updateShaderVars(Shader shaderType)
const bool texturesSeparate = mgr->hasSeparateSamplerAndTextureObjects();
- const int varCount = m_shaders[shaderType].shaderInfo.variables.count();
+ const int varCount = m_shaders[shaderType].shaderInfo.variables.size();
m_shaders[shaderType].varData.resize(varCount);
// Recreate signal mappers when the shader has changed.
@@ -1496,7 +1499,7 @@ void QQuickShaderEffectImpl::updateShaderVars(Shader shaderType)
bool QQuickShaderEffectImpl::sourceIsUnique(QQuickItem *source, Shader typeToSkip, int indexToSkip) const
{
for (int shaderType = 0; shaderType < NShader; ++shaderType) {
- for (int idx = 0; idx < m_shaders[shaderType].varData.count(); ++idx) {
+ for (int idx = 0; idx < m_shaders[shaderType].varData.size(); ++idx) {
if (shaderType != typeToSkip || idx != indexToSkip) {
const auto &vd(m_shaders[shaderType].varData[idx]);
if (vd.specialType == QSGShaderEffectNode::VariableData::Source && qvariant_cast<QObject *>(vd.value) == source)
@@ -1511,7 +1514,7 @@ std::optional<int> QQuickShaderEffectImpl::findMappedShaderVariableId(const QByt
{
for (int shaderType = 0; shaderType < NShader; ++shaderType) {
const auto &vars = m_shaders[shaderType].shaderInfo.variables;
- for (int idx = 0; idx < vars.count(); ++idx) {
+ for (int idx = 0; idx < vars.size(); ++idx) {
if (vars[idx].name == name)
return indexToMappedId(shaderType, idx);
}
@@ -1527,10 +1530,11 @@ void QQuickShaderEffectImpl::propertyChanged(int mappedId)
const auto &v(m_shaders[type].shaderInfo.variables[idx]);
auto &vd(m_shaders[type].varData[idx]);
+ QVariant oldValue = vd.value;
vd.value = getValueFromProperty(m_item, m_itemMetaObject, v.name, vd.propertyIndex);
if (vd.specialType == QSGShaderEffectNode::VariableData::Source) {
- QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(vd.value));
+ QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(oldValue));
if (source) {
if (m_item->window())
QQuickItemPrivate::get(source)->derefWindow();
diff --git a/src/quick/items/qquickshadereffectmesh.cpp b/src/quick/items/qquickshadereffectmesh.cpp
index 118ae18df5..2acd1bcf31 100644
--- a/src/quick/items/qquickshadereffectmesh.cpp
+++ b/src/quick/items/qquickshadereffectmesh.cpp
@@ -54,7 +54,7 @@ QQuickGridMesh::QQuickGridMesh(QObject *parent)
bool QQuickGridMesh::validateAttributes(const QList<QByteArray> &attributes, int *posIndex)
{
- const int attrCount = attributes.count();
+ const int attrCount = attributes.size();
int positionIndex = attributes.indexOf(qtPositionAttributeName());
int texCoordIndex = attributes.indexOf(qtTexCoordAttributeName());
diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp
index fd5b28b2ed..5d33092e6d 100644
--- a/src/quick/items/qquickspriteengine.cpp
+++ b/src/quick/items/qquickspriteengine.cpp
@@ -267,7 +267,7 @@ int QQuickSpriteEngine::spriteCount() const //TODO: Actually image state count,
void QQuickStochasticEngine::setGoal(int state, int sprite, bool jump)
{
- if (sprite >= m_things.count() || state >= m_states.count()
+ if (sprite >= m_things.size() || state >= m_states.size()
|| sprite < 0 || state < 0)
return;
if (!jump){
@@ -316,12 +316,13 @@ void QQuickSpriteEngine::startAssemblingImage()
return;
m_loaded = false;
m_errorsPrinted = false;
+ m_sprites.clear();
//This could also trigger the start of the image loading in Sprites, however that currently happens in Sprite::setSource
QList<QQuickStochasticState*> removals;
- for (QQuickStochasticState* s : qAsConst(m_states)) {
+ for (QQuickStochasticState* s : std::as_const(m_states)) {
QQuickSprite* sprite = qobject_cast<QQuickSprite*>(s);
if (sprite) {
m_sprites << sprite;
@@ -330,7 +331,7 @@ void QQuickSpriteEngine::startAssemblingImage()
qDebug() << "Error: Non-sprite in QQuickSpriteEngine";
}
}
- for (QQuickStochasticState* s : qAsConst(removals))
+ for (QQuickStochasticState* s : std::as_const(removals))
m_states.removeAll(s);
m_startedImageAssembly = true;
}
@@ -339,7 +340,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize)
{
QQuickPixmap::Status stat = status();
if (!m_errorsPrinted && stat == QQuickPixmap::Error) {
- for (QQuickSprite* s : qAsConst(m_sprites))
+ for (QQuickSprite* s : std::as_const(m_sprites))
if (s->m_pix.isError())
qmlWarning(s) << s->m_pix.error();
m_errorsPrinted = true;
@@ -354,7 +355,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize)
m_imageStateCount = 0;
qreal pixelRatio = 1.0;
- for (QQuickSprite* state : qAsConst(m_sprites)) {
+ for (QQuickSprite* state : std::as_const(m_sprites)) {
if (state->frames() > m_maxFrames)
m_maxFrames = state->frames();
@@ -414,7 +415,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize)
image.fill(0);
QPainter p(&image);
int y = 0;
- for (QQuickSprite* state : qAsConst(m_sprites)) {
+ for (QQuickSprite* state : std::as_const(m_sprites)) {
QImage img(state->m_pix.image());
const int frameWidth = state->m_frameWidth;
const int frameHeight = state->m_frameHeight;
@@ -488,7 +489,7 @@ void QQuickStochasticEngine::setCount(int c)
void QQuickStochasticEngine::start(int index, int state)
{
- if (index >= m_things.count())
+ if (index >= m_things.size())
return;
m_things[index] = state;
m_duration[index] = m_states.at(state)->variedDuration();
@@ -504,10 +505,10 @@ void QQuickStochasticEngine::start(int index, int state)
void QQuickStochasticEngine::stop(int index)
{
- if (index >= m_things.count())
+ if (index >= m_things.size())
return;
//Will never change until start is called again with a new state (or manually advanced) - this is not a 'pause'
- for (int i=0; i<m_stateUpdates.count(); i++)
+ for (int i=0; i<m_stateUpdates.size(); i++)
m_stateUpdates[i].second.removeAll(index);
}
@@ -520,7 +521,7 @@ void QQuickStochasticEngine::restart(int index)
if (randomStart)
m_startTimes[index] -= QRandomGenerator::global()->bounded(m_duration.at(index));
int time = m_duration.at(index) + m_startTimes.at(index);
- for (int i=0; i<m_stateUpdates.count(); i++)
+ for (int i=0; i<m_stateUpdates.size(); i++)
m_stateUpdates[i].second.removeAll(index);
if (m_duration.at(index) >= 0)
addToUpdateList(time, index);
@@ -546,7 +547,7 @@ void QQuickSpriteEngine::restart(int index) //Reimplemented to recognize and han
time += spriteDuration(index);
}
- for (int i=0; i<m_stateUpdates.count(); i++)
+ for (int i=0; i<m_stateUpdates.size(); i++)
m_stateUpdates[i].second.removeAll(index);
addToUpdateList(time, index);
}
@@ -554,7 +555,7 @@ void QQuickSpriteEngine::restart(int index) //Reimplemented to recognize and han
void QQuickStochasticEngine::advance(int idx)
{
- if (idx >= m_things.count())
+ if (idx >= m_things.size())
return;//TODO: Proper fix(because this has happened and I just ignored it)
int nextIdx = nextState(m_things.at(idx), idx);
m_things[idx] = nextIdx;
@@ -571,7 +572,7 @@ void QQuickSpriteEngine::advance(int idx) //Reimplemented to recognize and handl
return;
}
- if (idx >= m_things.count())
+ if (idx >= m_things.size())
return;//TODO: Proper fix(because this has happened and I just ignored it)
if (m_duration.at(idx) == 0) {
if (m_sprites.at(m_things.at(idx))->frameSync()) {
@@ -614,7 +615,7 @@ int QQuickStochasticEngine::nextState(int curState, int curThing)
iter!=m_states.at(curState)->m_to.constEnd(); ++iter){
if (r < (*iter).toReal()){
bool superBreak = false;
- for (int i=0; i<m_states.count(); i++){
+ for (int i=0; i<m_states.size(); i++){
if (m_states.at(i)->name() == iter.key()){
nextIdx = i;
superBreak = true;
@@ -640,7 +641,7 @@ uint QQuickStochasticEngine::updateSprites(uint time)//### would returning a lis
m_timeOffset = time;
m_addAdvance = false;
int i = 0;
- for (; i < m_stateUpdates.count() && time >= m_stateUpdates.at(i).first; ++i) {
+ for (; i < m_stateUpdates.size() && time >= m_stateUpdates.at(i).first; ++i) {
const auto copy = m_stateUpdates.at(i).second;
for (int idx : copy)
advance(idx);
@@ -665,16 +666,16 @@ int QQuickStochasticEngine::goalSeek(int curIdx, int spriteIdx, int dist)
return -1;
//TODO: caching instead of excessively redoing iterative deepening (which was chosen arbitrarily anyways)
// Paraphrased - implement in an *efficient* manner
- for (int i=0; i<m_states.count(); i++)
+ for (int i=0; i<m_states.size(); i++)
if (m_states.at(curIdx)->name() == goalName)
return curIdx;
if (dist < 0)
- dist = m_states.count();
+ dist = m_states.size();
QQuickStochasticState* curState = m_states.at(curIdx);
for (QVariantMap::const_iterator iter = curState->m_to.constBegin();
iter!=curState->m_to.constEnd(); ++iter){
if (iter.key() == goalName)
- for (int i=0; i<m_states.count(); i++)
+ for (int i=0; i<m_states.size(); i++)
if (m_states.at(i)->name() == goalName)
return i;
}
@@ -683,7 +684,7 @@ int QQuickStochasticEngine::goalSeek(int curIdx, int spriteIdx, int dist)
for (QVariantMap::const_iterator iter = curState->m_to.constBegin();
iter!=curState->m_to.constEnd(); ++iter){
int option = -1;
- for (int j=0; j<m_states.count(); j++)//One place that could be a lot more efficient...
+ for (int j=0; j<m_states.size(); j++)//One place that could be a lot more efficient...
if (m_states.at(j)->name() == iter.key())
if (goalSeek(j, spriteIdx, i) != -1)
option = j;
@@ -691,7 +692,7 @@ int QQuickStochasticEngine::goalSeek(int curIdx, int spriteIdx, int dist)
options << option;
}
if (!options.isEmpty()){
- if (options.count()==1)
+ if (options.size()==1)
return *(options.begin());
int option = -1;
qreal r = QRandomGenerator::global()->generateDouble();
@@ -703,7 +704,7 @@ int QQuickStochasticEngine::goalSeek(int curIdx, int spriteIdx, int dist)
for (QVariantMap::const_iterator iter = curState->m_to.constBegin();
iter!=curState->m_to.constEnd(); ++iter){
bool superContinue = true;
- for (int j=0; j<m_states.count(); j++)
+ for (int j=0; j<m_states.size(); j++)
if (m_states.at(j)->name() == iter.key())
if (options.contains(j))
superContinue = false;
@@ -711,7 +712,7 @@ int QQuickStochasticEngine::goalSeek(int curIdx, int spriteIdx, int dist)
continue;
if (r < (*iter).toReal()){
bool superBreak = false;
- for (int j=0; j<m_states.count(); j++){
+ for (int j=0; j<m_states.size(); j++){
if (m_states.at(j)->name() == iter.key()){
option = j;
superBreak = true;
@@ -731,7 +732,7 @@ int QQuickStochasticEngine::goalSeek(int curIdx, int spriteIdx, int dist)
void QQuickStochasticEngine::addToUpdateList(uint t, int idx)
{
- for (int i=0; i<m_stateUpdates.count(); i++){
+ for (int i=0; i<m_stateUpdates.size(); i++){
if (m_stateUpdates.at(i).first == t){
m_stateUpdates[i].second << idx;
return;
diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h
index 3b74df241a..ee2fa34f72 100644
--- a/src/quick/items/qquickspriteengine_p.h
+++ b/src/quick/items/qquickspriteengine_p.h
@@ -168,7 +168,7 @@ public:
return m_globalGoal;
}
- int count() const {return m_things.count();}
+ int count() const {return m_things.size();}
void setCount(int c);
void setGoal(int state, int sprite=0, bool jump=false);
@@ -181,13 +181,13 @@ public:
QQuickStochasticState* state(int idx) const {return m_states[idx];}
int stateIndex(QQuickStochasticState* s) const {return m_states.indexOf(s);}
int stateIndex(const QString& s) const {
- for (int i=0; i<m_states.count(); i++)
+ for (int i=0; i<m_states.size(); i++)
if (m_states[i]->name() == s)
return i;
return -1;
}
- int stateCount() {return m_states.count();}
+ int stateCount() {return m_states.size();}
private:
Q_SIGNALS:
@@ -291,7 +291,7 @@ inline void spriteClear(QQmlListProperty<QQuickSprite> *p)
inline qsizetype spriteCount(QQmlListProperty<QQuickSprite> *p)
{
- return reinterpret_cast<QList<QQuickSprite *> *>(p->data)->count();
+ return reinterpret_cast<QList<QQuickSprite *> *>(p->data)->size();
}
inline void spriteReplace(QQmlListProperty<QQuickSprite> *p, qsizetype idx, QQuickSprite *s)
diff --git a/src/quick/items/qquickspritesequence.cpp b/src/quick/items/qquickspritesequence.cpp
index 7e005935e4..4feb3402b1 100644
--- a/src/quick/items/qquickspritesequence.cpp
+++ b/src/quick/items/qquickspritesequence.cpp
@@ -161,7 +161,7 @@ void QQuickSpriteSequence::createEngine()
//TODO: delay until component complete
if (d->m_spriteEngine)
delete d->m_spriteEngine;
- if (d->m_sprites.count()) {
+ if (d->m_sprites.size()) {
d->m_spriteEngine = new QQuickSpriteEngine(d->m_sprites, this);
if (!d->m_goalState.isEmpty())
d->m_spriteEngine->setGoal(d->m_spriteEngine->stateIndex(d->m_goalState));
diff --git a/src/quick/items/qquickstateoperations.cpp b/src/quick/items/qquickstateoperations.cpp
index 9e1d771364..a6e5eed56c 100644
--- a/src/quick/items/qquickstateoperations.cpp
+++ b/src/quick/items/qquickstateoperations.cpp
@@ -504,7 +504,7 @@ void QQuickParentChange::saveCurrentValues()
return;
QList<QQuickItem *> children = d->rewind->parent->childItems();
- for (int ii = 0; ii < children.count() - 1; ++ii) {
+ for (int ii = 0; ii < children.size() - 1; ++ii) {
if (children.at(ii) == d->target) {
d->rewind->stackBefore = children.at(ii + 1);
break;
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 54781968b4..cc5c45db72 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -188,13 +188,80 @@
\note \l{Qt Quick Controls} offers a SelectionRectangle that can be used
to let the user select cells.
+ \note By default, a cell will become
+ \l {QQuickItemSelectionModel::currentIndex()}{current}, and any selections will
+ be removed, when the user taps on it. If such default tap behavior is not wanted
+ (e.g if you use custom pointer handlers inside your delegate), you can set
+ \l pointerNavigationEnabled to \c false.
+
\section1 Keyboard navigation
In order to support keyboard navigation, you need to assign an \l ItemSelectionModel
to the \l selectionModel property. TableView will then use this model to manipulate
- the model's \l {QQuickItemSelectionModel::currentIndex()}{currentIndex}. You can
+ the model's \l {ItemSelectionModel::currentIndex}{currentIndex}. You can
disable keyboard navigation fully (in case you want to implement your own key
handlers) by setting \l keyNavigationEnabled to \c false.
+
+ \section1 Copy and paste
+
+ Implementing copy and paste operations for a TableView usually also includes using
+ a QUndoStack (or some other undo/redo framework). The QUndoStack can be used to
+ store the different operations done on the model, like adding or removing rows, or
+ pasting data from the clipboard, with a way to undo it again later. However, an
+ accompanying QUndoStack that describes the possible operations, and how to undo them,
+ should be designed according to the needs of the model and the application.
+ As such, TableView doesn't offer a built-in API for handling copy and paste.
+
+ The following snippet can be used as a reference for how to add copy and paste support
+ to your model and TableView. It uses the existing mime data API in QAbstractItemModel,
+ together with QClipboard. The snippet will work as it is, but can also be extended to
+ use a QUndoStack.
+
+ \code
+ // Inside your C++ QAbstractTableModel subclass:
+
+ Q_INVOKABLE void copyToClipboard(const QModelIndexList &indexes) const
+ {
+ QGuiApplication::clipboard()->setMimeData(mimeData(indexes));
+ }
+
+ Q_INVOKABLE bool pasteFromClipboard(const QModelIndex &targetIndex)
+ {
+ const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData();
+ // Consider using a QUndoCommand for the following call. It should store
+ // the (mime) data for the model items that are about to be overwritten, so
+ // that a later call to undo can revert it.
+ return dropMimeData(mimeData, Qt::CopyAction, -1, -1, targetIndex);
+ }
+ \endcode
+
+ The two functions can, for example, be used from QML like this:
+
+ \code
+ TableView {
+ id: tableView
+ model: tableModel
+ selectionModel: ItemSelectionModel {}
+
+ Shortcut {
+ sequence: StandardKey.Copy
+ onActivated: {
+ let indexes = tableView.selectionModel.selectedIndexes
+ tableView.model.copyToClipboard(indexes)
+ }
+ }
+
+ Shortcut {
+ sequence: StandardKey.Paste
+ onActivated: {
+ let targetIndex = tableView.selectionModel.currentIndex
+ tableView.model.pasteFromClipboard(targetIndex)
+ }
+ }
+ }
+ \endcode
+
+ \sa mimeData(), dropMimeData(), QUndoStack, QUndoCommand, QClipboard
*/
/*!
@@ -792,13 +859,14 @@
/*!
\qmlmethod QModelIndex QtQuick::TableView::modelIndex(int column, int row)
\since 6.4
+ \deprecated
- Returns the \l QModelIndex that maps to \a column and \a row in the view.
-
- \a row and \a column should be the row and column in the view (table row and
- table column), and not a row and column in the model.
+ Use \l index(row, column) instead.
- \sa rowAtIndex(), columnAtIndex()
+ \note Because of an API incompatible change between Qt 6.4.0 and Qt 6.4.2, the
+ order of \c row and \c column was specified in the opposite order. If you
+ rely on the order to be \c {modelIndex(column, row)}, you can set the
+ environment variable \c QT_QUICK_TABLEVIEW_COMPAT_VERSION to \c 6.4
*/
/*!
@@ -811,8 +879,25 @@
\endcode
A cell is simply a \l point that combines row and column into
- a single type. Note that \c point.x will map to the column, and
- \c point.y will map to the row.
+ a single type.
+
+ \note \c {point.x} will map to the column, and \c {point.y} will map to the row.
+*/
+
+/*!
+ \qmlmethod QModelIndex QtQuick::TableView::index(int row, int column)
+ \since 6.4.3
+
+ Returns the \l QModelIndex that maps to \a row and \a column in the view.
+
+ \a row and \a column should be the row and column in the view (table row and
+ table column), and not a row and column in the model. For a plain
+ TableView, this is equivalent of calling \c {model.index(row, column).}
+ But for a subclass of TableView, like TreeView, where the data model is
+ wrapped inside an internal proxy model that flattens the tree structure
+ into a table, you need to use this function to resolve the model index.
+
+ \sa rowAtIndex(), columnAtIndex()
*/
/*!
@@ -821,7 +906,7 @@
Returns the row in the view that maps to \a modelIndex in the model.
- \sa columnAtIndex(), modelIndex()
+ \sa columnAtIndex(), index()
*/
/*!
@@ -830,7 +915,7 @@
Returns the column in the view that maps to \a modelIndex in the model.
- \sa rowAtIndex(), modelIndex()
+ \sa rowAtIndex(), index()
*/
/*!
@@ -845,8 +930,10 @@
\endcode
A cell is simply a \l point that combines row and column into
- a single type. Note that \c point.x will map to the column, and
- \c point.y will map to the row.
+ a single type.
+
+ \note that \c {point.x} will map to the column, and
+ \c {point.y} will map to the row.
*/
/*!
@@ -1693,7 +1780,7 @@ void QQuickTableViewPrivate::updateExtents()
relayoutTableItems();
// Inform the sync children that they need to rebuild to stay in sync
- for (auto syncChild : qAsConst(syncChildren)) {
+ for (auto syncChild : std::as_const(syncChildren)) {
auto syncChild_d = syncChild->d_func();
syncChild_d->scheduledRebuildOptions |= RebuildOption::ViewportOnly;
if (tableMovedHorizontally)
@@ -2687,19 +2774,20 @@ void QQuickTableViewPrivate::processRebuildTable()
if (rebuildState == RebuildState::LayoutTable) {
layoutAfterLoadingInitialTable();
+ loadAndUnloadVisibleEdges();
if (!moveToNextRebuildState())
return;
}
- if (rebuildState == RebuildState::LoadAndUnloadAfterLayout) {
+ if (rebuildState == RebuildState::CancelOvershoot) {
+ cancelOvershootAfterLayout();
loadAndUnloadVisibleEdges();
if (!moveToNextRebuildState())
return;
}
- if (rebuildState == RebuildState::CancelOvershoot) {
- cancelOvershootAfterLayout();
- loadAndUnloadVisibleEdges();
+ if (rebuildState == RebuildState::UpdateContentSize) {
+ updateContentSize();
if (!moveToNextRebuildState())
return;
}
@@ -2961,12 +3049,8 @@ void QQuickTableViewPrivate::loadInitialTable()
loadAndUnloadVisibleEdges();
}
-void QQuickTableViewPrivate::layoutAfterLoadingInitialTable()
+void QQuickTableViewPrivate::updateContentSize()
{
- clearEdgeSizeCache();
- relayoutTableItems();
- syncLoadedTableRectFromLoadedTable();
-
const bool allColumnsLoaded = atTableEnd(Qt::LeftEdge) && atTableEnd(Qt::RightEdge);
if (rebuildOptions.testFlag(RebuildOption::CalculateNewContentWidth) || allColumnsLoaded) {
updateAverageColumnWidth();
@@ -2980,6 +3064,16 @@ void QQuickTableViewPrivate::layoutAfterLoadingInitialTable()
}
updateExtents();
+}
+
+void QQuickTableViewPrivate::layoutAfterLoadingInitialTable()
+{
+ clearEdgeSizeCache();
+ relayoutTableItems();
+ syncLoadedTableRectFromLoadedTable();
+
+ updateContentSize();
+
adjustViewportXAccordingToAlignment();
adjustViewportYAccordingToAlignment();
}
@@ -3098,7 +3192,7 @@ void QQuickTableViewPrivate::unloadEdge(Qt::Edge edge)
void QQuickTableViewPrivate::loadEdge(Qt::Edge edge, QQmlIncubator::IncubationMode incubationMode)
{
const int edgeIndex = nextVisibleEdgeIndexAroundLoadedTable(edge);
- qCDebug(lcTableViewDelegateLifecycle) << edge << edgeIndex;
+ qCDebug(lcTableViewDelegateLifecycle) << edge << edgeIndex << q_func();
const auto &visibleCells = edge & (Qt::LeftEdge | Qt::RightEdge)
? loadedRows.values() : loadedColumns.values();
@@ -3653,6 +3747,13 @@ void QQuickTableViewPrivate::syncSyncView()
q->setLeftMargin(syncView->leftMargin());
q->setRightMargin(syncView->rightMargin());
updateContentWidth();
+
+ if (syncView->leftColumn() != q->leftColumn()) {
+ // The left column is no longer the same as the left
+ // column in syncView. This requires a rebuild.
+ scheduledRebuildOptions |= QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftColumn;
+ scheduledRebuildOptions.setFlag(RebuildOption::ViewportOnly);
+ }
}
if (syncVertically) {
@@ -3661,6 +3762,13 @@ void QQuickTableViewPrivate::syncSyncView()
q->setTopMargin(syncView->topMargin());
q->setBottomMargin(syncView->bottomMargin());
updateContentHeight();
+
+ if (syncView->topRow() != q->topRow()) {
+ // The top row is no longer the same as the top
+ // row in syncView. This requires a rebuild.
+ scheduledRebuildOptions |= QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftRow;
+ scheduledRebuildOptions.setFlag(RebuildOption::ViewportOnly);
+ }
}
if (syncView && loadedItems.isEmpty() && !tableSize.isEmpty()) {
@@ -4010,10 +4118,26 @@ void QQuickTableViewPrivate::setLocalViewportY(qreal contentY)
void QQuickTableViewPrivate::syncViewportRect()
{
- // Sync viewportRect so that it contains the actual geometry of the viewport
+ // Sync viewportRect so that it contains the actual geometry of the viewport.
+ // Since the column (and row) size of a sync child is decided by the column size
+ // of its sync view, the viewport width of a sync view needs to be the maximum of
+ // the sync views width, and its sync childrens width. This to ensure that no sync
+ // child loads a column which is not yet loaded by the sync view, since then the
+ // implicit column size cannot be resolved.
Q_Q(QQuickTableView);
- viewportRect = QRectF(q->contentX(), q->contentY(), q->width(), q->height());
- qCDebug(lcTableViewDelegateLifecycle) << viewportRect;
+
+ qreal w = q->width();
+ qreal h = q->height();
+
+ for (auto syncChild : std::as_const(syncChildren)) {
+ auto syncChild_d = syncChild->d_func();
+ if (syncChild_d->syncHorizontally)
+ w = qMax(w, syncChild->width());
+ if (syncChild_d->syncHorizontally)
+ h = qMax(h, syncChild->height());
+ }
+
+ viewportRect = QRectF(q->contentX(), q->contentY(), w, h);
}
void QQuickTableViewPrivate::init()
@@ -4030,7 +4154,7 @@ void QQuickTableViewPrivate::init()
positionYAnimation.setProperty(QStringLiteral("contentY"));
positionYAnimation.setEasing(QEasingCurve::OutQuart);
- auto tapHandler = new QQuickTapHandler(q->contentItem());
+ auto tapHandler = new QQuickTableViewTapHandler(q);
QObject::connect(tapHandler, &QQuickTapHandler::pressedChanged, [this, q, tapHandler] {
if (!pointerNavigationEnabled || !tapHandler->isPressed())
@@ -4071,7 +4195,7 @@ void QQuickTableViewPrivate::syncViewportPosRecursive()
}
}
- for (auto syncChild : qAsConst(syncChildren)) {
+ for (auto syncChild : std::as_const(syncChildren)) {
auto syncChild_d = syncChild->d_func();
if (!syncChild_d->inSyncViewportPosRecursive) {
if (syncChild_d->syncHorizontally)
@@ -4634,14 +4758,22 @@ void QQuickTableView::positionViewAtColumn(int column, PositionMode mode, qreal
void QQuickTableView::positionViewAtCell(const QPoint &cell, PositionMode mode, const QPointF &offset, const QRectF &subRect)
{
- positionViewAtRow(cell.y(), mode, offset.y(), subRect);
- positionViewAtColumn(cell.x(), mode, offset.x(), subRect);
+ positionViewAtCell(cell.x(), cell.y(), mode, offset, subRect);
}
void QQuickTableView::positionViewAtCell(int column, int row, PositionMode mode, const QPointF &offset, const QRectF &subRect)
{
- positionViewAtRow(row, mode, offset.y(), subRect);
- positionViewAtColumn(column, mode, offset.x(), subRect);
+ PositionMode horizontalMode = mode & ~(AlignTop | AlignBottom | AlignVCenter);
+ PositionMode verticalMode = mode & ~(AlignLeft | AlignRight | AlignHCenter);
+ if (!horizontalMode && !verticalMode) {
+ qmlWarning(this) << "Unsupported mode:" << int(mode);
+ return;
+ }
+
+ if (horizontalMode)
+ positionViewAtColumn(column, horizontalMode, offset.x(), subRect);
+ if (verticalMode)
+ positionViewAtRow(row, verticalMode, offset.y(), subRect);
}
QQuickItem *QQuickTableView::itemAtCell(const QPoint &cell) const
@@ -4814,7 +4946,26 @@ QPoint QQuickTableView::cellAtIndex(const QModelIndex &index) const
return {index.column(), index.row()};
}
-QModelIndex QQuickTableView::modelIndex(int column, int row) const
+#if QT_DEPRECATED_SINCE(6, 4)
+QModelIndex QQuickTableView::modelIndex(int row, int column) const
+{
+ static bool compat6_4 = qEnvironmentVariable("QT_QUICK_TABLEVIEW_COMPAT_VERSION") == QStringLiteral("6.4");
+ if (compat6_4) {
+ // In Qt 6.4.0 and 6.4.1, a source incompatible change led to row and column
+ // being documented to be specified in the opposite order.
+ // QT_QUICK_TABLEVIEW_COMPAT_VERSION can therefore be set to force tableview
+ // to continue accepting calls to modelIndex(column, row).
+ return modelIndex({row, column});
+ } else {
+ qmlWarning(this) << "modelIndex(row, column) is deprecated. "
+ "Use index(row, column) instead. For more information, see "
+ "https://doc.qt.io/qt-6/qml-qtquick-tableview-obsolete.html";
+ return modelIndex({column, row});
+ }
+}
+#endif
+
+QModelIndex QQuickTableView::index(int row, int column) const
{
return modelIndex({column, row});
}
@@ -4850,7 +5001,10 @@ void QQuickTableView::geometryChange(const QRectF &newGeometry, const QRectF &ol
d->tableModel->drainReusableItemsPool(0);
}
- polish();
+ d->scheduleRebuildTable(
+ QQuickTableViewPrivate::RebuildOption::LayoutOnly |
+ QQuickTableViewPrivate::RebuildOption::CalculateNewContentWidth |
+ QQuickTableViewPrivate::RebuildOption::CalculateNewContentHeight);
}
void QQuickTableView::viewportMoved(Qt::Orientations orientation)
@@ -4918,7 +5072,7 @@ void QQuickTableView::keyPressEvent(QKeyEvent *e)
case Qt::Key_Right:
// Special case: the current index doesn't map to a cell in the view (perhaps
// because it isn't set yet). In that case, we set it to be the top-left cell.
- const QModelIndex topLeftIndex = modelIndex(leftColumn(), topRow());
+ const QModelIndex topLeftIndex = index(topRow(), leftColumn());
d->selectionModel->setCurrentIndex(topLeftIndex, QItemSelectionModel::NoUpdate);
}
return;
@@ -5134,6 +5288,20 @@ QQuickTableSectionSizeProviderPrivate::~QQuickTableSectionSizeProviderPrivate()
}
+// ----------------------------------------------
+
+QQuickTableViewTapHandler::QQuickTableViewTapHandler(QQuickTableView *view)
+ : QQuickTapHandler(view->contentItem())
+{
+}
+
+bool QQuickTableViewTapHandler::wantsEventPoint(const QPointerEvent *event, const QEventPoint &point)
+{
+ auto tableView = static_cast<QQuickTableView *>(parentItem()->parent());
+ auto tableViewPrivate = QQuickTableViewPrivate::get(tableView);
+ return tableViewPrivate->pointerNavigationEnabled && QQuickTapHandler::wantsEventPoint(event, point);
+}
+
QT_END_NAMESPACE
#include "moc_qquicktableview_p.cpp"
diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h
index 598e109093..442e490a87 100644
--- a/src/quick/items/qquicktableview_p.h
+++ b/src/quick/items/qquicktableview_p.h
@@ -77,8 +77,8 @@ public:
Visible = 0x01000,
Contain = 0x02000
};
- Q_FLAG(PositionModeFlag)
Q_DECLARE_FLAGS(PositionMode, PositionModeFlag)
+ Q_FLAG(PositionMode)
enum SelectionBehavior {
SelectionDisabled,
@@ -159,6 +159,8 @@ public:
Q_REVISION(6, 4) Q_INVOKABLE QPoint cellAtPosition(const QPointF &position, bool includeSpacing = false) const;
Q_REVISION(6, 4) Q_INVOKABLE QPoint cellAtPosition(qreal x, qreal y, bool includeSpacing = false) const;
#if QT_DEPRECATED_SINCE(6, 4)
+ QT_DEPRECATED_VERSION_X_6_4("Use index(row, column) instead")
+ Q_REVISION(6, 4) Q_INVOKABLE virtual QModelIndex modelIndex(int row, int column) const;
QT_DEPRECATED_VERSION_X_6_4("Use cellAtPosition() instead")
Q_INVOKABLE QPoint cellAtPos(const QPointF &position, bool includeSpacing = false) const;
Q_INVOKABLE QPoint cellAtPos(qreal x, qreal y, bool includeSpacing = false) const;
@@ -172,8 +174,8 @@ public:
Q_REVISION(6, 2) Q_INVOKABLE qreal implicitColumnWidth(int column) const;
Q_REVISION(6, 2) Q_INVOKABLE qreal implicitRowHeight(int row) const;
+ Q_REVISION(6, 4) Q_INVOKABLE QModelIndex index(int row, int column) const;
Q_REVISION(6, 4) Q_INVOKABLE virtual QModelIndex modelIndex(const QPoint &cell) const;
- Q_REVISION(6, 4) Q_INVOKABLE virtual QModelIndex modelIndex(int column, int row) const;
Q_REVISION(6, 4) Q_INVOKABLE virtual QPoint cellAtIndex(const QModelIndex &index) const;
Q_REVISION(6, 4) Q_INVOKABLE int rowAtIndex(const QModelIndex &index) const;
Q_REVISION(6, 4) Q_INVOKABLE int columnAtIndex(const QModelIndex &index) const;
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index 608eee8558..7c865169cb 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -29,6 +29,7 @@
#include <QtQuick/private/qquickitemviewfxitem_p_p.h>
#include <QtQuick/private/qquickanimation_p.h>
#include <QtQuick/private/qquickselectable_p.h>
+#include <QtQuick/private/qquicktaphandler_p.h>
QT_BEGIN_NAMESPACE
@@ -60,6 +61,21 @@ private:
Q_DECLARE_PRIVATE(QQuickTableSectionSizeProvider)
};
+/*! \internal
+ * QQuickTableViewTapHandler used to handle tap events explicitly for table view
+ */
+class QQuickTableViewTapHandler : public QQuickTapHandler
+{
+ Q_OBJECT
+
+public:
+ explicit QQuickTableViewTapHandler(QQuickTableView *view);
+ bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point) override;
+
+ friend class QQuickTableViewPrivate;
+};
+
+
class Q_QUICK_PRIVATE_EXPORT QQuickTableViewPrivate : public QQuickFlickablePrivate, public QQuickSelectable
{
public:
@@ -105,7 +121,7 @@ public:
inline bool isActive() const { return m_active; }
inline QPoint currentCell() const { return cellAt(m_currentIndex); }
- inline bool hasCurrentCell() const { return m_currentIndex < m_visibleCellsInEdge.count(); }
+ inline bool hasCurrentCell() const { return m_currentIndex < m_visibleCellsInEdge.size(); }
inline void moveToNextCell() { ++m_currentIndex; }
inline Qt::Edge edge() const { return m_edge; }
@@ -168,8 +184,8 @@ public:
LoadInitalTable,
VerifyTable,
LayoutTable,
- LoadAndUnloadAfterLayout,
CancelOvershoot,
+ UpdateContentSize,
PreloadColumns,
PreloadRows,
MovePreloadedItemsToPool,
@@ -416,6 +432,7 @@ public:
void adjustViewportXAccordingToAlignment();
void adjustViewportYAccordingToAlignment();
void cancelOvershootAfterLayout();
+ void updateContentSize();
void scheduleRebuildTable(QQuickTableViewPrivate::RebuildOptions options);
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 877e120644..e25df1512f 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -285,7 +285,7 @@ void QQuickText::imageDownloadFinished()
if (d->extra.isAllocated() && d->extra->nbActiveDownloads == 0) {
bool needToUpdateLayout = false;
- for (QQuickStyledTextImgTag *img : qAsConst(d->extra->visibleImgTags)) {
+ for (QQuickStyledTextImgTag *img : std::as_const(d->extra->visibleImgTags)) {
if (!img->size.isValid()) {
img->size = img->pix->implicitSize();
needToUpdateLayout = true;
@@ -617,7 +617,7 @@ void QQuickTextPrivate::elideFormats(
{
const int end = start + length;
const QVector<QTextLayout::FormatRange> formats = layout.formats();
- for (int i = 0; i < formats.count(); ++i) {
+ for (int i = 0; i < formats.size(); ++i) {
QTextLayout::FormatRange format = formats.at(i);
const int formatLength = qMin(format.start + format.length, end) - qMax(format.start, start);
if (formatLength > 0) {
@@ -628,7 +628,7 @@ void QQuickTextPrivate::elideFormats(
}
}
-QString QQuickTextPrivate::elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine) const
+QString QQuickTextPrivate::elidedText(qreal lineWidth, const QTextLine &line, const QTextLine *nextLine) const
{
if (nextLine) {
return layout.engine()->elidedText(
@@ -641,7 +641,7 @@ QString QQuickTextPrivate::elidedText(qreal lineWidth, const QTextLine &line, QT
QString elideText = layout.text().mid(line.textStart(), line.textLength());
if (!styledText) {
// QFontMetrics won't help eliding styled text.
- elideText[elideText.length() - 1] = elideChar;
+ elideText[elideText.size() - 1] = elideChar;
// Appending the elide character may push the line over the maximum width
// in which case the elided text will need to be elided.
QFontMetricsF metrics(layout.font());
@@ -792,12 +792,14 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
br = QRectF();
QRectF unelidedRect;
- QTextLine line = layout.createLine();
+ QTextLine line;
for (visibleCount = 1; ; ++visibleCount) {
+ line = layout.createLine();
+
if (noBreakLastLine && visibleCount == maxLineCount)
layout.engine()->option.setWrapMode(QTextOption::WrapAnywhere);
if (customLayout) {
- setupCustomLineGeometry(line, naturalHeight, layoutText.length());
+ setupCustomLineGeometry(line, naturalHeight, layoutText.size());
} else {
setLineGeometry(line, lineWidth, naturalHeight);
}
@@ -819,7 +821,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
visibleCount -= 1;
- QTextLine previousLine = layout.lineAt(visibleCount - 1);
+ const QTextLine previousLine = layout.lineAt(visibleCount - 1);
elideText = layoutText.at(line.textStart() - 1) != QChar::LineSeparator
? elidedText(line.width(), previousLine, &line)
: elidedText(line.width(), previousLine);
@@ -830,10 +832,9 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
break;
}
- const QTextLine previousLine = line;
- line = layout.createLine();
- if (!line.isValid()) {
- if (singlelineElide && visibleCount == 1 && previousLine.naturalTextWidth() > previousLine.width()) {
+ const bool isLastLine = line.textStart() + line.textLength() >= layoutText.size();
+ if (isLastLine) {
+ if (singlelineElide && visibleCount == 1 && line.naturalTextWidth() > line.width()) {
// Elide a single previousLine of text if its width exceeds the element width.
elide = true;
widthExceeded = true;
@@ -843,26 +844,25 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
truncated = true;
elideText = layout.engine()->elidedText(
Qt::TextElideMode(elideMode),
- QFixed::fromReal(previousLine.width()),
+ QFixed::fromReal(line.width()),
0,
- previousLine.textStart(),
- previousLine.textLength());
- elideStart = previousLine.textStart();
- elideEnd = elideStart + previousLine.textLength();
+ line.textStart(),
+ line.textLength());
+ elideStart = line.textStart();
+ elideEnd = elideStart + line.textLength();
} else {
br = unelidedRect;
height = naturalHeight;
}
break;
} else {
- const bool wrappedLine = layoutText.at(line.textStart() - 1) != QChar::LineSeparator;
+ const bool wrappedLine = layoutText.at(line.textStart() + line.textLength() - 1) != QChar::LineSeparator;
wrapped |= wrappedLine;
if (!wrappedLine)
++unwrappedLineCount;
- // Stop if the maximum number of lines has been reached and elide the last line
- // if enabled.
+ // Stop if the maximum number of lines has been reached
if (visibleCount == maxLineCount) {
truncated = true;
heightExceeded |= wrapped;
@@ -871,10 +871,12 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
elide = true;
if (eos != -1) // There's an abbreviated string available
break;
+
+ const QTextLine nextLine = layout.createLine();
elideText = wrappedLine
- ? elidedText(previousLine.width(), previousLine, &line)
- : elidedText(previousLine.width(), previousLine);
- elideStart = previousLine.textStart();
+ ? elidedText(line.width(), line, &nextLine)
+ : elidedText(line.width(), line);
+ elideStart = line.textStart();
// elideEnd isn't required for right eliding.
} else {
br = unelidedRect;
@@ -911,8 +913,8 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
// implicit width.
const int eol = line.isValid()
? line.textStart() + line.textLength()
- : layoutText.length();
- if (eol < layoutText.length() && layoutText.at(eol) != QChar::LineSeparator)
+ : layoutText.size();
+ if (eol < layoutText.size() && layoutText.at(eol) != QChar::LineSeparator)
line = layout.createLine();
for (; line.isValid() && unwrappedLineCount <= maxLineCount; ++unwrappedLineCount)
line = layout.createLine();
@@ -1109,18 +1111,18 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
QVector<QTextLayout::FormatRange> formats;
switch (elideMode) {
case QQuickText::ElideRight:
- elideFormats(elideStart, elideText.length() - 1, 0, &formats);
+ elideFormats(elideStart, elideText.size() - 1, 0, &formats);
break;
case QQuickText::ElideLeft:
- elideFormats(elideEnd - elideText.length() + 1, elideText.length() - 1, 1, &formats);
+ elideFormats(elideEnd - elideText.size() + 1, elideText.size() - 1, 1, &formats);
break;
case QQuickText::ElideMiddle: {
const int index = elideText.indexOf(elideChar);
if (index != -1) {
elideFormats(elideStart, index, 0, &formats);
elideFormats(
- elideEnd - elideText.length() + index + 1,
- elideText.length() - index - 1,
+ elideEnd - elideText.size() + index + 1,
+ elideText.size() - index - 1,
index + 1,
&formats);
}
@@ -1140,7 +1142,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
QTextLine elidedLine = elideLayout->createLine();
elidedLine.setPosition(QPointF(0, height));
if (customLayout) {
- setupCustomLineGeometry(elidedLine, height, elideText.length(), visibleCount - 1);
+ setupCustomLineGeometry(elidedLine, height, elideText.size(), visibleCount - 1);
} else {
setLineGeometry(elidedLine, lineWidth, height);
}
@@ -1194,7 +1196,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
QList<QQuickStyledTextImgTag *> imagesInLine;
if (extra.isAllocated()) {
- for (QQuickStyledTextImgTag *image : qAsConst(extra->imgTags)) {
+ for (QQuickStyledTextImgTag *image : std::as_const(extra->imgTags)) {
if (image->position >= line.textStart() &&
image->position < line.textStart() + line.textLength()) {
@@ -1232,7 +1234,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
}
}
- for (QQuickStyledTextImgTag *image : qAsConst(imagesInLine)) {
+ for (QQuickStyledTextImgTag *image : std::as_const(imagesInLine)) {
totalLineHeight = qMax(totalLineHeight, textTop + image->pos.y() + image->size.height());
const int leadX = line.cursorToX(image->position);
const int trailX = line.cursorToX(image->position, QTextLine::Trailing);
@@ -2409,21 +2411,23 @@ void QQuickText::geometryChange(const QRectF &newGeometry, const QRectF &oldGeom
goto geomChangeDone;
if (!(widthChanged || widthMaximum) && !d->isLineLaidOutConnected()) { // only height has changed
- if (newGeometry.height() > oldGeometry.height()) {
- if (!d->heightExceeded && !qFuzzyIsNull(oldGeometry.height())) {
- // Height is adequate and growing, and it wasn't 0 previously.
- goto geomChangeDone;
- }
- if (d->lineCount == d->maximumLineCount()) // Reached maximum line and height is growing.
- goto geomChangeDone;
- } else if (newGeometry.height() < oldGeometry.height()) {
- if (d->lineCount < 2 && !verticalScale && newGeometry.height() > 0) // A single line won't be truncated until the text is 0 height.
- goto geomChangeDone;
-
- if (!verticalScale // no scaling, no eliding, and either unwrapped, or no maximum line count.
- && d->elideMode != QQuickText::ElideRight
- && !(d->maximumLineCountValid && d->widthExceeded)) {
- goto geomChangeDone;
+ if (!verticalPositionChanged) {
+ if (newGeometry.height() > oldGeometry.height()) {
+ if (!d->heightExceeded && !qFuzzyIsNull(oldGeometry.height())) {
+ // Height is adequate and growing, and it wasn't 0 previously.
+ goto geomChangeDone;
+ }
+ if (d->lineCount == d->maximumLineCount()) // Reached maximum line and height is growing.
+ goto geomChangeDone;
+ } else if (newGeometry.height() < oldGeometry.height()) {
+ if (d->lineCount < 2 && !verticalScale && newGeometry.height() > 0) // A single line won't be truncated until the text is 0 height.
+ goto geomChangeDone;
+
+ if (!verticalScale // no scaling, no eliding, and either unwrapped, or no maximum line count.
+ && d->elideMode != QQuickText::ElideRight
+ && !(d->maximumLineCountValid && d->widthExceeded)) {
+ goto geomChangeDone;
+ }
}
}
} else if (!heightChanged && widthMaximum) {
@@ -2509,7 +2513,7 @@ QSGNode *QQuickText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data
node->addTextLayout(QPointF(dx, dy), d->elideLayout, color, d->style, styleColor, linkColor);
if (d->extra.isAllocated()) {
- for (QQuickStyledTextImgTag *img : qAsConst(d->extra->visibleImgTags)) {
+ for (QQuickStyledTextImgTag *img : std::as_const(d->extra->visibleImgTags)) {
QQuickPixmap *pix = img->pix;
if (pix && pix->isReady())
node->addImage(QRectF(img->pos.x() + dx, img->pos.y() + dy, pix->width(), pix->height()), pix->image());
diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h
index 5966ff5f75..bfcca403bf 100644
--- a/src/quick/items/qquicktext_p_p.h
+++ b/src/quick/items/qquicktext_p_p.h
@@ -48,7 +48,7 @@ public:
void setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height);
int lineHeightOffset() const;
- QString elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine = nullptr) const;
+ QString elidedText(qreal lineWidth, const QTextLine &line, const QTextLine *nextLine = nullptr) const;
void elideFormats(int start, int length, int offset, QVector<QTextLayout::FormatRange> *elidedFormats);
void clearFormats();
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index cbc9f10f9e..929ce10136 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -742,8 +742,7 @@ void QQuickTextControl::processEvent(QEvent *e, const QTransform &transform)
case QEvent::ShortcutOverride:
if (d->interactionFlags & Qt::TextEditable) {
QKeyEvent* ke = static_cast<QKeyEvent *>(e);
- if (isCommonTextEditShortcut(ke))
- ke->accept();
+ ke->setAccepted(isCommonTextEditShortcut(ke));
}
break;
default:
@@ -963,7 +962,7 @@ QRectF QQuickTextControlPrivate::rectForPosition(int position) const
if (relativePos == preeditPos)
relativePos += preeditCursor;
else if (relativePos > preeditPos)
- relativePos += layout->preeditAreaText().length();
+ relativePos += layout->preeditAreaText().size();
}
#endif
QTextLine line = layout->lineForTextPosition(relativePos);
@@ -1272,7 +1271,7 @@ bool QQuickTextControlPrivate::sendMouseEventToInputContext(QMouseEvent *e, cons
QTextLayout *layout = cursor.block().layout();
int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position();
- if (cursorPos >= 0 && cursorPos <= layout->preeditAreaText().length()) {
+ if (cursorPos >= 0 && cursorPos <= layout->preeditAreaText().size()) {
if (e->type() == QEvent::MouseButtonRelease) {
QGuiApplication::inputMethod()->invokeAction(QInputMethod::Click, cursorPos);
}
@@ -1344,7 +1343,7 @@ void QQuickTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
emit q->preeditTextChanged();
}
QVector<QTextLayout::FormatRange> overrides;
- preeditCursor = e->preeditString().length();
+ preeditCursor = e->preeditString().size();
hasImState = !e->preeditString().isEmpty();
cursorVisible = true;
for (int i = 0; i < e->attributes().size(); ++i) {
@@ -1417,7 +1416,7 @@ QVariant QQuickTextControl::inputMethodQuery(Qt::InputMethodQuery property, cons
QTextCursor tmpCursor = d->cursor;
int localPos = d->cursor.position() - block.position();
QString result = block.text().mid(localPos);
- while (result.length() < maxLength) {
+ while (result.size() < maxLength) {
int currentBlock = tmpCursor.blockNumber();
tmpCursor.movePosition(QTextCursor::NextBlock);
if (tmpCursor.blockNumber() == currentBlock)
diff --git a/src/quick/items/qquicktextdocument.cpp b/src/quick/items/qquicktextdocument.cpp
index 4f585f8333..ce0efb4d2a 100644
--- a/src/quick/items/qquicktextdocument.cpp
+++ b/src/quick/items/qquicktextdocument.cpp
@@ -183,7 +183,7 @@ QQuickPixmap *QQuickTextDocumentWithImageResources::loadPixmap(
void QQuickTextDocumentWithImageResources::clearResources()
{
- for (QQuickPixmap *pixmap : qAsConst(m_resources))
+ for (QQuickPixmap *pixmap : std::as_const(m_resources))
pixmap->clear(this);
qDeleteAll(m_resources);
m_resources.clear();
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 8ce622d176..b1158899bf 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -405,6 +405,11 @@ void QQuickTextEdit::setText(const QString &text)
void QQuickTextEdit::invalidate()
{
+ QMetaObject::invokeMethod(this, &QQuickTextEdit::q_invalidate);
+}
+
+void QQuickTextEdit::q_invalidate()
+{
Q_D(QQuickTextEdit);
if (isComponentComplete()) {
if (d->document != nullptr)
@@ -1088,7 +1093,7 @@ int QQuickTextEdit::positionAt(qreal x, qreal y) const
// preedit or the next text block.
QTextLayout *layout = cursor.block().layout();
const int preeditLength = layout
- ? layout->preeditAreaText().length()
+ ? layout->preeditAreaText().size()
: 0;
if (preeditLength > 0
&& d->document->documentLayout()->blockBoundingRect(cursor.block()).contains(x, y)) {
@@ -2214,7 +2219,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
// Having nodes spanning across frame boundaries will break the current bookkeeping mechanism. We need to prevent that.
QList<int> frameBoundaries;
frameBoundaries.reserve(frames.size());
- for (QTextFrame *frame : qAsConst(frames))
+ for (QTextFrame *frame : std::as_const(frames))
frameBoundaries.append(frame->firstPosition());
std::sort(frameBoundaries.begin(), frameBoundaries.end());
@@ -2241,13 +2246,16 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
if (coveredRegion.top() > viewport.top() + 1) {
qCDebug(lcVP) << "checking backwards from block" << block.blockNumber() << "@" << nodeOffset.y() << coveredRegion;
while (it != textFrame->begin() && it.currentBlock().layout() &&
- it.currentBlock().layout()->boundingRect().top() + nodeOffset.y() > viewport.top())
+ it.currentBlock().layout()->boundingRect().top() + nodeOffset.y() > viewport.top()) {
+ nodeOffset = d->document->documentLayout()->blockBoundingRect(it.currentBlock()).topLeft();
--it;
+ }
if (!it.currentBlock().layout())
++it;
if (Q_LIKELY(it.currentBlock().layout())) {
block = it.currentBlock();
coveredRegion = block.layout()->boundingRect().adjusted(nodeOffset.x(), nodeOffset.y(), nodeOffset.x(), nodeOffset.y());
+ firstDirtyPos = it.currentBlock().position();
} else {
qCWarning(lcVP) << "failed to find a text block with layout during back-scrolling";
}
@@ -2271,11 +2279,13 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
}
}
+ bool createdNodeInView = false;
if (inView) {
if (!engine.hasContents()) {
if (node && !node->parent())
d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart);
node = d->createTextNode();
+ createdNodeInView = true;
updateNodeTransform(node, nodeOffset);
nodeStart = block.position();
}
@@ -2285,18 +2295,18 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
if ((it.atEnd()) || block.next().position() >= firstCleanNode.startPos())
break; // last node that needed replacing or last block of the frame
-
QList<int>::const_iterator lowerBound = std::lower_bound(frameBoundaries.constBegin(), frameBoundaries.constEnd(), block.next().position());
if (node && (currentNodeSize > nodeBreakingSize || lowerBound == frameBoundaries.constEnd() || *lowerBound > nodeStart)) {
currentNodeSize = 0;
if (!node->parent())
d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart);
- node = d->createTextNode();
+ if (!createdNodeInView)
+ node = d->createTextNode();
resetEngine(&engine, d->color, d->selectedTextColor, d->selectionColor);
nodeStart = block.next().position();
}
++it;
- }
+ } // loop over blocks in frame
}
if (Q_LIKELY(node && !node->parent()))
d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart);
@@ -3357,6 +3367,16 @@ void QQuickTextEdit::clear()
d->control->clear();
}
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QQuickTextEditPrivate::Node &n)
+{
+ QDebugStateSaver saver(debug);
+ debug.space();
+ debug << "Node(startPos:" << n.m_startPos << "dirty:" << n.m_dirty << n.m_node << ')';
+ return debug;
+}
+#endif
+
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
void QQuickTextEdit::setOldSelectionDefault()
{
@@ -3365,7 +3385,7 @@ void QQuickTextEdit::setOldSelectionDefault()
setKeepMouseGrab(false);
d->control->setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByMouse);
d->control->setTouchDragSelectionEnabled(true);
- qCDebug(lcTextEdit, "pre-6.4 behavior chosen by import version: selectByMouse defaults false; if enabled, touchscreen acts like a mouse");
+ qCDebug(lcTextEdit, "pre-6.4 behavior chosen: selectByMouse defaults false; if enabled, touchscreen acts like a mouse");
}
// TODO in 6.7.0: remove the note about versions prior to 6.4 in selectByMouse() documentation
diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h
index b4a8e95cf4..c98d062c6b 100644
--- a/src/quick/items/qquicktextedit_p.h
+++ b/src/quick/items/qquicktextedit_p.h
@@ -338,6 +338,7 @@ public Q_SLOTS:
Q_REVISION(2, 7) void clear();
private Q_SLOTS:
+ void q_invalidate();
void q_textChanged();
void q_contentsChange(int, int, int);
void updateSelection();
diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h
index b2cbd80626..db07462a5a 100644
--- a/src/quick/items/qquicktextedit_p_p.h
+++ b/src/quick/items/qquicktextedit_p_p.h
@@ -53,6 +53,10 @@ public:
int m_startPos;
QQuickTextNode* m_node;
bool m_dirty;
+
+#ifndef QT_NO_DEBUG_STREAM
+ friend QDebug Q_QUICK_PRIVATE_EXPORT operator<<(QDebug, const Node &);
+#endif
};
typedef QList<Node>::iterator TextNodeIterator;
@@ -202,6 +206,10 @@ public:
static const int largeTextSizeThreshold;
};
+#ifndef QT_NO_DEBUG_STREAM
+QDebug Q_QUICK_PRIVATE_EXPORT operator<<(QDebug debug, const QQuickTextEditPrivate::Node &);
+#endif
+
QT_END_NAMESPACE
#endif // QQUICKTEXTEDIT_P_P_H
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index a980e7fbaf..660496734b 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -31,7 +31,7 @@
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
-Q_LOGGING_CATEGORY(lcTextInput, "qt.quick.textInput")
+Q_LOGGING_CATEGORY(lcQuickTextInput, "qt.quick.textInput")
/*!
\qmltype TextInput
@@ -173,7 +173,7 @@ void QQuickTextInput::setRenderType(QQuickTextInput::RenderType renderType)
int QQuickTextInput::length() const
{
Q_D(const QQuickTextInput);
- return d->m_text.length();
+ return d->m_text.size();
}
/*!
@@ -833,7 +833,7 @@ int QQuickTextInput::cursorPosition() const
void QQuickTextInput::setCursorPosition(int cp)
{
Q_D(QQuickTextInput);
- if (cp < 0 || cp > text().length())
+ if (cp < 0 || cp > text().size())
return;
d->moveCursor(cp);
}
@@ -866,7 +866,7 @@ QRectF QQuickTextInput::cursorRectangle() const
qreal y = l.y() - d->vscroll + topPadding();
qreal w = 1;
if (d->overwriteMode) {
- if (c < text().length())
+ if (c < text().size())
w = l.cursorToX(c + 1) - x;
else
w = QFontMetrics(font()).horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw()
@@ -922,7 +922,7 @@ int QQuickTextInput::selectionEnd() const
void QQuickTextInput::select(int start, int end)
{
Q_D(QQuickTextInput);
- if (start < 0 || end < 0 || start > d->m_text.length() || end > d->m_text.length())
+ if (start < 0 || end < 0 || start > d->m_text.size() || end > d->m_text.size())
return;
d->setSelection(start, end-start);
}
@@ -937,10 +937,10 @@ void QQuickTextInput::select(int start, int end)
It is equivalent to the following snippet, but is faster and easier
to use.
- \js
+ \qml
myTextInput.text.toString().substring(myTextInput.selectionStart,
myTextInput.selectionEnd);
- \endjs
+ \endqml
*/
QString QQuickTextInput::selectedText() const
{
@@ -1365,7 +1365,7 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const
pos = 0;
#if QT_CONFIG(im)
else if (pos > d->m_cursor)
- pos += d->preeditAreaText().length();
+ pos += d->preeditAreaText().size();
#endif
QTextLine l = d->m_textLayout.lineForTextPosition(pos);
if (!l.isValid())
@@ -1374,7 +1374,7 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const
qreal y = l.y() - d->vscroll;
qreal w = 1;
if (d->overwriteMode) {
- if (pos < text().length())
+ if (pos < text().size())
w = l.cursorToX(pos + 1) - x;
else
w = QFontMetrics(font()).horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw()
@@ -1435,7 +1435,7 @@ void QQuickTextInput::positionAt(QQmlV4Function *args) const
const int cursor = d->m_cursor;
if (pos > cursor) {
#if QT_CONFIG(im)
- const int preeditLength = d->preeditAreaText().length();
+ const int preeditLength = d->preeditAreaText().size();
pos = pos > cursor + preeditLength
? pos - preeditLength
: cursor;
@@ -1503,7 +1503,7 @@ void QQuickTextInput::keyPressEvent(QKeyEvent* ev)
int cursorPosition = d->m_cursor;
if (cursorPosition == 0)
ignore = ev->key() == (d->layoutDirection() == Qt::LeftToRight ? Qt::Key_Left : Qt::Key_Right);
- if (!ignore && cursorPosition == d->m_text.length())
+ if (!ignore && cursorPosition == d->m_text.size())
ignore = ev->key() == (d->layoutDirection() == Qt::LeftToRight ? Qt::Key_Right : Qt::Key_Left);
}
if (ignore) {
@@ -1593,10 +1593,13 @@ void QQuickTextInput::mousePressEvent(QMouseEvent *event)
void QQuickTextInput::mouseMoveEvent(QMouseEvent *event)
{
- if (!QQuickDeliveryAgentPrivate::isEventFromMouseOrTouchpad(event))
- return;
-
Q_D(QQuickTextInput);
+ if (!QQuickDeliveryAgentPrivate::isEventFromMouseOrTouchpad(event)
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ && ! d->selectByTouchDrag
+#endif
+ )
+ return;
if (d->selectPressed) {
if (qAbs(int(event->position().x() - d->pressPos.x())) > QGuiApplication::styleHints()->startDragDistance())
@@ -1629,7 +1632,12 @@ void QQuickTextInput::mouseReleaseEvent(QMouseEvent *event)
d->selectPressed = false;
setKeepMouseGrab(false);
}
- const bool isMouse = QQuickDeliveryAgentPrivate::isEventFromMouseOrTouchpad(event);
+ const bool isMouse = QQuickDeliveryAgentPrivate::isEventFromMouseOrTouchpad(event)
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ || d->selectByTouchDrag
+#endif
+ ;
+
#if QT_CONFIG(clipboard)
if (isMouse && QGuiApplication::clipboard()->supportsSelection()) {
if (event->button() == Qt::LeftButton) {
@@ -1640,9 +1648,11 @@ void QQuickTextInput::mouseReleaseEvent(QMouseEvent *event)
}
}
#endif
+
// On a touchscreen or with a stylus, set cursor position and focus on release, not on press;
// if Flickable steals the grab in the meantime, the cursor won't move.
- if (!isMouse)
+ // Check d->hasSelectedText() to keep touch-and-hold word selection working.
+ if (!isMouse && !d->hasSelectedText())
d->moveCursor(d->positionAt(event->position()), false);
if (d->focusOnPress && qGuiApp->styleHints()->setFocusOnTouchRelease())
@@ -1658,7 +1668,7 @@ bool QQuickTextInputPrivate::sendMouseEventToInputContext(QMouseEvent *event)
if (composeMode()) {
int tmp_cursor = positionAt(event->position());
int mousePos = tmp_cursor - m_cursor;
- if (mousePos >= 0 && mousePos <= m_textLayout.preeditAreaText().length()) {
+ if (mousePos >= 0 && mousePos <= m_textLayout.preeditAreaText().size()) {
if (event->type() == QEvent::MouseButtonRelease) {
QGuiApplication::inputMethod()->invokeAction(QInputMethod::Click, mousePos);
}
@@ -1684,8 +1694,10 @@ bool QQuickTextInput::event(QEvent* ev)
#if QT_CONFIG(shortcut)
Q_D(QQuickTextInput);
if (ev->type() == QEvent::ShortcutOverride) {
- if (d->m_readOnly)
+ if (d->m_readOnly) {
+ ev->ignore();
return false;
+ }
QKeyEvent* ke = static_cast<QKeyEvent*>(ev);
if (ke == QKeySequence::Copy
|| ke == QKeySequence::Paste
@@ -1728,6 +1740,7 @@ bool QQuickTextInput::event(QEvent* ev)
}
}
}
+ ev->ignore();
}
#endif
@@ -1799,7 +1812,7 @@ void QQuickTextInputPrivate::updateHorizontalScroll()
{
if (autoScroll && m_echoMode != QQuickTextInput::NoEcho) {
#if QT_CONFIG(im)
- const int preeditLength = m_textLayout.preeditAreaText().length();
+ const int preeditLength = m_textLayout.preeditAreaText().size();
ensureVisible(m_cursor, m_preeditCursor, preeditLength);
#else
ensureVisible(m_cursor);
@@ -1813,7 +1826,7 @@ void QQuickTextInputPrivate::updateVerticalScroll()
{
Q_Q(QQuickTextInput);
#if QT_CONFIG(im)
- const int preeditLength = m_textLayout.preeditAreaText().length();
+ const int preeditLength = m_textLayout.preeditAreaText().size();
#endif
const qreal height = qMax<qreal>(0, q->height() - q->topPadding() - q->bottomPadding());
qreal heightUsed = contentSize.height();
@@ -2038,7 +2051,7 @@ void QQuickTextInput::deselect()
void QQuickTextInput::selectAll()
{
Q_D(QQuickTextInput);
- d->setSelection(0, text().length());
+ d->setSelection(0, text().size());
}
/*!
@@ -2151,7 +2164,7 @@ void QQuickTextInput::insert(int position, const QString &text)
if (d->m_passwordMaskDelay > 0)
d->m_passwordEchoTimer.start(d->m_passwordMaskDelay, this);
}
- if (position < 0 || position > d->m_text.length())
+ if (position < 0 || position > d->m_text.size())
return;
const int priorState = d->m_undoState;
@@ -2164,31 +2177,31 @@ void QQuickTextInput::insert(int position, const QString &text)
}
if (d->m_maskData) {
insertText = d->maskString(position, insertText);
- for (int i = 0; i < insertText.length(); ++i) {
+ for (int i = 0; i < insertText.size(); ++i) {
d->addCommand(QQuickTextInputPrivate::Command(
QQuickTextInputPrivate::DeleteSelection, position + i, d->m_text.at(position + i), -1, -1));
d->addCommand(QQuickTextInputPrivate::Command(
QQuickTextInputPrivate::Insert, position + i, insertText.at(i), -1, -1));
}
- d->m_text.replace(position, insertText.length(), insertText);
+ d->m_text.replace(position, insertText.size(), insertText);
if (!insertText.isEmpty())
d->m_textDirty = true;
- if (position < d->m_selend && position + insertText.length() > d->m_selstart)
+ if (position < d->m_selend && position + insertText.size() > d->m_selstart)
d->m_selDirty = true;
} else {
- int remaining = d->m_maxLength - d->m_text.length();
+ int remaining = d->m_maxLength - d->m_text.size();
if (remaining != 0) {
insertText = insertText.left(remaining);
d->m_text.insert(position, insertText);
- for (int i = 0; i < insertText.length(); ++i)
+ for (int i = 0; i < insertText.size(); ++i)
d->addCommand(QQuickTextInputPrivate::Command(
QQuickTextInputPrivate::Insert, position + i, insertText.at(i), -1, -1));
if (d->m_cursor >= position)
- d->m_cursor += insertText.length();
+ d->m_cursor += insertText.size();
if (d->m_selstart >= position)
- d->m_selstart += insertText.length();
+ d->m_selstart += insertText.size();
if (d->m_selend >= position)
- d->m_selend += insertText.length();
+ d->m_selend += insertText.size();
d->m_textDirty = true;
if (position >= d->m_selstart && position <= d->m_selend)
d->m_selDirty = true;
@@ -2221,8 +2234,8 @@ void QQuickTextInput::remove(int start, int end)
{
Q_D(QQuickTextInput);
- start = qBound(0, start, d->m_text.length());
- end = qBound(0, end, d->m_text.length());
+ start = qBound(0, start, d->m_text.size());
+ end = qBound(0, end, d->m_text.size());
if (start > end)
qSwap(start, end);
@@ -2320,7 +2333,7 @@ QString QQuickTextInput::passwordCharacter() const
void QQuickTextInput::setPasswordCharacter(const QString &str)
{
Q_D(QQuickTextInput);
- if (str.length() < 1)
+ if (str.size() < 1)
return;
d->m_passwordCharacter = str.constData()[0];
if (d->m_echoMode == Password || d->m_echoMode == PasswordEchoOnEdit)
@@ -2619,7 +2632,7 @@ void QQuickTextInput::moveCursorSelection(int pos, SelectionMode mode)
finder.setPosition(anchor);
const QTextBoundaryFinder::BoundaryReasons reasons = finder.boundaryReasons();
- if (anchor < text.length() && (reasons == QTextBoundaryFinder::NotAtBoundary
+ if (anchor < text.size() && (reasons == QTextBoundaryFinder::NotAtBoundary
|| (reasons & QTextBoundaryFinder::EndOfItem))) {
finder.toPreviousBoundary();
}
@@ -2628,7 +2641,7 @@ void QQuickTextInput::moveCursorSelection(int pos, SelectionMode mode)
finder.setPosition(pos);
if (pos > 0 && !finder.boundaryReasons())
finder.toNextBoundary();
- const int cursor = finder.position() != -1 ? finder.position() : text.length();
+ const int cursor = finder.position() != -1 ? finder.position() : text.size();
d->setSelection(anchor, cursor - anchor);
} else if (anchor > pos || (anchor == pos && cursor > pos)) {
@@ -2641,10 +2654,10 @@ void QQuickTextInput::moveCursorSelection(int pos, SelectionMode mode)
|| (reasons & QTextBoundaryFinder::StartOfItem))) {
finder.toNextBoundary();
}
- anchor = finder.position() != -1 ? finder.position() : text.length();
+ anchor = finder.position() != -1 ? finder.position() : text.size();
finder.setPosition(pos);
- if (pos < text.length() && !finder.boundaryReasons())
+ if (pos < text.size() && !finder.boundaryReasons())
finder.toPreviousBoundary();
const int cursor = finder.position() != -1 ? finder.position() : 0;
@@ -2900,7 +2913,7 @@ void QQuickTextInputPrivate::updateDisplayText(bool forceUpdate)
if (m_echoMode == QQuickTextInput::Password) {
str.fill(m_passwordCharacter);
- if (m_passwordEchoTimer.isActive() && m_cursor > 0 && m_cursor <= m_text.length()) {
+ if (m_passwordEchoTimer.isActive() && m_cursor > 0 && m_cursor <= m_text.size()) {
int cursor = m_cursor - 1;
QChar uc = m_text.at(cursor);
str[cursor] = uc;
@@ -2920,7 +2933,7 @@ void QQuickTextInputPrivate::updateDisplayText(bool forceUpdate)
// drawing boxes when using fonts that don't have glyphs for such
// characters)
QChar* uc = str.data();
- for (int i = 0; i < str.length(); ++i) {
+ for (int i = 0; i < str.size(); ++i) {
if (uc[i] == QChar::LineSeparator
|| uc[i] == QChar::ParagraphSeparator
|| uc[i] == QChar::ObjectReplacementCharacter)
@@ -3292,7 +3305,7 @@ void QQuickTextInputPrivate::clear()
int priorState = m_undoState;
separateSelection();
m_selstart = 0;
- m_selend = m_text.length();
+ m_selend = m_text.size();
removeSelectedText();
separate();
finishChange(priorState, /*update*/false, /*edited*/false);
@@ -3313,7 +3326,7 @@ void QQuickTextInputPrivate::setSelection(int start, int length)
commitPreedit();
#endif
- if (start < 0 || start > m_text.length()) {
+ if (start < 0 || start > m_text.size()) {
qWarning("QQuickTextInputPrivate::setSelection: Invalid start position");
return;
}
@@ -3322,7 +3335,7 @@ void QQuickTextInputPrivate::setSelection(int start, int length)
if (start == m_selstart && start + length == m_selend && m_cursor == m_selend)
return;
m_selstart = start;
- m_selend = qMin(start + length, m_text.length());
+ m_selend = qMin(start + length, m_text.size());
m_cursor = m_selend;
} else if (length < 0) {
if (start == m_selend && start + length == m_selstart && m_cursor == m_selstart)
@@ -3454,14 +3467,14 @@ void QQuickTextInputPrivate::processInputMethodEvent(QInputMethodEvent *event)
if (m_echoMode == QQuickTextInput::PasswordEchoOnEdit && !m_passwordEchoEditing) {
updatePasswordEchoEditing(true);
m_selstart = 0;
- m_selend = m_text.length();
+ m_selend = m_text.size();
}
removeSelectedText();
}
int c = m_cursor; // cursor position after insertion of commit string
if (event->replacementStart() <= 0)
- c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength());
+ c += event->commitString().size() - qMin(-event->replacementStart(), event->replacementLength());
int cursorInsertPos = m_cursor + event->replacementStart();
if (cursorInsertPos < 0)
@@ -3471,7 +3484,7 @@ void QQuickTextInputPrivate::processInputMethodEvent(QInputMethodEvent *event)
if (event->replacementLength()) {
m_selstart = cursorInsertPos;
m_selend = m_selstart + event->replacementLength();
- m_selend = qMin(m_selend, m_text.length());
+ m_selend = qMin(m_selend, m_text.size());
removeSelectedText();
}
m_cursor = cursorInsertPos;
@@ -3480,7 +3493,7 @@ void QQuickTextInputPrivate::processInputMethodEvent(QInputMethodEvent *event)
internalInsert(event->commitString());
cursorPositionChanged = true;
} else {
- m_cursor = qBound(0, c, m_text.length());
+ m_cursor = qBound(0, c, m_text.size());
}
for (int i = 0; i < event->attributes().size(); ++i) {
@@ -3491,15 +3504,16 @@ void QQuickTextInputPrivate::processInputMethodEvent(QInputMethodEvent *event)
// not seem to take the mask into account, so it will reset cursor
// to an invalid position in such case.
if (!cursorPositionChanged)
- m_cursor = qBound(0, a.start + a.length, m_text.length());
+ m_cursor = qBound(0, a.start + a.length, m_text.size());
if (a.length) {
- m_selstart = qMax(0, qMin(a.start, m_text.length()));
+ m_selstart = qMax(0, qMin(a.start, m_text.size()));
m_selend = m_cursor;
if (m_selend < m_selstart) {
qSwap(m_selstart, m_selend);
}
selectionChange = true;
} else {
+ selectionChange = m_selstart != m_selend;
m_selstart = m_selend = 0;
}
cursorPositionChanged = true;
@@ -3514,7 +3528,7 @@ void QQuickTextInputPrivate::processInputMethodEvent(QInputMethodEvent *event)
m_undoPreeditState = priorState;
}
const int oldPreeditCursor = m_preeditCursor;
- m_preeditCursor = event->preeditString().length();
+ m_preeditCursor = event->preeditString().size();
hasImState = !event->preeditString().isEmpty();
bool cursorVisible = true;
QVector<QTextLayout::FormatRange> formats;
@@ -3642,7 +3656,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo
validateFromState = m_undoPreeditState;
#endif
if (validateFromState >= 0 && wasValidInput && !m_validInput) {
- if (m_transactions.count())
+ if (m_transactions.size())
return false;
internalUndo(validateFromState);
m_history.resize(m_undoState);
@@ -3707,7 +3721,7 @@ void QQuickTextInputPrivate::internalSetText(const QString &txt, int pos, bool e
QString oldText = m_text;
if (m_maskData) {
m_text = maskString(0, txt, true);
- m_text += clearString(m_text.length(), m_maxLength - m_text.length());
+ m_text += clearString(m_text.size(), m_maxLength - m_text.size());
} else {
m_text = txt.isEmpty() ? txt : txt.left(m_maxLength);
}
@@ -3716,7 +3730,7 @@ void QQuickTextInputPrivate::internalSetText(const QString &txt, int pos, bool e
#if QT_CONFIG(im)
m_undoPreeditState = -1;
#endif
- m_cursor = (pos < 0 || pos > m_text.length()) ? m_text.length() : pos;
+ m_cursor = (pos < 0 || pos > m_text.size()) ? m_text.size() : pos;
m_textDirty = (oldText != m_text);
bool changed = finishChange(-1, true, edited);
@@ -3772,16 +3786,16 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
Q_ASSERT(!hasSelectedText()); // insert(), processInputMethodEvent() call removeSelectedText() first.
if (m_maskData) {
QString ms = maskString(m_cursor, s);
- for (int i = 0; i < ms.length(); ++i) {
+ for (int i = 0; i < ms.size(); ++i) {
addCommand (Command(DeleteSelection, m_cursor + i, m_text.at(m_cursor + i), -1, -1));
addCommand(Command(Insert, m_cursor + i, ms.at(i), -1, -1));
}
- m_text.replace(m_cursor, ms.length(), ms);
- m_cursor += ms.length();
+ m_text.replace(m_cursor, ms.size(), ms);
+ m_cursor += ms.size();
m_cursor = nextMaskBlank(m_cursor);
m_textDirty = true;
} else {
- int remaining = m_maxLength - m_text.length();
+ int remaining = m_maxLength - m_text.size();
if (remaining != 0) {
const QStringView remainingStr = QStringView{s}.left(remaining);
m_text.insert(m_cursor, remainingStr);
@@ -3805,7 +3819,7 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
*/
void QQuickTextInputPrivate::internalDelete(bool wasBackspace)
{
- if (m_cursor < m_text.length()) {
+ if (m_cursor < m_text.size()) {
cancelPasswordEchoTimer();
Q_ASSERT(!hasSelectedText()); // del(), backspace() call removeSelectedText() first.
addCommand(Command((CommandType)((m_maskData ? 2 : 0) + (wasBackspace ? Remove : Delete)),
@@ -3831,7 +3845,7 @@ void QQuickTextInputPrivate::internalDelete(bool wasBackspace)
*/
void QQuickTextInputPrivate::removeSelectedText()
{
- if (m_selstart < m_selend && m_selend <= m_text.length()) {
+ if (m_selstart < m_selend && m_selend <= m_text.size()) {
cancelPasswordEchoTimer();
int i ;
if (m_selstart <= m_cursor && m_cursor < m_selend) {
@@ -3901,13 +3915,13 @@ void QQuickTextInputPrivate::parseInputMask(const QString &maskFields)
m_inputMask = maskFields;
} else {
m_inputMask = maskFields.left(delimiter);
- m_blank = (delimiter + 1 < maskFields.length()) ? maskFields[delimiter + 1] : QLatin1Char(' ');
+ m_blank = (delimiter + 1 < maskFields.size()) ? maskFields[delimiter + 1] : QLatin1Char(' ');
}
// calculate m_maxLength / m_maskData length
m_maxLength = 0;
QChar c = u'\0';
- for (int i=0; i<m_inputMask.length(); i++) {
+ for (int i=0; i<m_inputMask.size(); i++) {
c = m_inputMask.at(i);
if (i > 0 && m_inputMask.at(i-1) == QLatin1Char('\\')) {
m_maxLength++;
@@ -3927,7 +3941,7 @@ void QQuickTextInputPrivate::parseInputMask(const QString &maskFields)
bool s;
bool escape = false;
int index = 0;
- for (int i = 0; i < m_inputMask.length(); i++) {
+ for (int i = 0; i < m_inputMask.size(); i++) {
c = m_inputMask.at(i);
if (escape) {
s = true;
@@ -4078,7 +4092,7 @@ QQuickTextInputPrivate::ValidatorState QQuickTextInputPrivate::hasAcceptableInpu
if (!m_maskData)
return AcceptableInput;
- if (str.length() != m_maxLength)
+ if (str.size() != m_maxLength)
return InvalidInput;
for (int i=0; i < m_maxLength; ++i) {
@@ -4113,7 +4127,7 @@ QString QQuickTextInputPrivate::maskString(uint pos, const QString &str, bool cl
QString s = QString::fromLatin1("");
int i = pos;
while (i < m_maxLength) {
- if (strIndex < str.length()) {
+ if (strIndex < str.size()) {
if (m_maskData[i].separator) {
s += m_maskData[i].maskChar;
if (str[strIndex] == m_maskData[i].maskChar)
@@ -4136,7 +4150,7 @@ QString QQuickTextInputPrivate::maskString(uint pos, const QString &str, bool cl
// search for separator first
int n = findInMask(i, true, true, str[strIndex]);
if (n != -1) {
- if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) {
+ if (str.size() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) {
s += QStringView{fill}.mid(i, n-i+1);
i = n + 1; // update i to find + 1
}
@@ -4204,7 +4218,7 @@ QString QQuickTextInputPrivate::stripString(const QString &str) const
return str;
QString s;
- int end = qMin(m_maxLength, str.length());
+ int end = qMin(m_maxLength, str.size());
for (int i = 0; i < end; ++i) {
if (m_maskData[i].separator)
s += m_maskData[i].maskChar;
@@ -4629,7 +4643,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event)
// no need to call del() if we have a selection, insert
// does it already
&& !hasSelectedText()
- && !(m_cursor == q_func()->text().length())) {
+ && !(m_cursor == q_func()->text().size())) {
del();
}
@@ -4872,7 +4886,7 @@ void QQuickTextInput::setOldSelectionDefault()
Q_D(QQuickTextInput);
d->selectByMouse = false;
d->selectByTouchDrag = true;
- qCDebug(lcTextInput, "pre-6.4 behavior chosen by import version: selectByMouse defaults false; if enabled, touchscreen acts like a mouse");
+ qCDebug(lcQuickTextInput, "pre-6.4 behavior chosen: selectByMouse defaults false; if enabled, touchscreen acts like a mouse");
}
// TODO in 6.7.0: remove the note about versions prior to 6.4 in selectByMouse() documentation
diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h
index 3facf42496..01d90f6b10 100644
--- a/src/quick/items/qquicktextinput_p_p.h
+++ b/src/quick/items/qquicktextinput_p_p.h
@@ -315,7 +315,7 @@ public:
#endif
}
- bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length(); }
+ bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.size(); }
bool hasSelectedText() const { return !m_text.isEmpty() && m_selend > m_selstart; }
void setSelection(int start, int length);
@@ -342,7 +342,7 @@ public:
}
int start() const { return 0; }
- int end() const { return m_text.length(); }
+ int end() const { return m_text.size(); }
QString realText() const;
@@ -379,18 +379,18 @@ public:
void cursorWordBackward(bool mark) { moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark); }
void home(bool mark) { moveCursor(0, mark); }
- void end(bool mark) { moveCursor(q_func()->text().length(), mark); }
+ void end(bool mark) { moveCursor(q_func()->text().size(), mark); }
void backspace();
void del();
void deselect() { internalDeselect(); finishChange(); }
- void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.length(), true); }
+ void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.size(), true); }
void insert(const QString &);
void clear();
void selectWordAtPos(int);
- void setCursorPosition(int pos) { if (pos <= m_text.length()) moveCursor(qMax(0, pos)); }
+ void setCursorPosition(int pos) { if (pos <= m_text.size()) moveCursor(qMax(0, pos)); }
bool fixup();
diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp
index 84fae432d3..171cbdee8b 100644
--- a/src/quick/items/qquicktextnode.cpp
+++ b/src/quick/items/qquicktextnode.cpp
@@ -223,7 +223,7 @@ void QQuickTextNode::addTextLayout(const QPointF &position, QTextLayout *textLay
engine.setPosition(position);
#if QT_CONFIG(im)
- int preeditLength = textLayout->preeditAreaText().length();
+ int preeditLength = textLayout->preeditAreaText().size();
int preeditPosition = textLayout->preeditAreaPosition();
#endif
diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp
index df96a4af41..d2256128cf 100644
--- a/src/quick/items/qquicktextnodeengine.cpp
+++ b/src/quick/items/qquicktextnodeengine.cpp
@@ -175,10 +175,7 @@ void QQuickTextNodeEngine::addTextDecorations(const QVarLengthArray<TextDecorati
{
QRectF &rect = textDecoration.rect;
- rect.setY(qRound(rect.y()
- + m_currentLine.ascent()
- + (m_currentLine.leadingIncluded() ? m_currentLine.leading() : qreal(0.0f))
- + offset));
+ rect.setY(qRound(rect.y() + m_currentLine.ascent() + offset));
rect.setHeight(thickness);
}
@@ -960,7 +957,7 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText
{
Q_ASSERT(textDocument);
#if QT_CONFIG(im)
- int preeditLength = block.isValid() ? block.layout()->preeditAreaText().length() : 0;
+ int preeditLength = block.isValid() ? block.layout()->preeditAreaText().size() : 0;
int preeditPosition = block.isValid() ? block.layout()->preeditAreaPosition() : -1;
#endif
@@ -1082,14 +1079,14 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText
}
QQuickTextNodeEngine::SelectionState selectionState =
- (selectionStart < textPos + text.length()
+ (selectionStart < textPos + text.size()
&& selectionEnd >= textPos)
? QQuickTextNodeEngine::Selected
: QQuickTextNodeEngine::Unselected;
addTextObject(block, QPointF(), charFormat, selectionState, textDocument, textPos);
}
- textPos += text.length();
+ textPos += text.size();
} else {
if (charFormat.foreground().style() != Qt::NoBrush)
setTextColor(charFormat.foreground().color());
diff --git a/src/quick/items/qquicktreeview.cpp b/src/quick/items/qquicktreeview.cpp
index a8df1ac00a..3ba739d0ca 100644
--- a/src/quick/items/qquicktreeview.cpp
+++ b/src/quick/items/qquicktreeview.cpp
@@ -67,7 +67,7 @@
\li \c {required property bool expanded}
- Is \c true if the model item drawn by the delegate is expanded
in the view.
- \li \c {required property int hasChildren}
+ \li \c {required property bool hasChildren}
- Is \c true if the model item drawn by the delegate has children
in the model.
\li \c {required property int depth}
@@ -338,8 +338,8 @@ void QQuickTreeViewPrivate::updateSelection(const QRect &oldSelection, const QRe
for (int row = newRect.y(); row <= newRect.y() + newRect.height(); ++row) {
if (oldRect.y() != -1 && oldRect.y() <= row && row <= oldRect.y() + oldRect.height())
continue;
- const QModelIndex startIndex = q->modelIndex(newRect.x(), row);
- const QModelIndex endIndex = q->modelIndex(newRect.x() + newRect.width(), row);
+ const QModelIndex startIndex = q->index(row, newRect.x());
+ const QModelIndex endIndex = q->index(row, newRect.x() + newRect.width());
selectionModel->select(QItemSelection(startIndex, endIndex), QItemSelectionModel::Select);
}
@@ -351,15 +351,15 @@ void QQuickTreeViewPrivate::updateSelection(const QRect &oldSelection, const QRe
if (oldRect.x() <= column && column <= oldRect.x() + oldRect.width())
continue;
for (int row = newRect.y(); row <= newRect.y() + newRect.height(); ++row)
- selectionModel->select(q->modelIndex(column, row), QItemSelectionModel::Select);
+ selectionModel->select(q->index(row, column), QItemSelectionModel::Select);
}
// Unselect the rows inside oldRect that don't overlap with newRect
for (int row = oldRect.y(); row <= oldRect.y() + oldRect.height(); ++row) {
if (newRect.y() <= row && row <= newRect.y() + newRect.height())
continue;
- const QModelIndex startIndex = q->modelIndex(oldRect.x(), row);
- const QModelIndex endIndex = q->modelIndex(oldRect.x() + oldRect.width(), row);
+ const QModelIndex startIndex = q->index(row, oldRect.x());
+ const QModelIndex endIndex = q->index(row, oldRect.x() + oldRect.width());
selectionModel->select(QItemSelection(startIndex, endIndex), QItemSelectionModel::Deselect);
}
@@ -375,7 +375,7 @@ void QQuickTreeViewPrivate::updateSelection(const QRect &oldSelection, const QRe
// performance. But large selections containing a lot of columns is not normally
// the case for a treeview, so accept this potential corner case for now.
for (int row = newRect.y(); row <= newRect.y() + newRect.height(); ++row)
- selectionModel->select(q->modelIndex(column, row), QItemSelectionModel::Deselect);
+ selectionModel->select(q->index(row, column), QItemSelectionModel::Deselect);
}
}
}
@@ -588,10 +588,25 @@ QPoint QQuickTreeView::cellAtIndex(const QModelIndex &index) const
return QPoint(tableIndex.column(), tableIndex.row());
}
-QModelIndex QQuickTreeView::modelIndex(int column, int row) const
+#if QT_DEPRECATED_SINCE(6, 4)
+QModelIndex QQuickTreeView::modelIndex(int row, int column) const
{
- return modelIndex({column, row});
+ static const bool compat6_4 = qEnvironmentVariable("QT_QUICK_TABLEVIEW_COMPAT_VERSION") == QStringLiteral("6.4");
+ if (compat6_4) {
+ // XXX Qt 7: Remove this compatibility path here and in QQuickTableView.
+ // In Qt 6.4.0 and 6.4.1, a source incompatible change led to row and column
+ // being documented to be specified in the opposite order.
+ // QT_QUICK_TABLEVIEW_COMPAT_VERSION can therefore be set to force tableview
+ // to continue accepting calls to modelIndex(column, row).
+ return modelIndex({row, column});
+ } else {
+ qmlWarning(this) << "modelIndex(row, column) is deprecated. "
+ "Use index(row, column) instead. For more information, see "
+ "https://doc.qt.io/qt-6/qml-qtquick-tableview-obsolete.html";
+ return modelIndex({column, row});
+ }
}
+#endif
void QQuickTreeView::keyPressEvent(QKeyEvent *event)
{
diff --git a/src/quick/items/qquicktreeview_p.h b/src/quick/items/qquicktreeview_p.h
index f86d6f9369..3b77477684 100644
--- a/src/quick/items/qquicktreeview_p.h
+++ b/src/quick/items/qquicktreeview_p.h
@@ -44,9 +44,13 @@ public:
Q_REVISION(6, 4) Q_INVOKABLE void expandToIndex(const QModelIndex &index);
Q_INVOKABLE QModelIndex modelIndex(const QPoint &cell) const override;
- Q_INVOKABLE QModelIndex modelIndex(int column, int row) const override;
Q_INVOKABLE QPoint cellAtIndex(const QModelIndex &index) const override;
+#if QT_DEPRECATED_SINCE(6, 4)
+ QT_DEPRECATED_VERSION_X_6_4("Use index(row, column) instead")
+ Q_REVISION(6, 4) Q_INVOKABLE QModelIndex modelIndex(int row, int column) const override;
+#endif
+
Q_SIGNALS:
void expanded(int row, int depth);
void collapsed(int row, bool recursively);
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 2026d41fdf..692e7f284d 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -53,6 +53,7 @@
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcHoverTrace)
Q_DECLARE_LOGGING_CATEGORY(lcMouse)
Q_DECLARE_LOGGING_CATEGORY(lcTouch)
Q_DECLARE_LOGGING_CATEGORY(lcPtr)
@@ -279,7 +280,7 @@ struct PolishLoopDetector
**/
bool check(QQuickItem *item, int itemsRemainingBeforeUpdatePolish)
{
- if (itemsToPolish.count() > itemsRemainingBeforeUpdatePolish) {
+ if (itemsToPolish.size() > itemsRemainingBeforeUpdatePolish) {
// Detected potential polish loop.
++numPolishLoopsInSequence;
if (numPolishLoopsInSequence >= 1000) {
@@ -338,7 +339,7 @@ void QQuickWindowPrivate::polishItems()
QQuickItem *item = itemsToPolish.takeLast();
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
itemPrivate->polishScheduled = false;
- const int itemsRemaining = itemsToPolish.count();
+ const int itemsRemaining = itemsToPolish.size();
itemPrivate->updatePolish();
item->updatePolish();
if (polishLoopDetector.check(item, itemsRemaining) == true)
@@ -651,7 +652,7 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfa
pixelSize = size * devicePixelRatio;
else
pixelSize = surfaceSize;
- QSizeF logicalSize = QSizeF(pixelSize) / devicePixelRatio;
+ QSize logicalSize = pixelSize / devicePixelRatio;
renderer->setDevicePixelRatio(devicePixelRatio);
renderer->setDeviceRect(QRect(QPoint(0, 0), pixelSize));
@@ -1078,7 +1079,11 @@ QQuickWindow::QQuickWindow(QQuickWindowPrivate &dd, QWindow *parent)
}
/*!
- \internal
+ Constructs a window for displaying a QML scene, whose rendering will
+ be controlled by the \a control object.
+ Please refer to QQuickRenderControl's documentation for more information.
+
+ \since 5.4
*/
QQuickWindow::QQuickWindow(QQuickRenderControl *control)
: QWindow(*(new QQuickWindowPrivate), nullptr)
@@ -1381,6 +1386,7 @@ bool QQuickWindow::event(QEvent *event)
for (pt : pe->points()) would only iterate once, so we might as well skip that logic.
*/
if (pe->pointCount()) {
+ const bool synthMouse = QQuickDeliveryAgentPrivate::isSynthMouse(pe);
if (QQuickDeliveryAgentPrivate::subsceneAgentsExist) {
bool ret = false;
// Split up the multi-point event according to the relevant QQuickDeliveryAgent that should deliver to each existing grabber
@@ -1389,7 +1395,7 @@ bool QQuickWindow::event(QEvent *event)
QEventPoint::States eventStates;
auto insert = [&](QQuickDeliveryAgent *ptda, const QEventPoint &pt) {
- if (pt.state() == QEventPoint::Pressed)
+ if (pt.state() == QEventPoint::Pressed && !synthMouse)
pe->clearPassiveGrabbers(pt);
auto &ptList = deliveryAgentsNeedingPoints[ptda];
auto idEquals = [](auto id) { return [id] (const auto &e) { return e.id() == id; }; };
@@ -1452,7 +1458,9 @@ bool QQuickWindow::event(QEvent *event)
if (ret)
return true;
- } else {
+ } else if (!synthMouse) {
+ // clear passive grabbers unless it's a system synth-mouse event
+ // QTBUG-104890: Windows sends synth mouse events (which should be ignored) after touch events
for (const auto &pt : pe->points()) {
if (pt.state() == QEventPoint::Pressed)
pe->clearPassiveGrabbers(pt);
@@ -1665,10 +1673,14 @@ void QQuickWindowPrivate::updateCursor(const QPointF &scenePos, QQuickItem *root
QWindow *window = renderWindow ? renderWindow : q;
cursorItem = cursorItemAndHandler.first;
cursorHandler = cursorItemAndHandler.second;
- if (cursorItem)
- window->setCursor(QQuickItemPrivate::get(cursorItem)->effectiveCursor(cursorHandler));
- else
+ if (cursorItem) {
+ const auto cursor = QQuickItemPrivate::get(cursorItem)->effectiveCursor(cursorHandler);
+ qCDebug(lcHoverTrace) << "setting cursor" << cursor << "from" << cursorHandler << "or" << cursorItem;
+ window->setCursor(cursor);
+ } else {
+ qCDebug(lcHoverTrace) << "unsetting cursor";
window->unsetCursor();
+ }
}
}
@@ -1683,7 +1695,7 @@ QPair<QQuickItem*, QQuickPointerHandler*> QQuickWindowPrivate::findCursorItemAnd
if (itemPrivate->subtreeCursorEnabled) {
QList<QQuickItem *> children = itemPrivate->paintOrderChildItems();
- for (int ii = children.count() - 1; ii >= 0; --ii) {
+ for (int ii = children.size() - 1; ii >= 0; --ii) {
QQuickItem *child = children.at(ii);
if (!child->isVisible() || !child->isEnabled() || QQuickItemPrivate::get(child)->culled)
continue;
@@ -1806,7 +1818,7 @@ void QQuickWindowPrivate::rhiCreationFailureMessage(const QString &backendName,
void QQuickWindowPrivate::cleanupNodes()
{
- for (int ii = 0; ii < cleanupNodeList.count(); ++ii)
+ for (int ii = 0; ii < cleanupNodeList.size(); ++ii)
delete cleanupNodeList.at(ii);
cleanupNodeList.clear();
}
@@ -1841,7 +1853,7 @@ void QQuickWindowPrivate::cleanupNodesOnShutdown(QQuickItem *item)
}
}
- for (int ii = 0; ii < p->childItems.count(); ++ii)
+ for (int ii = 0; ii < p->childItems.size(); ++ii)
cleanupNodesOnShutdown(p->childItems.at(ii));
}
@@ -1896,7 +1908,7 @@ static QSGNode *fetchNextNode(QQuickItemPrivate *itemPriv, int &ii, bool &return
{
QList<QQuickItem *> orderedChildren = itemPriv->paintOrderChildItems();
- for (; ii < orderedChildren.count() && orderedChildren.at(ii)->z() < 0; ++ii) {
+ for (; ii < orderedChildren.size() && orderedChildren.at(ii)->z() < 0; ++ii) {
QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(orderedChildren.at(ii));
if (!childPrivate->explicitVisible &&
(!childPrivate->extra.isAllocated() || !childPrivate->extra->effectRefCount))
@@ -1911,7 +1923,7 @@ static QSGNode *fetchNextNode(QQuickItemPrivate *itemPriv, int &ii, bool &return
return itemPriv->paintNode;
}
- for (; ii < orderedChildren.count(); ++ii) {
+ for (; ii < orderedChildren.size(); ++ii) {
QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(orderedChildren.at(ii));
if (!childPrivate->explicitVisible &&
(!childPrivate->extra.isAllocated() || !childPrivate->extra->effectRefCount))
@@ -1939,7 +1951,7 @@ void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item)
if (itemPriv->x != 0. || itemPriv->y != 0.)
matrix.translate(itemPriv->x, itemPriv->y);
- for (int ii = itemPriv->transforms.count() - 1; ii >= 0; --ii)
+ for (int ii = itemPriv->transforms.size() - 1; ii >= 0; --ii)
itemPriv->transforms.at(ii)->applyTo(&matrix);
if (itemPriv->scale() != 1. || itemPriv->rotation() != 0.) {
@@ -3706,7 +3718,7 @@ void QQuickWindowPrivate::runAndClearJobs(QList<QRunnable *> *jobs)
jobs->clear();
renderJobMutex.unlock();
- for (QRunnable *r : qAsConst(jobList)) {
+ for (QRunnable *r : std::as_const(jobList)) {
r->run();
delete r;
}
@@ -3824,7 +3836,7 @@ QSGRendererInterface *QQuickWindow::rendererInterface() const
graphics API based on the platform and other conditions, set \a api to
QSGRendererInterface::Unknown.
- \since 5.8
+ \since 6.0
*/
void QQuickWindow::setGraphicsApi(QSGRendererInterface::GraphicsApi api)
{
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
index 4da188bbfe..0c0ee5e579 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
@@ -107,6 +107,18 @@ void QSGSoftwareRenderContext::initializeIfNeeded()
void QSGSoftwareRenderContext::invalidate()
{
+ qDeleteAll(m_texturesToDelete);
+ m_texturesToDelete.clear();
+
+ qDeleteAll(m_textures);
+ m_textures.clear();
+
+ qDeleteAll(m_fontEnginesToClean);
+ m_fontEnginesToClean.clear();
+
+ qDeleteAll(m_glyphCaches);
+ m_glyphCaches.clear();
+
m_sg->renderContextInvalidated(this);
emit invalidated();
}
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp
index 71e9c7b2aa..488f622dce 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp
@@ -84,7 +84,7 @@ void QSGSoftwareInternalRectangleNode::setGradientStops(const QGradientStops &st
{
//normalize stops
bool needsNormalization = false;
- for (const QGradientStop &stop : qAsConst(stops)) {
+ for (const QGradientStop &stop : std::as_const(stops)) {
if (stop.first < 0.0 || stop.first > 1.0) {
needsNormalization = true;
break;
@@ -93,7 +93,7 @@ void QSGSoftwareInternalRectangleNode::setGradientStops(const QGradientStops &st
if (needsNormalization) {
QGradientStops normalizedStops;
- if (stops.count() == 1) {
+ if (stops.size() == 1) {
//If there is only one stop, then the position does not matter
//It is just treated as a color
QGradientStop stop = stops.at(0);
@@ -104,7 +104,7 @@ void QSGSoftwareInternalRectangleNode::setGradientStops(const QGradientStops &st
int below = -1;
int above = -1;
QVector<int> between;
- for (int i = 0; i < stops.count(); ++i) {
+ for (int i = 0; i < stops.size(); ++i) {
if (stops.at(i).first < 0.0) {
below = i;
} else if (stops.at(i).first > 1.0) {
@@ -118,7 +118,7 @@ void QSGSoftwareInternalRectangleNode::setGradientStops(const QGradientStops &st
//Interpoloate new color values for above and below
if (below != -1 ) {
//If there are more than one stops left, interpolate
- if (below + 1 < stops.count()) {
+ if (below + 1 < stops.size()) {
normalizedStops.append(interpolateStop(stops.at(below), stops.at(below + 1), 0.0));
} else {
QGradientStop singleStop;
@@ -128,7 +128,7 @@ void QSGSoftwareInternalRectangleNode::setGradientStops(const QGradientStops &st
}
}
- for (int i = 0; i < between.count(); ++i)
+ for (int i = 0; i < between.size(); ++i)
normalizedStops.append(stops.at(between.at(i)));
if (above != -1) {
@@ -249,8 +249,8 @@ bool QSGSoftwareInternalRectangleNode::isOpaque() const
return false;
if (m_penWidth > 0.0f && m_penColor.alpha() < 255)
return false;
- if (m_stops.count() > 0) {
- for (const QGradientStop &stop : qAsConst(m_stops)) {
+ if (m_stops.size() > 0) {
+ for (const QGradientStop &stop : std::as_const(m_stops)) {
if (stop.second.alpha() < 255)
return false;
}
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp
index 56400161bb..20e1ca5b8b 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp
@@ -47,7 +47,7 @@ void QSGSoftwareRenderableNodeUpdater::endVisit(QSGTransformNode *)
bool QSGSoftwareRenderableNodeUpdater::visit(QSGClipNode *node)
{
// Make sure to translate the clip rect into world coordinates
- if (m_clipState.count() == 0 || (m_clipState.count() == 1 && m_clipState.top().isNull())) {
+ if (m_clipState.size() == 0 || (m_clipState.size() == 1 && m_clipState.top().isNull())) {
m_clipState.push(m_transformState.top().map(QRegion(node->clipRect().toRect())));
m_hasClip = true;
} else {
@@ -61,7 +61,7 @@ bool QSGSoftwareRenderableNodeUpdater::visit(QSGClipNode *node)
void QSGSoftwareRenderableNodeUpdater::endVisit(QSGClipNode *)
{
m_clipState.pop();
- if (m_clipState.count() == 0 || (m_clipState.count() == 1 && m_clipState.top().isNull()))
+ if (m_clipState.size() == 0 || (m_clipState.size() == 1 && m_clipState.top().isNull()))
m_hasClip = false;
}
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
index fa709deea2..d12deec9f6 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
@@ -754,7 +754,7 @@ void QSGSoftwareThreadedRenderLoop::onAnimationStarted()
{
startOrStopAnimationTimer();
- for (const WindowData &w : qAsConst(m_windows))
+ for (const WindowData &w : std::as_const(m_windows))
w.window->requestUpdate();
}
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h
index 8ae245f07e..46c2c1022f 100644
--- a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h
+++ b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h
@@ -63,7 +63,7 @@ public:
QSGTexture *removedFromAtlas(QRhiResourceUpdateBatch *) const override;
const QByteArray &data() const { return m_data; }
- int sizeInBytes() const { return m_data.length(); }
+ int sizeInBytes() const { return m_data.size(); }
private:
QRectF m_texture_coords_rect;
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index df7575a33e..29d507a8fb 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -272,14 +272,14 @@ void ShaderManager::invalidated()
void ShaderManager::clearCachedRendererData()
{
- for (ShaderManager::Shader *sms : qAsConst(stockShaders)) {
+ for (ShaderManager::Shader *sms : std::as_const(stockShaders)) {
QSGMaterialShader *s = sms->programRhi.program;
if (s) {
QSGMaterialShaderPrivate *sd = QSGMaterialShaderPrivate::get(s);
sd->clearCachedRendererData();
}
}
- for (ShaderManager::Shader *sms : qAsConst(rewrittenShaders)) {
+ for (ShaderManager::Shader *sms : std::as_const(rewrittenShaders)) {
QSGMaterialShader *s = sms->programRhi.program;
if (s) {
QSGMaterialShaderPrivate *sd = QSGMaterialShaderPrivate::get(s);
@@ -915,8 +915,14 @@ Renderer::~Renderer()
qsg_wipeBatch(m_batchPool.at(i));
}
- for (Node *n : qAsConst(m_nodes))
+ for (Node *n : std::as_const(m_nodes)) {
+ if (n->type() == QSGNode::GeometryNodeType) {
+ Element *e = n->element();
+ if (!e->removed)
+ m_elementsToDelete.add(e);
+ }
m_nodeAllocator.release(n);
+ }
// Remaining elements...
for (int i=0; i<m_elementsToDelete.size(); ++i)
@@ -1980,7 +1986,7 @@ void Renderer::uploadBatch(Batch *b)
bool canMerge = (g->drawingMode() == QSGGeometry::DrawTriangles || g->drawingMode() == QSGGeometry::DrawTriangleStrip ||
g->drawingMode() == QSGGeometry::DrawLines || g->drawingMode() == QSGGeometry::DrawPoints)
&& b->positionAttribute >= 0
- && g->indexType() == QSGGeometry::UnsignedShortType
+ && (g->indexType() == QSGGeometry::UnsignedShortType && g->indexCount() > 0)
&& (flags & (QSGMaterial::NoBatching | QSGMaterial_FullMatrix)) == 0
&& ((flags & QSGMaterial::RequiresFullMatrixExceptTranslate) == 0 || b->isTranslateOnlyToRoot())
&& b->isSafeToBatch();
@@ -2869,11 +2875,11 @@ void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms,
pd->samplerBindingTable[binding] = samplers; // does not own
}
- if (pd->textureBindingTable[binding].count() == pd->samplerBindingTable[binding].count()) {
+ if (pd->textureBindingTable[binding].size() == pd->samplerBindingTable[binding].size()) {
QVarLengthArray<QRhiShaderResourceBinding::TextureAndSampler, 4> textureSamplers;
- for (int i = 0; i < pd->textureBindingTable[binding].count(); ++i) {
+ for (int i = 0; i < pd->textureBindingTable[binding].size(); ++i) {
QRhiTexture *texture = pd->textureBindingTable[binding].at(i)->rhiTexture();
@@ -2960,7 +2966,7 @@ void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms,
// with increasing binding points afterwards, so the list is already sorted based
// on the binding points, thus we can save some time by telling the QRhi backend
// not to sort again.
- if (pd->ubufBinding <= 0 || bindings.count() <= 1)
+ if (pd->ubufBinding <= 0 || bindings.size() <= 1)
flags |= QRhiShaderResourceBindings::BindingsAreSorted;
e->srb->updateResources(flags);
@@ -3440,7 +3446,7 @@ void Renderer::releaseElement(Element *e, bool inDestructor)
} else {
if (e->srb) {
if (!inDestructor) {
- if (m_shaderManager->srbPool.count() < m_srbPoolThreshold)
+ if (m_shaderManager->srbPool.size() < m_srbPoolThreshold)
m_shaderManager->srbPool.insert(e->srb->serializedLayoutDescription(), e->srb);
else
delete e->srb;
@@ -3783,7 +3789,7 @@ void Renderer::recordRenderPass(RenderPassContext *ctx)
QRhiCommandBuffer *cb = commandBuffer();
cb->debugMarkBegin(QByteArrayLiteral("Qt Quick scene render"));
- for (int i = 0, ie = ctx->opaqueRenderBatches.count(); i != ie; ++i) {
+ for (int i = 0, ie = ctx->opaqueRenderBatches.size(); i != ie; ++i) {
PreparedRenderBatch *renderBatch = &ctx->opaqueRenderBatches[i];
if (renderBatch->batch->merged)
renderMergedBatch(renderBatch);
@@ -3791,7 +3797,7 @@ void Renderer::recordRenderPass(RenderPassContext *ctx)
renderUnmergedBatch(renderBatch);
}
- for (int i = 0, ie = ctx->alphaRenderBatches.count(); i != ie; ++i) {
+ for (int i = 0, ie = ctx->alphaRenderBatches.size(); i != ie; ++i) {
PreparedRenderBatch *renderBatch = &ctx->alphaRenderBatches[i];
if (renderBatch->batch->merged)
renderMergedBatch(renderBatch);
@@ -3803,7 +3809,7 @@ void Renderer::recordRenderPass(RenderPassContext *ctx)
if (m_renderMode == QSGRendererInterface::RenderMode3D) {
// depth post-pass
- for (int i = 0, ie = ctx->alphaRenderBatches.count(); i != ie; ++i) {
+ for (int i = 0, ie = ctx->alphaRenderBatches.size(); i != ie; ++i) {
PreparedRenderBatch *renderBatch = &ctx->alphaRenderBatches[i];
if (renderBatch->batch->merged)
renderMergedBatch(renderBatch, true);
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
index 06771d2686..5b0c024466 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
@@ -115,7 +115,7 @@ public:
// one. when an item is released, we'll reset m_freePage anyway.
if (!p) {
p = new AllocatorPage<Type, PageSize>();
- m_freePage = pages.count();
+ m_freePage = pages.size();
pages.push_back(p);
}
uint pos = p->blocks[PageSize - p->available];
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp
index bd082a8d79..9541107b78 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.cpp
+++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp
@@ -370,8 +370,10 @@ const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_ColoredPoint2D()
Geometry objects are constructed by default with DrawTriangleStrip as
the drawing mode.
- The attribute structure is assumed to be POD and the geometry object
- assumes this will not go away. There is no memory management involved.
+ \note \a attributes and the \l Attribute objects referenced by it must
+ stay valid for the entire lifetime of the QSGGeometry.
+ QSGGeometry stores a reference to \a attributes and does not delete
+ the \l Attribute objects.
*/
QSGGeometry::QSGGeometry(const QSGGeometry::AttributeSet &attributes,
@@ -494,13 +496,18 @@ const void *QSGGeometry::indexData() const
Specifies the drawing mode, also called primitive topology.
+ \note Starting with Qt 6 the scene graph only exposes topologies that are
+ supported across all the supported 3D graphics APIs. As a result, the
+ values \c DrawLineLoop and \c DrawTriangleFan are no longer supported at
+ run time in Qt 6, even though the enum values themselves are still present.
+
\value DrawPoints
\value DrawLines
- \value DrawLineLoop
+ \omitvalue DrawLineLoop
\value DrawLineStrip
\value DrawTriangles
\value DrawTriangleStrip
- \value DrawTriangleFan
+ \omitvalue DrawTriangleFan
*/
/*!
@@ -534,10 +541,10 @@ void QSGGeometry::setDrawingMode(unsigned int mode)
}
/*!
- Gets the current line or point width or to be used for this
- geometry. This property only applies to line width when the drawingMode
- is DrawLines, DarwLineStrip, or DrawLineLoop. When supported, it also
- applies to point size when the drawingMode is DrawPoints.
+ Gets the current line or point width or to be used for this geometry. This
+ property only applies to line width when the drawingMode is DrawLines or
+ DrawLineStrip. When supported, it also applies to point size when the
+ drawingMode is DrawPoints.
The default value is \c 1.0
@@ -556,10 +563,10 @@ float QSGGeometry::lineWidth() const
}
/*!
- Sets the line or point width to be used for this geometry to \a
- width. This property only applies to line width when the drawingMode is
- DrawLines, DrawLineStrip, or DrawLineLoop. When supported, it also
- applies to point size when the drawingMode is DrawPoints.
+ Sets the line or point width to be used for this geometry to \a width. This
+ property only applies to line width when the drawingMode is DrawLines or
+ DrawLineStrip. When supported, it also applies to point size when the
+ drawingMode is DrawPoints.
\note Support for point and line drawing may be limited at run time,
depending on the platform and graphics API. For example, some APIs do
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.h b/src/quick/scenegraph/coreapi/qsggeometry.h
index 1583bfd5b2..4392070b6e 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.h
+++ b/src/quick/scenegraph/coreapi/qsggeometry.h
@@ -165,6 +165,7 @@ public:
void setLineWidth(float w);
private:
+ Q_DISABLE_COPY_MOVE(QSGGeometry)
friend class QSGGeometryData;
int m_drawing_mode;
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
index e1edbc2445..a3e8b179b3 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
@@ -247,7 +247,7 @@ void QSGMaterialShaderPrivate::prepare(QShader::Variant vertexShaderVariant)
const QShaderDescription desc = it->shader.description();
const QVector<QShaderDescription::UniformBlock> ubufs = desc.uniformBlocks();
- const int ubufCount = ubufs.count();
+ const int ubufCount = ubufs.size();
if (ubufCount > 1) {
qWarning("Multiple uniform blocks found in shader. "
"This should be avoided as Qt Quick supports only one.");
@@ -272,7 +272,7 @@ void QSGMaterialShaderPrivate::prepare(QShader::Variant vertexShaderVariant)
}
const QVector<QShaderDescription::InOutVariable> imageSamplers = desc.combinedImageSamplers();
- const int imageSamplersCount = imageSamplers.count();
+ const int imageSamplersCount = imageSamplers.size();
for (int i = 0; i < imageSamplersCount; ++i) {
const QShaderDescription::InOutVariable &var(imageSamplers[i]);
diff --git a/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp b/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp
index 4352b9e795..9183de29d9 100644
--- a/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp
@@ -275,7 +275,7 @@ QRhiGraphicsPipeline *RhiVisualizer::PipelineCache::pipeline(RhiVisualizer *visu
quint32 vertexStride,
bool blendOneOne)
{
- for (int i = 0, ie = pipelines.count(); i != ie; ++i) {
+ for (int i = 0, ie = pipelines.size(); i != ie; ++i) {
const Pipeline &p(pipelines.at(i));
if (p.topology == topology && p.format == vertexFormat && p.stride == vertexStride)
return p.ps;
@@ -316,7 +316,7 @@ QRhiGraphicsPipeline *RhiVisualizer::PipelineCache::pipeline(RhiVisualizer *visu
void RhiVisualizer::PipelineCache::releaseResources()
{
- for (int i = 0, ie = pipelines.count(); i != ie; ++i)
+ for (int i = 0, ie = pipelines.size(); i != ie; ++i)
delete pipelines.at(i).ps;
pipelines.clear();
diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp
index 15167f8ae5..f9c1f86436 100644
--- a/src/quick/scenegraph/coreapi/qsgtexture.cpp
+++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp
@@ -686,6 +686,7 @@ namespace QNativeInterface {
\inmodule QtQuick
\ingroup native-interfaces
\ingroup native-interfaces-qsgtexture
+ \inheaderfile QSGTexture
\brief Provides access to and enables adopting OpenGL texture objects.
\since 6.0
*/
@@ -786,6 +787,7 @@ namespace QNativeInterface {
\inmodule QtQuick
\ingroup native-interfaces
\ingroup native-interfaces-qsgtexture
+ \inheaderfile QSGTexture
\brief Provides access to and enables adopting Direct3D 11 texture objects.
\since 6.0
*/
@@ -846,6 +848,7 @@ namespace QNativeInterface {
\inmodule QtQuick
\ingroup native-interfaces
\ingroup native-interfaces-qsgtexture
+ \inheaderfile QSGTexture
\brief Provides access to and enables adopting Metal texture objects.
\since 6.0
*/
@@ -893,6 +896,7 @@ namespace QNativeInterface {
\inmodule QtQuick
\ingroup native-interfaces
\ingroup native-interfaces-qsgtexture
+ \inheaderfile QSGTexture
\brief Provides access to and enables adopting Vulkan image objects.
\since 6.0
*/
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp
index b2932a12ea..c20a126dce 100644
--- a/src/quick/scenegraph/qsgadaptationlayer.cpp
+++ b/src/quick/scenegraph/qsgadaptationlayer.cpp
@@ -91,7 +91,7 @@ void QSGDistanceFieldGlyphCache::populate(const QVector<glyph_t> &glyphs)
{
QSet<glyph_t> referencedGlyphs;
QSet<glyph_t> newGlyphs;
- int count = glyphs.count();
+ int count = glyphs.size();
for (int i = 0; i < count; ++i) {
glyph_t glyphIndex = glyphs.at(i);
if ((int) glyphIndex >= glyphCount() && glyphCount() > 0) {
@@ -124,7 +124,7 @@ void QSGDistanceFieldGlyphCache::populate(const QVector<glyph_t> &glyphs)
void QSGDistanceFieldGlyphCache::release(const QVector<glyph_t> &glyphs)
{
QSet<glyph_t> unusedGlyphs;
- int count = glyphs.count();
+ int count = glyphs.size();
for (int i = 0; i < count; ++i) {
glyph_t glyphIndex = glyphs.at(i);
GlyphData &gd = glyphData(glyphIndex);
@@ -180,7 +180,7 @@ void QSGDistanceFieldGlyphCache::update()
storeGlyphs(distanceFields);
#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG)
- for (Texture texture : qAsConst(m_textures))
+ for (Texture texture : std::as_const(m_textures))
saveTexture(texture.texture, m_referenceFont.familyName());
#endif
@@ -203,7 +203,7 @@ void QSGDistanceFieldGlyphCache::setGlyphsPosition(const QList<GlyphPosition> &g
{
QVector<quint32> invalidatedGlyphs;
- int count = glyphs.count();
+ int count = glyphs.size();
for (int i = 0; i < count; ++i) {
GlyphPosition glyph = glyphs.at(i);
GlyphData &gd = glyphData(glyph.glyph);
@@ -254,7 +254,7 @@ void QSGDistanceFieldGlyphCache::setGlyphsTexture(const QVector<glyph_t> &glyphs
QVector<quint32> invalidatedGlyphs;
- int count = glyphs.count();
+ int count = glyphs.size();
for (int j = 0; j < count; ++j) {
glyph_t glyphIndex = glyphs.at(j);
GlyphData &gd = glyphData(glyphIndex);
@@ -272,14 +272,14 @@ void QSGDistanceFieldGlyphCache::setGlyphsTexture(const QVector<glyph_t> &glyphs
void QSGDistanceFieldGlyphCache::markGlyphsToRender(const QVector<glyph_t> &glyphs)
{
- int count = glyphs.count();
+ int count = glyphs.size();
for (int i = 0; i < count; ++i)
m_pendingGlyphs.add(glyphs.at(i));
}
void QSGDistanceFieldGlyphCache::updateRhiTexture(QRhiTexture *oldTex, QRhiTexture *newTex, const QSize &newTexSize)
{
- int count = m_textures.count();
+ int count = m_textures.size();
for (int i = 0; i < count; ++i) {
Texture &tex = m_textures[i];
if (tex.texture == oldTex) {
diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h
index c20a99a8a9..a1edc97f52 100644
--- a/src/quick/scenegraph/qsgadaptationlayer_p.h
+++ b/src/quick/scenegraph/qsgadaptationlayer_p.h
@@ -256,7 +256,6 @@ public:
Texture // for APIs with separate texture and sampler objects
};
struct Variable {
- Variable() {}
VariableType type = Constant;
QByteArray name;
uint offset = 0; // for cbuffer members
@@ -337,6 +336,7 @@ public:
};
ShaderSyncData vertex;
ShaderSyncData fragment;
+ void *materialTypeCacheKey;
};
// Each ShaderEffect item has one node (render thread) and one manager (gui thread).
diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp
index 192bd565a9..e21f2fbb6f 100644
--- a/src/quick/scenegraph/qsgcontextplugin.cpp
+++ b/src/quick/scenegraph/qsgcontextplugin.cpp
@@ -81,7 +81,7 @@ QSGAdaptationBackendData *contextFactory()
const QStringList args = QGuiApplication::arguments();
QString requestedBackend = backendData->quickWindowBackendRequest; // empty or set via QQuickWindow::setSceneGraphBackend()
- for (int index = 0; index < args.count(); ++index) {
+ for (int index = 0; index < args.size(); ++index) {
if (args.at(index).startsWith(QLatin1String("--device="))) {
requestedBackend = args.at(index).mid(9);
break;
@@ -129,7 +129,7 @@ QSGAdaptationBackendData *contextFactory()
qCDebug(QSG_LOG_INFO, "Loading backend %s", qUtf8Printable(requestedBackend));
// First look for a built-in adaptation.
- for (QSGContextFactoryInterface *builtInBackend : qAsConst(backendData->builtIns)) {
+ for (QSGContextFactoryInterface *builtInBackend : std::as_const(backendData->builtIns)) {
if (builtInBackend->keys().contains(requestedBackend)) {
backendData->factory = builtInBackend;
backendData->name = requestedBackend;
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index 429d7ad4e1..43a7e919bc 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -472,9 +472,11 @@ void QSGTextMaskMaterial::populate(const QPointF &p,
bool supportsSubPixelPositions = fontD->fontEngine->supportsHorizontalSubPixelPositions();
for (int i=0; i<glyphIndexes.size(); ++i) {
QPointF glyphPosition = glyphPositions.at(i) + position;
+ QFixedPoint fixedPointPosition = fixedPointPositions.at(i);
+
QFixed subPixelPosition;
if (supportsSubPixelPositions)
- subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(glyphPosition.x() * glyphCacheScaleX));
+ subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(fixedPointPosition.x.toReal() * glyphCacheScaleX));
QTextureGlyphCache::GlyphAndSubPixelPosition glyph(glyphIndexes.at(i),
QFixedPoint(subPixelPosition, 0));
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
index 3fee9d9faf..cd0a5b6d28 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
@@ -119,7 +119,7 @@ void QSGDefaultRenderContext::invalidate()
qDeleteAll(m_glyphCaches);
m_glyphCaches.clear();
- releaseGlyphCacheResourceUpdates();
+ resetGlyphCacheResources();
m_rhi = nullptr;
@@ -264,12 +264,23 @@ QRhiResourceUpdateBatch *QSGDefaultRenderContext::glyphCacheResourceUpdates()
return m_glyphCacheResourceUpdates;
}
-void QSGDefaultRenderContext::releaseGlyphCacheResourceUpdates()
+void QSGDefaultRenderContext::deferredReleaseGlyphCacheTexture(QRhiTexture *texture)
+{
+ if (texture)
+ m_pendingGlyphCacheTextures.insert(texture);
+}
+
+void QSGDefaultRenderContext::resetGlyphCacheResources()
{
if (m_glyphCacheResourceUpdates) {
m_glyphCacheResourceUpdates->release();
m_glyphCacheResourceUpdates = nullptr;
}
+
+ for (QRhiTexture *t : std::as_const(m_pendingGlyphCacheTextures))
+ t->deleteLater(); // the QRhiTexture object stays valid for the current frame
+
+ m_pendingGlyphCacheTextures.clear();
}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext_p.h b/src/quick/scenegraph/qsgdefaultrendercontext_p.h
index 448255a594..580a973e85 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext_p.h
+++ b/src/quick/scenegraph/qsgdefaultrendercontext_p.h
@@ -24,6 +24,7 @@ class QRhi;
class QRhiCommandBuffer;
class QRhiRenderPassDescriptor;
class QRhiResourceUpdateBatch;
+class QRhiTexture;
class QSGMaterialShader;
class QSurface;
@@ -102,7 +103,8 @@ public:
QRhiResourceUpdateBatch *maybeGlyphCacheResourceUpdates();
QRhiResourceUpdateBatch *glyphCacheResourceUpdates();
- void releaseGlyphCacheResourceUpdates();
+ void deferredReleaseGlyphCacheTexture(QRhiTexture *texture);
+ void resetGlyphCacheResources();
protected:
static QString fontKey(const QRawFont &font, int renderTypeQuality);
@@ -116,6 +118,7 @@ protected:
qreal m_currentDevicePixelRatio;
bool m_useDepthBufferFor2D;
QRhiResourceUpdateBatch *m_glyphCacheResourceUpdates;
+ QSet<QRhiTexture *> m_pendingGlyphCacheTextures;
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
index bff5d0404d..64f862f948 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
@@ -101,11 +101,11 @@ void QSGDistanceFieldGlyphNode::setGlyphs(const QPointF &position, const QGlyphR
m_glyph_cache->populate(glyphs.glyphIndexes());
const QVector<quint32> glyphIndexes = m_glyphs.glyphIndexes();
- for (int i = 0; i < glyphIndexes.count(); ++i)
+ for (int i = 0; i < glyphIndexes.size(); ++i)
m_allGlyphIndexesLookup.insert(glyphIndexes.at(i));
qCDebug(lcSgText, "inserting %" PRIdQSIZETYPE " glyphs, %" PRIdQSIZETYPE " unique",
- glyphIndexes.count(),
- m_allGlyphIndexesLookup.count());
+ glyphIndexes.size(),
+ m_allGlyphIndexesLookup.size());
#ifdef QSG_RUNTIME_DESCRIPTION
qsgnode_set_description(this, QString::number(glyphs.glyphIndexes().count()) + QStringLiteral(" DF glyphs: ") +
m_glyphs.rawFont().familyName() + QStringLiteral(" ") + QString::number(m_glyphs.rawFont().pixelSize()));
@@ -147,7 +147,7 @@ void QSGDistanceFieldGlyphNode::invalidateGlyphs(const QVector<quint32> &glyphs)
if (m_dirtyGeometry)
return;
- for (int i = 0; i < glyphs.count(); ++i) {
+ for (int i = 0; i < glyphs.size(); ++i) {
if (m_allGlyphIndexesLookup.contains(glyphs.at(i))) {
m_dirtyGeometry = true;
setFlag(UsePreprocess);
@@ -289,12 +289,12 @@ void QSGDistanceFieldGlyphNode::updateGeometry()
Q_ASSERT(m_glyphsInOtherTextures.isEmpty());
} else {
if (!m_glyphsInOtherTextures.isEmpty())
- qCDebug(lcSgText, "%" PRIdQSIZETYPE " 'other' textures", m_glyphsInOtherTextures.count());
+ qCDebug(lcSgText, "%" PRIdQSIZETYPE " 'other' textures", m_glyphsInOtherTextures.size());
QHash<const QSGDistanceFieldGlyphCache::Texture *, GlyphInfo>::const_iterator ite = m_glyphsInOtherTextures.constBegin();
while (ite != m_glyphsInOtherTextures.constEnd()) {
QGlyphRun subNodeGlyphRun(m_glyphs);
- for (int i = 0; i < ite->indexes.count(); i += maxIndexCount) {
- int len = qMin(maxIndexCount, ite->indexes.count() - i);
+ for (int i = 0; i < ite->indexes.size(); i += maxIndexCount) {
+ int len = qMin(maxIndexCount, ite->indexes.size() - i);
subNodeGlyphRun.setRawData(ite->indexes.constData() + i, ite->positions.constData() + i, len);
qCDebug(lcSgText) << "subNodeGlyphRun has" << len << "positions:"
<< *(ite->positions.constData() + i) << "->" << *(ite->positions.constData() + i + len - 1);
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index 5545ea05d9..6dee0304ab 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -329,7 +329,7 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window)
d->cleanupNodesOnShutdown();
#if QT_CONFIG(quick_shadereffect)
- QSGRhiShaderEffectNode::cleanupMaterialTypeCache();
+ QSGRhiShaderEffectNode::cleanupMaterialTypeCache(window);
#endif
if (m_windows.size() == 0) {
diff --git a/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
index abd0f9c790..54cf298943 100644
--- a/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
@@ -32,19 +32,10 @@ QSGRhiDistanceFieldGlyphCache::QSGRhiDistanceFieldGlyphCache(QSGDefaultRenderCon
QSGRhiDistanceFieldGlyphCache::~QSGRhiDistanceFieldGlyphCache()
{
- // A plain delete should work, but just in case commitResourceUpdates was
- // not called and something is enqueued on the update batch for a texture,
- // defer until the end of the frame.
- for (int i = 0; i < m_textures.count(); ++i) {
- if (m_textures[i].texture)
- m_textures[i].texture->deleteLater();
- }
+ for (const TextureInfo &t : std::as_const(m_textures))
+ m_rc->deferredReleaseGlyphCacheTexture(t.texture);
delete m_areaAllocator;
-
- // should be empty, but just in case
- for (QRhiTexture *t : qAsConst(m_pendingDispose))
- t->deleteLater();
}
void QSGRhiDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyphs)
@@ -113,7 +104,7 @@ void QSGRhiDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyphs)
bool QSGRhiDistanceFieldGlyphCache::isActive() const
{
- return m_unusedGlyphs.size() != m_glyphsTexture.size();
+ return !m_referencedGlyphs.empty();
}
void QSGRhiDistanceFieldGlyphCache::storeGlyphs(const QList<QDistanceField> &glyphs)
@@ -176,11 +167,13 @@ void QSGRhiDistanceFieldGlyphCache::storeGlyphs(const QList<QDistanceField> &gly
void QSGRhiDistanceFieldGlyphCache::referenceGlyphs(const QSet<glyph_t> &glyphs)
{
+ m_referencedGlyphs += glyphs;
m_unusedGlyphs -= glyphs;
}
void QSGRhiDistanceFieldGlyphCache::releaseGlyphs(const QSet<glyph_t> &glyphs)
{
+ m_referencedGlyphs -= glyphs;
m_unusedGlyphs += glyphs;
}
@@ -241,7 +234,7 @@ void QSGRhiDistanceFieldGlyphCache::resizeTexture(TextureInfo *texInfo, int widt
resourceUpdates->copyTexture(texInfo->texture, oldTexture);
}
- m_pendingDispose.insert(oldTexture);
+ m_rc->deferredReleaseGlyphCacheTexture(oldTexture);
}
bool QSGRhiDistanceFieldGlyphCache::useTextureResizeWorkaround() const
@@ -520,14 +513,8 @@ void QSGRhiDistanceFieldGlyphCache::commitResourceUpdates(QRhiResourceUpdateBatc
{
if (QRhiResourceUpdateBatch *resourceUpdates = m_rc->maybeGlyphCacheResourceUpdates()) {
mergeInto->merge(resourceUpdates);
- m_rc->releaseGlyphCacheResourceUpdates();
+ m_rc->resetGlyphCacheResources();
}
-
- // now let's assume the resource updates will be committed in this frame
- for (QRhiTexture *t : qAsConst(m_pendingDispose))
- t->deleteLater(); // will be deleted after the frame is submitted -> safe
-
- m_pendingDispose.clear();
}
bool QSGRhiDistanceFieldGlyphCache::eightBitFormatIsAlphaSwizzled() const
diff --git a/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h
index aed2739c89..b7653881f5 100644
--- a/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h
@@ -71,7 +71,7 @@ private:
TextureInfo *textureInfo(int index)
{
- for (int i = m_textures.count(); i <= index; ++i) {
+ for (int i = m_textures.size(); i <= index; ++i) {
if (createFullSizeTextures())
m_textures.append(QRect(0, 0, maxTextureSize(), maxTextureSize()));
else
@@ -89,6 +89,7 @@ private:
QList<TextureInfo> m_textures;
QHash<glyph_t, TextureInfo *> m_glyphsTexture;
QSet<glyph_t> m_unusedGlyphs;
+ QSet<glyph_t> m_referencedGlyphs;
QSet<QRhiTexture *> m_pendingDispose;
};
diff --git a/src/quick/scenegraph/qsgrhishadereffectnode.cpp b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
index e831c97a80..e7c2b0fb0d 100644
--- a/src/quick/scenegraph/qsgrhishadereffectnode.cpp
+++ b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
@@ -11,6 +11,7 @@
#include <QQmlFile>
#include <QFile>
#include <QFileSelector>
+#include <QMutexLocker>
QT_BEGIN_NAMESPACE
@@ -27,14 +28,18 @@ void QSGRhiShaderLinker::reset(const QShader &vs, const QShader &fs)
m_samplers.clear();
m_samplerNameMap.clear();
m_subRectBindings.clear();
+
+ m_constants.reserve(8);
+ m_samplers.reserve(4);
+ m_samplerNameMap.reserve(4);
}
void QSGRhiShaderLinker::feedConstants(const QSGShaderEffectNode::ShaderData &shader, const QSet<int> *dirtyIndices)
{
- Q_ASSERT(shader.shaderInfo.variables.count() == shader.varData.count());
+ Q_ASSERT(shader.shaderInfo.variables.size() == shader.varData.size());
if (!dirtyIndices) {
m_constantBufferSize = qMax(m_constantBufferSize, shader.shaderInfo.constantDataSize);
- for (int i = 0; i < shader.shaderInfo.variables.count(); ++i) {
+ for (int i = 0; i < shader.shaderInfo.variables.size(); ++i) {
const QSGGuiThreadShaderEffectManager::ShaderInfo::Variable &var(shader.shaderInfo.variables.at(i));
if (var.type == QSGGuiThreadShaderEffectManager::ShaderInfo::Constant) {
const QSGShaderEffectNode::VariableData &vd(shader.varData.at(i));
@@ -75,11 +80,17 @@ void QSGRhiShaderLinker::feedConstants(const QSGShaderEffectNode::ShaderData &sh
void QSGRhiShaderLinker::feedSamplers(const QSGShaderEffectNode::ShaderData &shader, const QSet<int> *dirtyIndices)
{
if (!dirtyIndices) {
- for (int i = 0; i < shader.shaderInfo.variables.count(); ++i) {
+ for (int i = 0; i < shader.shaderInfo.variables.size(); ++i) {
const QSGGuiThreadShaderEffectManager::ShaderInfo::Variable &var(shader.shaderInfo.variables.at(i));
const QSGShaderEffectNode::VariableData &vd(shader.varData.at(i));
if (var.type == QSGGuiThreadShaderEffectManager::ShaderInfo::Sampler) {
Q_ASSERT(vd.specialType == QSGShaderEffectNode::VariableData::Source);
+
+#ifndef QT_NO_DEBUG
+ int existingBindPoint = m_samplerNameMap.value(var.name, -1);
+ Q_ASSERT(existingBindPoint < 0 || existingBindPoint == var.bindPoint);
+#endif
+
m_samplers.insert(var.bindPoint, vd.value);
m_samplerNameMap.insert(var.name, var.bindPoint);
}
@@ -88,6 +99,12 @@ void QSGRhiShaderLinker::feedSamplers(const QSGShaderEffectNode::ShaderData &sha
for (int idx : *dirtyIndices) {
const QSGGuiThreadShaderEffectManager::ShaderInfo::Variable &var(shader.shaderInfo.variables.at(idx));
const QSGShaderEffectNode::VariableData &vd(shader.varData.at(idx));
+
+#ifndef QT_NO_DEBUG
+ int existingBindPoint = m_samplerNameMap.value(var.name, -1);
+ Q_ASSERT(existingBindPoint < 0 || existingBindPoint == var.bindPoint);
+#endif
+
m_samplers.insert(var.bindPoint, vd.value);
m_samplerNameMap.insert(var.name, var.bindPoint);
}
@@ -142,11 +159,18 @@ struct QSGRhiShaderMaterialTypeCache
void reset() { qDeleteAll(m_types); m_types.clear(); }
struct Key {
- QShader blob[2];
- Key() { }
- Key(const QShader &vs, const QShader &fs) { blob[0] = vs; blob[1] = fs; }
+ QShader vs;
+ QShader fs;
+ size_t hash;
+ Key(const QShader &vs, const QShader &fs)
+ : vs(vs),
+ fs(fs)
+ {
+ QtPrivate::QHashCombine hashGen;
+ hash = hashGen(hashGen(0, vs), fs);
+ }
bool operator==(const Key &other) const {
- return blob[0] == other.blob[0] && blob[1] == other.blob[1];
+ return vs == other.vs && fs == other.fs;
}
};
QHash<Key, QSGMaterialType *> m_types;
@@ -154,10 +178,7 @@ struct QSGRhiShaderMaterialTypeCache
size_t qHash(const QSGRhiShaderMaterialTypeCache::Key &key, size_t seed = 0)
{
- size_t hash = seed;
- for (int i = 0; i < 2; ++i)
- hash = hash * 31337 + qHash(key.blob[i]);
- return hash;
+ return seed ^ key.hash;
}
QSGMaterialType *QSGRhiShaderMaterialTypeCache::get(const QShader &vs, const QShader &fs)
@@ -171,7 +192,8 @@ QSGMaterialType *QSGRhiShaderMaterialTypeCache::get(const QShader &vs, const QSh
return t;
}
-static QSGRhiShaderMaterialTypeCache shaderMaterialTypeCache;
+static QHash<void *, QSGRhiShaderMaterialTypeCache> shaderMaterialTypeCache;
+static QMutex shaderMaterialTypeCacheMutex;
class QSGRhiShaderEffectMaterialShader : public QSGMaterialShader
{
@@ -447,7 +469,7 @@ int QSGRhiShaderEffectMaterial::compare(const QSGMaterial *other) const
if (int diff = m_cullMode - o->m_cullMode)
return diff;
- if (int diff = m_textureProviders.count() - o->m_textureProviders.count())
+ if (int diff = m_textureProviders.size() - o->m_textureProviders.size())
return diff;
if (m_linker.m_constants != o->m_linker.m_constants)
@@ -459,7 +481,7 @@ int QSGRhiShaderEffectMaterial::compare(const QSGMaterial *other) const
if (hasAtlasTexture(o->m_textureProviders) && !o->m_geometryUsesTextureSubRect)
return 1;
- for (int binding = 0, count = m_textureProviders.count(); binding != count; ++binding) {
+ for (int binding = 0, count = m_textureProviders.size(); binding != count; ++binding) {
QSGTextureProvider *tp1 = m_textureProviders.at(binding);
QSGTextureProvider *tp2 = o->m_textureProviders.at(binding);
if (tp1 && tp2) {
@@ -559,7 +581,7 @@ QRectF QSGRhiShaderEffectNode::updateNormalizedTextureSubRect(bool supportsAtlas
bool geometryUsesTextureSubRect = false;
if (supportsAtlasTextures) {
QSGTextureProvider *tp = nullptr;
- for (int binding = 0, count = m_material.m_textureProviders.count(); binding != count; ++binding) {
+ for (int binding = 0, count = m_material.m_textureProviders.size(); binding != count; ++binding) {
if (QSGTextureProvider *candidate = m_material.m_textureProviders.at(binding)) {
if (!tp) {
tp = candidate;
@@ -627,7 +649,12 @@ void QSGRhiShaderEffectNode::syncMaterial(SyncData *syncData)
m_material.m_fragmentShader = defaultFragmentShader;
}
- m_material.m_materialType = shaderMaterialTypeCache.get(m_material.m_vertexShader, m_material.m_fragmentShader);
+ {
+ QMutexLocker lock(&shaderMaterialTypeCacheMutex);
+ m_material.m_materialType = shaderMaterialTypeCache[syncData->materialTypeCacheKey].get(m_material.m_vertexShader,
+ m_material.m_fragmentShader);
+ }
+
m_material.m_linker.reset(m_material.m_vertexShader, m_material.m_fragmentShader);
if (m_material.m_hasCustomVertexShader) {
@@ -675,7 +702,7 @@ void QSGRhiShaderEffectNode::syncMaterial(SyncData *syncData)
v.bindPoint = 1;
v.type = QSGGuiThreadShaderEffectManager::ShaderInfo::Sampler;
defaultSD.shaderInfo.variables.append(v);
- for (const QSGShaderEffectNode::VariableData &extVarData : qAsConst(syncData->fragment.shader->varData)) {
+ for (const QSGShaderEffectNode::VariableData &extVarData : std::as_const(syncData->fragment.shader->varData)) {
if (extVarData.specialType == QSGShaderEffectNode::VariableData::Source) {
vd.value = extVarData.value;
break;
@@ -745,9 +772,10 @@ void QSGRhiShaderEffectNode::preprocess()
}
}
-void QSGRhiShaderEffectNode::cleanupMaterialTypeCache()
+void QSGRhiShaderEffectNode::cleanupMaterialTypeCache(void *materialTypeCacheKey)
{
- shaderMaterialTypeCache.reset();
+ QMutexLocker lock(&shaderMaterialTypeCacheMutex);
+ shaderMaterialTypeCache[materialTypeCacheKey].reset();
}
bool QSGRhiGuiThreadShaderEffectManager::hasSeparateSamplerAndTextureObjects() const
@@ -818,7 +846,7 @@ bool QSGRhiGuiThreadShaderEffectManager::reflect(ShaderInfo *result)
int ubufBinding = -1;
const QVector<QShaderDescription::UniformBlock> ubufs = desc.uniformBlocks();
- const int ubufCount = ubufs.count();
+ const int ubufCount = ubufs.size();
for (int i = 0; i < ubufCount; ++i) {
const QShaderDescription::UniformBlock &ubuf(ubufs[i]);
if (ubufBinding == -1 && ubuf.binding >= 0) {
@@ -839,7 +867,7 @@ bool QSGRhiGuiThreadShaderEffectManager::reflect(ShaderInfo *result)
}
const QVector<QShaderDescription::InOutVariable> combinedImageSamplers = desc.combinedImageSamplers();
- const int samplerCount = combinedImageSamplers.count();
+ const int samplerCount = combinedImageSamplers.size();
for (int i = 0; i < samplerCount; ++i) {
const QShaderDescription::InOutVariable &combinedImageSampler(combinedImageSamplers[i]);
ShaderInfo::Variable v;
diff --git a/src/quick/scenegraph/qsgrhishadereffectnode_p.h b/src/quick/scenegraph/qsgrhishadereffectnode_p.h
index a901a6651e..b606871af6 100644
--- a/src/quick/scenegraph/qsgrhishadereffectnode_p.h
+++ b/src/quick/scenegraph/qsgrhishadereffectnode_p.h
@@ -99,7 +99,7 @@ public:
void syncMaterial(SyncData *syncData) override;
void preprocess() override;
- static void cleanupMaterialTypeCache();
+ static void cleanupMaterialTypeCache(void *materialTypeCacheKey);
private Q_SLOTS:
void handleTextureChange();
diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp
index ede98e865a..d37786901c 100644
--- a/src/quick/scenegraph/qsgrhisupport.cpp
+++ b/src/quick/scenegraph/qsgrhisupport.cpp
@@ -883,7 +883,7 @@ int QSGRhiSupport::chooseSampleCount(int samples, QRhi *rhi)
const QVector<int> supportedSampleCounts = rhi->supportedSampleCounts();
if (!supportedSampleCounts.contains(msaaSampleCount)) {
int reducedSampleCount = 1;
- for (int i = supportedSampleCounts.count() - 1; i >= 0; --i) {
+ for (int i = supportedSampleCounts.size() - 1; i >= 0; --i) {
if (supportedSampleCounts[i] <= msaaSampleCount) {
reducedSampleCount = supportedSampleCounts[i];
break;
diff --git a/src/quick/scenegraph/qsgrhitextureglyphcache.cpp b/src/quick/scenegraph/qsgrhitextureglyphcache.cpp
index a2d7de9a0a..9fe1b2ad01 100644
--- a/src/quick/scenegraph/qsgrhitextureglyphcache.cpp
+++ b/src/quick/scenegraph/qsgrhitextureglyphcache.cpp
@@ -23,15 +23,7 @@ QSGRhiTextureGlyphCache::QSGRhiTextureGlyphCache(QSGDefaultRenderContext *rc,
QSGRhiTextureGlyphCache::~QSGRhiTextureGlyphCache()
{
- // A plain delete should work, but just in case commitResourceUpdates was
- // not called and something is enqueued on the update batch for m_texture,
- // defer until the end of the frame.
- if (m_texture)
- m_texture->deleteLater();
-
- // should be empty, but just in case
- for (QRhiTexture *t : qAsConst(m_pendingDispose))
- t->deleteLater();
+ m_rc->deferredReleaseGlyphCacheTexture(m_texture);
}
QRhiTexture *QSGRhiTextureGlyphCache::createEmptyTexture(QRhiTexture::Format format)
@@ -97,7 +89,7 @@ void QSGRhiTextureGlyphCache::resizeTextureData(int width, int height)
resourceUpdates->uploadTexture(t, QRhiTextureUploadEntry(0, 0, subresDesc));
}
- m_pendingDispose.insert(m_texture);
+ m_rc->deferredReleaseGlyphCacheTexture(m_texture);
m_texture = t;
}
}
@@ -197,7 +189,10 @@ void QSGRhiTextureGlyphCache::endFillTexture()
int QSGRhiTextureGlyphCache::glyphPadding() const
{
- return 1;
+ if (m_format == QFontEngine::Format_Mono)
+ return 8;
+ else
+ return 1;
}
int QSGRhiTextureGlyphCache::maxTextureWidth() const
@@ -217,14 +212,8 @@ void QSGRhiTextureGlyphCache::commitResourceUpdates(QRhiResourceUpdateBatch *mer
{
if (QRhiResourceUpdateBatch *resourceUpdates = m_rc->maybeGlyphCacheResourceUpdates()) {
mergeInto->merge(resourceUpdates);
- m_rc->releaseGlyphCacheResourceUpdates();
+ m_rc->resetGlyphCacheResources();
}
-
- // now let's assume the resource updates will be committed in this frame
- for (QRhiTexture *t : qAsConst(m_pendingDispose))
- t->deleteLater(); // will be deleted after the frame is submitted -> safe
-
- m_pendingDispose.clear();
}
bool QSGRhiTextureGlyphCache::eightBitFormatIsAlphaSwizzled() const
diff --git a/src/quick/scenegraph/qsgrhitextureglyphcache_p.h b/src/quick/scenegraph/qsgrhitextureglyphcache_p.h
index 2960c91b01..3c6b99bc9f 100644
--- a/src/quick/scenegraph/qsgrhitextureglyphcache_p.h
+++ b/src/quick/scenegraph/qsgrhitextureglyphcache_p.h
@@ -60,7 +60,6 @@ private:
QSize m_size;
bool m_bgra = false;
QVarLengthArray<QRhiTextureUploadEntry, 16> m_uploads;
- QSet<QRhiTexture *> m_pendingDispose;
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index e20ded6c5a..c9b7ca2084 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -476,7 +476,7 @@ void QSGRenderThread::invalidateGraphics(QQuickWindow *window, bool inDestructor
if (wipeSG) {
dd->cleanupNodesOnShutdown();
#if QT_CONFIG(quick_shadereffect)
- QSGRhiShaderEffectNode::cleanupMaterialTypeCache();
+ QSGRhiShaderEffectNode::cleanupMaterialTypeCache(window);
#endif
} else {
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- persistent SG, avoiding cleanup");
@@ -505,6 +505,7 @@ void QSGRenderThread::invalidateGraphics(QQuickWindow *window, bool inDestructor
if (ownRhi)
QSGRhiSupport::instance()->destroyRhi(rhi);
rhi = nullptr;
+ dd->rhi = nullptr;
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- QRhi destroyed");
} else {
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- persistent GL, avoiding cleanup");
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index b2bf0c6d19..2301e0780b 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -965,7 +965,7 @@ void QQuickScriptActionPrivate::debugAction(QDebug d, int indentLevel) const
QString exprStr = expr.expression();
int endOfFirstLine = exprStr.indexOf(u'\n');
d << "\n" << ind.constData() << QStringView{exprStr}.left(endOfFirstLine);
- if (endOfFirstLine != -1 && endOfFirstLine < exprStr.length())
+ if (endOfFirstLine != -1 && endOfFirstLine < exprStr.size())
d << "...";
}
}
@@ -998,7 +998,7 @@ QAbstractAnimationJob* QQuickScriptAction::transition(QQuickStateActions &action
d->hasRunScriptScript = false;
d->reversing = (direction == Backward);
if (!d->name.isEmpty()) {
- for (int ii = 0; ii < actions.count(); ++ii) {
+ for (int ii = 0; ii < actions.size(); ++ii) {
QQuickStateAction &action = actions[ii];
if (action.event && action.event->type() == QQuickStateActionEvent::Script
@@ -1178,14 +1178,14 @@ QAbstractAnimationJob* QQuickPropertyAction::transition(QQuickStateActions &acti
QQuickStateActions actions;
void doAction() override
{
- for (int ii = 0; ii < actions.count(); ++ii) {
+ for (int ii = 0; ii < actions.size(); ++ii) {
const QQuickStateAction &action = actions.at(ii);
QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
}
}
void debugAction(QDebug d, int indentLevel) const override {
QByteArray ind(indentLevel, ' ');
- for (int ii = 0; ii < actions.count(); ++ii) {
+ for (int ii = 0; ii < actions.size(); ++ii) {
const QQuickStateAction &action = actions.at(ii);
d << "\n" << ind.constData() << "target:" << action.property.object() << "property:" << action.property.name()
<< "value:" << action.toValue;
@@ -1194,7 +1194,7 @@ QAbstractAnimationJob* QQuickPropertyAction::transition(QQuickStateActions &acti
};
QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
- for (int ii = 0; ii < props.count(); ++ii)
+ for (int ii = 0; ii < props.size(); ++ii)
props[ii] = props.at(ii).trimmed();
if (!d->propertyName.isEmpty())
props << d->propertyName;
@@ -1218,8 +1218,8 @@ QAbstractAnimationJob* QQuickPropertyAction::transition(QQuickStateActions &acti
bool hasExplicit = false;
//an explicit animation has been specified
if (d->value.isValid()) {
- for (int i = 0; i < props.count(); ++i) {
- for (int j = 0; j < targets.count(); ++j) {
+ for (int i = 0; i < props.size(); ++i) {
+ for (int j = 0; j < targets.size(); ++j) {
QQuickStateAction myAction;
myAction.property = d->createProperty(targets.at(j), props.at(i), this);
if (myAction.property.isValid()) {
@@ -1227,7 +1227,7 @@ QAbstractAnimationJob* QQuickPropertyAction::transition(QQuickStateActions &acti
QQuickPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyMetaType());
data->actions << myAction;
hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
+ for (int ii = 0; ii < actions.size(); ++ii) {
QQuickStateAction &action = actions[ii];
if (action.property.object() == myAction.property.object() &&
myAction.property.name() == action.property.name()) {
@@ -1241,7 +1241,7 @@ QAbstractAnimationJob* QQuickPropertyAction::transition(QQuickStateActions &acti
}
if (!hasExplicit)
- for (int ii = 0; ii < actions.count(); ++ii) {
+ for (int ii = 0; ii < actions.size(); ++ii) {
QQuickStateAction &action = actions[ii];
QObject *obj = action.property.object();
@@ -1266,7 +1266,7 @@ QAbstractAnimationJob* QQuickPropertyAction::transition(QQuickStateActions &acti
}
QActionAnimation *action = new QActionAnimation;
- if (data->actions.count()) {
+ if (data->actions.size()) {
action->setAnimAction(data);
} else {
delete data;
@@ -1688,7 +1688,7 @@ QQuickAbstractAnimation *QQuickAnimationGroupPrivate::at_animation(QQmlListPrope
qsizetype QQuickAnimationGroupPrivate::count_animation(QQmlListProperty<QQuickAbstractAnimation> *list)
{
if (auto q = qmlobject_cast<QQuickAnimationGroup *>(list->object))
- return q->d_func()->animations.count();
+ return q->d_func()->animations.size();
return 0;
}
@@ -1696,7 +1696,7 @@ void QQuickAnimationGroupPrivate::clear_animation(QQmlListProperty<QQuickAbstrac
{
QQuickAnimationGroup *q = qobject_cast<QQuickAnimationGroup *>(list->object);
if (q) {
- while (q->d_func()->animations.count()) {
+ while (q->d_func()->animations.size()) {
QQuickAbstractAnimation *firstAnim = q->d_func()->animations.at(0);
firstAnim->setGroup(nullptr);
}
@@ -1723,7 +1723,7 @@ void QQuickAnimationGroupPrivate::removeLast_animation(QQmlListProperty<QQuickAb
QQuickAnimationGroup::~QQuickAnimationGroup()
{
Q_D(QQuickAnimationGroup);
- for (int i = 0; i < d->animations.count(); ++i)
+ for (int i = 0; i < d->animations.size(); ++i)
d->animations.at(i)->d_func()->group = nullptr;
d->animations.clear();
}
@@ -1812,14 +1812,14 @@ QAbstractAnimationJob* QQuickSequentialAnimation::transition(QQuickStateActions
int from = 0;
if (direction == Backward) {
inc = -1;
- from = d->animations.count() - 1;
+ from = d->animations.size() - 1;
}
ThreadingModel execution = threadingModel();
bool valid = d->defaultProperty.isValid();
QAbstractAnimationJob* anim;
- for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
+ for (int ii = from; ii < d->animations.size() && ii >= 0; ii += inc) {
if (valid)
d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
anim = d->animations.at(ii)->transition(actions, modified, direction, defaultTarget);
@@ -1902,7 +1902,7 @@ QAbstractAnimationJob* QQuickParallelAnimation::transition(QQuickStateActions &a
bool valid = d->defaultProperty.isValid();
QAbstractAnimationJob* anim;
- for (int ii = 0; ii < d->animations.count(); ++ii) {
+ for (int ii = 0; ii < d->animations.size(); ++ii) {
if (valid)
d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
anim = d->animations.at(ii)->transition(actions, modified, direction, defaultTarget);
@@ -2084,7 +2084,7 @@ void QQuickBulkValueAnimator::debugAnimation(QDebug d) const
Note that PropertyAnimation inherits the abstract \l Animation type.
This includes additional properties and methods for controlling the animation.
- \section1 Modifying Properties Duration Animations
+ \section1 Modifying running animations
Since Qt 6.4, it is possible to set the \l from, \l to, \l duration, and
\l easing properties on a top-level animation while it is running. The
@@ -2594,7 +2594,7 @@ void QQuickAnimationPropertyUpdater::setValue(qreal v)
wasDeleted = &deleted;
if (reverse)
v = 1 - v;
- for (int ii = 0; ii < actions.count(); ++ii) {
+ for (int ii = 0; ii < actions.size(); ++ii) {
QQuickStateAction &action = actions[ii];
if (v == 1.) {
@@ -2626,7 +2626,7 @@ void QQuickAnimationPropertyUpdater::setValue(qreal v)
void QQuickAnimationPropertyUpdater::debugUpdater(QDebug d, int indentLevel) const
{
QByteArray ind(indentLevel, ' ');
- for (int i = 0; i < actions.count(); ++i) {
+ for (int i = 0; i < actions.size(); ++i) {
const QQuickStateAction &action = actions.at(i);
d << "\n" << ind.constData() << "target:" << action.property.object() << "property:" << action.property.name()
<< "from:" << action.fromValue << "to:" << action.toValue;
@@ -2641,7 +2641,7 @@ QQuickStateActions QQuickPropertyAnimation::createTransitionActions(QQuickStateA
QQuickStateActions newActions;
QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
- for (int ii = 0; ii < props.count(); ++ii)
+ for (int ii = 0; ii < props.size(); ++ii)
props[ii] = props.at(ii).trimmed();
if (!d->propertyName.isEmpty())
props << d->propertyName;
@@ -2673,8 +2673,8 @@ QQuickStateActions QQuickPropertyAnimation::createTransitionActions(QQuickStateA
QVector<QString> errorMessages;
bool successfullyCreatedDefaultProperty = false;
- for (int i = 0; i < props.count(); ++i) {
- for (int j = 0; j < targets.count(); ++j) {
+ for (int i = 0; i < props.size(); ++i) {
+ for (int j = 0; j < targets.size(); ++j) {
QQuickStateAction myAction;
QString errorMessage;
const QString &propertyName = props.at(i);
@@ -2691,7 +2691,7 @@ QQuickStateActions QQuickPropertyAnimation::createTransitionActions(QQuickStateA
d->convertVariant(myAction.toValue, d->interpolatorType ? QMetaType(d->interpolatorType) : myAction.property.propertyMetaType());
newActions << myAction;
hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
+ for (int ii = 0; ii < actions.size(); ++ii) {
QQuickStateAction &action = actions[ii];
if (action.property.object() == myAction.property.object() &&
myAction.property.name() == action.property.name()) {
@@ -2706,13 +2706,13 @@ QQuickStateActions QQuickPropertyAnimation::createTransitionActions(QQuickStateA
}
if (!successfullyCreatedDefaultProperty) {
- for (const QString &errorMessage : qAsConst(errorMessages))
+ for (const QString &errorMessage : std::as_const(errorMessages))
qmlWarning(this) << errorMessage;
}
}
if (!hasExplicit)
- for (int ii = 0; ii < actions.count(); ++ii) {
+ for (int ii = 0; ii < actions.size(); ++ii) {
QQuickStateAction &action = actions[ii];
QObject *obj = action.property.object();
diff --git a/src/quick/util/qquickanimatorcontroller.cpp b/src/quick/util/qquickanimatorcontroller.cpp
index ab3ea93a71..d7c25dadc1 100644
--- a/src/quick/util/qquickanimatorcontroller.cpp
+++ b/src/quick/util/qquickanimatorcontroller.cpp
@@ -36,7 +36,7 @@ static void qquickanimator_invalidate_jobs(QAbstractAnimationJob *job)
void QQuickAnimatorController::windowNodesDestroyed()
{
- for (const QSharedPointer<QAbstractAnimationJob> &toStop : qAsConst(m_rootsPendingStop)) {
+ for (const QSharedPointer<QAbstractAnimationJob> &toStop : std::as_const(m_rootsPendingStop)) {
qquickanimator_invalidate_jobs(toStop.data());
toStop->stop();
}
@@ -59,14 +59,14 @@ void QQuickAnimatorController::windowNodesDestroyed()
void QQuickAnimatorController::advance()
{
bool running = false;
- for (const QSharedPointer<QAbstractAnimationJob> &job : qAsConst(m_animationRoots)) {
+ for (const QSharedPointer<QAbstractAnimationJob> &job : std::as_const(m_animationRoots)) {
if (job->isRunning()) {
running = true;
break;
}
}
- for (QQuickAnimatorJob *job : qAsConst(m_runningAnimators))
+ for (QQuickAnimatorJob *job : std::as_const(m_runningAnimators))
job->commit();
if (running)
@@ -85,18 +85,18 @@ static void qquickanimator_sync_before_start(QAbstractAnimationJob *job)
void QQuickAnimatorController::beforeNodeSync()
{
- for (const QSharedPointer<QAbstractAnimationJob> &toStop : qAsConst(m_rootsPendingStop)) {
+ for (const QSharedPointer<QAbstractAnimationJob> &toStop : std::as_const(m_rootsPendingStop)) {
toStop->stop();
m_animationRoots.remove(toStop.data());
}
m_rootsPendingStop.clear();
- for (QQuickAnimatorJob *job : qAsConst(m_runningAnimators))
+ for (QQuickAnimatorJob *job : std::as_const(m_runningAnimators))
job->preSync();
// Start pending jobs
- for (const QSharedPointer<QAbstractAnimationJob> &job : qAsConst(m_rootsPendingStart)) {
+ for (const QSharedPointer<QAbstractAnimationJob> &job : std::as_const(m_rootsPendingStart)) {
Q_ASSERT(!job->isRunning());
// We want to make sure that presync is called before
@@ -118,7 +118,7 @@ void QQuickAnimatorController::beforeNodeSync()
void QQuickAnimatorController::afterNodeSync()
{
- for (QQuickAnimatorJob *job : qAsConst(m_runningAnimators))
+ for (QQuickAnimatorJob *job : std::as_const(m_runningAnimators))
job->postSync();
}
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp
index af49244b6d..599b5515cb 100644
--- a/src/quick/util/qquickanimatorjob.cpp
+++ b/src/quick/util/qquickanimatorjob.cpp
@@ -358,11 +358,12 @@ void QQuickTransformAnimatorJob::Helper::sync()
wasSynced = true;
}
+ // We update the node before checking on dirty, as the node might have changed without the animator running
+ node = d->itemNode();
+
if (dirty == 0)
return;
- node = d->itemNode();
-
if (dirty & QQuickItemPrivate::Position) {
dx = item->x();
dy = item->y();
diff --git a/src/quick/util/qquickapplication.cpp b/src/quick/util/qquickapplication.cpp
index ee3e15d15f..bee3b7313f 100644
--- a/src/quick/util/qquickapplication.cpp
+++ b/src/quick/util/qquickapplication.cpp
@@ -277,7 +277,7 @@ void QQuickApplication::setDisplayName(const QString &displayName)
qsizetype screens_count(QQmlListProperty<QQuickScreenInfo> *prop)
{
- return static_cast<QVector<QQuickScreenInfo *> *>(prop->data)->count();
+ return static_cast<QVector<QQuickScreenInfo *> *>(prop->data)->size();
}
QQuickScreenInfo *screens_at(QQmlListProperty<QQuickScreenInfo> *prop, qsizetype idx)
@@ -294,8 +294,8 @@ QQmlListProperty<QQuickScreenInfo> QQuickApplication::screens()
void QQuickApplication::updateScreens()
{
const QList<QScreen *> screenList = QGuiApplication::screens();
- m_screens.resize(screenList.count());
- for (int i = 0; i < screenList.count(); ++i) {
+ m_screens.resize(screenList.size());
+ for (int i = 0; i < screenList.size(); ++i) {
if (!m_screens[i])
m_screens[i] = new QQuickScreenInfo(this);
m_screens[i]->setWrappedScreen(screenList[i]);
diff --git a/src/quick/util/qquickdeliveryagent.cpp b/src/quick/util/qquickdeliveryagent.cpp
index 2bb0d52b09..78a95aa33c 100644
--- a/src/quick/util/qquickdeliveryagent.cpp
+++ b/src/quick/util/qquickdeliveryagent.cpp
@@ -48,6 +48,7 @@ void QQuickDeliveryAgentPrivate::touchToMouseEvent(QEvent::Type type, const QEve
(type == QEvent::MouseButtonRelease ? Qt::NoButton : Qt::LeftButton),
touchEvent->modifiers(), Qt::MouseEventSynthesizedByQt);
ret.setAccepted(true); // this now causes the persistent touchpoint to be accepted too
+ ret.setTimestamp(touchEvent->timestamp());
*mouseEvent = ret;
}
@@ -119,7 +120,7 @@ bool QQuickDeliveryAgentPrivate::deliverTouchAsMouse(QQuickItem *item, QTouchEve
// FIXME: make this work for mouse events too and get rid of the asTouchEvent in here.
QMutableTouchEvent event;
QQuickItemPrivate::get(item)->localizedTouchEvent(pointerEvent, false, &event);
- if (!event.points().count())
+ if (!event.points().size())
return false;
// For each point, check if it is accepted, if not, try the next point.
@@ -424,7 +425,7 @@ void QQuickDeliveryAgentPrivate::setFocusInScope(QQuickItem *scope, QQuickItem *
emit rootItem->window()->focusObjectChanged(activeFocusItem);
if (!changed.isEmpty())
- notifyFocusChangesRecur(changed.data(), changed.count() - 1, reason);
+ notifyFocusChangesRecur(changed.data(), changed.size() - 1, reason);
if (isSubsceneAgent) {
auto da = QQuickWindowPrivate::get(rootItem->window())->deliveryAgent;
qCDebug(lcFocus) << " delegating setFocusInScope to" << da;
@@ -524,8 +525,12 @@ void QQuickDeliveryAgentPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem
emit rootItem->window()->focusObjectChanged(activeFocusItem);
if (!changed.isEmpty())
- notifyFocusChangesRecur(changed.data(), changed.count() - 1, reason);
-
+ notifyFocusChangesRecur(changed.data(), changed.size() - 1, reason);
+ if (isSubsceneAgent) {
+ auto da = QQuickWindowPrivate::get(rootItem->window())->deliveryAgent;
+ qCDebug(lcFocus) << " delegating clearFocusInScope to" << da;
+ QQuickWindowPrivate::get(rootItem->window())->deliveryAgentPrivate()->clearFocusInScope(da->rootItem(), item, reason, options);
+ }
if (oldActiveFocusItem == activeFocusItem)
qCDebug(lcFocus) << "activeFocusItem remains" << activeFocusItem << "in" << q;
else
@@ -717,10 +722,13 @@ bool QQuickDeliveryAgent::event(QEvent *ev)
if (!d->rootItem)
return false;
QEnterEvent *enter = static_cast<QEnterEvent*>(ev);
- bool accepted = d->deliverHoverEvent(enter->scenePosition(),
+ const auto scenePos = enter->scenePosition();
+ bool accepted = d->deliverHoverEvent(scenePos,
enter->points().first().sceneLastPosition(),
enter->modifiers(), enter->timestamp());
- d->lastMousePosition = enter->scenePosition();
+ d->lastMousePosition = scenePos;
+ // deliverHoverEvent() constructs QHoverEvents: check that EPD didn't end up with corrupted scenePos
+ Q_ASSERT(enter->scenePosition() == scenePos);
enter->setAccepted(accepted);
#if QT_CONFIG(cursor)
QQuickWindowPrivate::get(d->rootItem->window())->updateCursor(enter->scenePosition(), d->rootItem);
@@ -751,8 +759,7 @@ bool QQuickDeliveryAgent::event(QEvent *ev)
break;
#endif
case QEvent::ShortcutOverride:
- if (d->activeFocusItem)
- QCoreApplication::sendEvent(d->activeFocusItem, ev);
+ d->deliverKeyEvent(static_cast<QKeyEvent *>(ev));
break;
case QEvent::InputMethod:
case QEvent::InputMethodQuery:
@@ -792,7 +799,13 @@ bool QQuickDeliveryAgent::event(QEvent *ev)
case QEvent::TabletPress:
case QEvent::TabletMove:
case QEvent::TabletRelease:
- d->deliverPointerEvent(static_cast<QPointerEvent *>(ev));
+ {
+ auto *tabletEvent = static_cast<QTabletEvent *>(ev);
+ d->deliverPointerEvent(tabletEvent); // visits HoverHandlers too (unlike the mouse event case)
+#if QT_CONFIG(cursor)
+ QQuickWindowPrivate::get(d->rootItem->window())->updateCursor(tabletEvent->scenePosition(), d->rootItem);
+#endif
+ }
break;
#endif
default:
@@ -806,10 +819,16 @@ void QQuickDeliveryAgentPrivate::deliverKeyEvent(QKeyEvent *e)
{
if (activeFocusItem) {
const bool keyPress = (e->type() == QEvent::KeyPress);
- if (keyPress)
+ switch (e->type()) {
+ case QEvent::KeyPress:
Q_QUICK_INPUT_PROFILE(QQuickProfiler::Key, QQuickProfiler::InputKeyPress, e->key(), e->modifiers());
- else
+ break;
+ case QEvent::KeyRelease:
Q_QUICK_INPUT_PROFILE(QQuickProfiler::Key, QQuickProfiler::InputKeyRelease, e->key(), e->modifiers());
+ break;
+ default:
+ break;
+ }
QQuickItem *item = activeFocusItem;
@@ -819,12 +838,10 @@ void QQuickDeliveryAgentPrivate::deliverKeyEvent(QKeyEvent *e)
e->key(), e->modifiers(), e->text(),
e->isAutoRepeat(), e->count());
- e->accept();
- QCoreApplication::sendEvent(item, e);
- while (!e->isAccepted() && (item = item->parentItem())) {
+ do {
e->accept();
QCoreApplication::sendEvent(item, e);
- }
+ } while (!e->isAccepted() && (item = item->parentItem()));
}
}
@@ -926,11 +943,11 @@ bool QQuickDeliveryAgentPrivate::sendHoverEvent(QEvent::Type type, QQuickItem *i
const auto transform = itemPrivate->windowToItemTransform();
const auto transformToGlobal = itemPrivate->windowToGlobalTransform();
auto globalPos = transformToGlobal.map(scenePos);
- QHoverEvent hoverEvent(type, transform.map(scenePos), globalPos, transform.map(lastScenePos), modifiers);
+ QHoverEvent hoverEvent(type, scenePos, globalPos, transform.map(lastScenePos), modifiers);
hoverEvent.setTimestamp(timestamp);
hoverEvent.setAccepted(true);
QEventPoint &point = hoverEvent.point(0);
- QMutableEventPoint::setScenePosition(point, scenePos);
+ QMutableEventPoint::setPosition(point, transform.map(scenePos));
QMutableEventPoint::setGlobalLastPosition(point, transformToGlobal.map(lastScenePos));
hasFiltered.clear();
@@ -952,9 +969,6 @@ bool QQuickDeliveryAgentPrivate::deliverHoverEvent(
const QPointF &scenePos, const QPointF &lastScenePos,
Qt::KeyboardModifiers modifiers, ulong timestamp)
{
- if (!QQuickItemPrivate::get(rootItem)->subtreeHoverEnabled)
- return false;
-
// The first time this function is called, hoverItems is empty.
// We then call deliverHoverEventRecursive from the rootItem, and
// populate the list with all the children and grandchildren that
@@ -970,11 +984,19 @@ bool QQuickDeliveryAgentPrivate::deliverHoverEvent(
// visit will still have an old hoverId. We can therefore go through the
// list at the end of this function and look for items with an old hoverId,
// remove them from the list, and update their state accordingly.
- currentHoverId++;
- hoveredLeafItemFound = false;
+ const bool subtreeHoverEnabled = QQuickItemPrivate::get(rootItem)->subtreeHoverEnabled;
const bool itemsWasHovered = !hoverItems.isEmpty();
- deliverHoverEventRecursive(rootItem, scenePos, lastScenePos, modifiers, timestamp);
+
+ if (!subtreeHoverEnabled && !itemsWasHovered)
+ return false;
+
+ currentHoverId++;
+
+ if (subtreeHoverEnabled) {
+ hoveredLeafItemFound = false;
+ deliverHoverEventRecursive(rootItem, scenePos, lastScenePos, modifiers, timestamp);
+ }
// Prune the list for items that are no longer hovered
for (auto it = hoverItems.begin(); it != hoverItems.end();) {
@@ -1005,10 +1027,11 @@ bool QQuickDeliveryAgentPrivate::deliverHoverEvent(
accepted, recursion stops. Returns \c true in that case, or \c false if the
event is rejected.
- All items that have hover enabled (either explicitly, from
- setAcceptHoverEvents(), or implicitly by having HoverHandlers) will have
- the QQuickItemPrivate::hoverEnabled flag set. And all their anchestors will
- have the QQuickItemPrivate::subtreeHoverEnabledset. This function will
+ Each item that has hover enabled (from setAcceptHoverEvents()) has the
+ QQuickItemPrivate::hoverEnabled flag set. This only controls whether we
+ should send hover events to the item itself. (HoverHandlers no longer set
+ this flag.) When an item has hoverEnabled set, all its ancestors have the
+ QQuickItemPrivate::subtreeHoverEnabled set. This function will
follow the subtrees that have subtreeHoverEnabled by recursing into each
child with that flag set. And for each child (in addition to the item
itself) that also has hoverEnabled set, we call deliverHoverEventToItem()
@@ -1020,10 +1043,19 @@ bool QQuickDeliveryAgentPrivate::deliverHoverEvent(
of an item that is stacked underneath, will not. Note that since siblings
can overlap, there can be more than one leaf item under the mouse.
+ Note that HoverHandler doesn't set the hoverEnabled flag on the parent item.
+ But still, adding a HoverHandler to an item will set its subtreeHoverEnabled flag.
+ So all the propagation logic described above will otherwise be the same.
+ But the hoverEnabled flag can be used to resolve if subtreeHoverEnabled is on
+ because the application explicitly requested it (setAcceptHoverEvents()), or
+ indirectly, because the item has HoverHandlers.
+
For legacy reasons (Qt 6.1), as soon as we find a leaf item that has hover
enabled, and therefore receives the event, we stop recursing into the remaining
siblings (even if the event was ignored). This means that we only allow hover
events to propagate up the direct parent-child hierarchy, and not to siblings.
+ However, if the first candidate HoverHandler is disabled, delivery continues
+ to the next one, which may be a sibling (QTBUG-106548).
*/
bool QQuickDeliveryAgentPrivate::deliverHoverEventRecursive(
QQuickItem *item, const QPointF &scenePos, const QPointF &lastScenePos,
@@ -1033,13 +1065,13 @@ bool QQuickDeliveryAgentPrivate::deliverHoverEventRecursive(
const QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
const QList<QQuickItem *> children = itemPrivate->paintOrderChildItems();
- for (int ii = children.count() - 1; ii >= 0; --ii) {
+ for (int ii = children.size() - 1; ii >= 0; --ii) {
QQuickItem *child = children.at(ii);
const QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child);
if (!child->isVisible() || childPrivate->culled)
continue;
- if (!child->isEnabled() && !childPrivate->subtreeHoverEnabled)
+ if (!childPrivate->subtreeHoverEnabled)
continue;
if (childPrivate->flags & QQuickItem::ItemClipsChildrenToShape) {
const QPointF localPos = child->mapFromScene(scenePos);
@@ -1061,8 +1093,7 @@ bool QQuickDeliveryAgentPrivate::deliverHoverEventRecursive(
// All decendants have been visited.
// Now deliver the event to the item
- if (itemPrivate->hoverEnabled)
- return deliverHoverEventToItem(item, scenePos, lastScenePos, modifiers, timestamp, false);
+ return deliverHoverEventToItem(item, scenePos, lastScenePos, modifiers, timestamp, false);
// Continue propagation / recursion
return false;
@@ -1089,14 +1120,17 @@ bool QQuickDeliveryAgentPrivate::deliverHoverEventToItem(
qCDebug(lcHoverTrace) << "item:" << item << "scene pos:" << scenePos << "localPos:" << localPos
<< "wasHovering:" << wasHovering << "isHovering:" << isHovering;
- if (isHovering)
- hoveredLeafItemFound = true;
-
- // Send enter/move/leave event to the item
bool accepted = false;
- if (isHovering && !clearHover) {
+
+ // Start by sending out enter/move/leave events to the item.
+ // Note that hoverEnabled only controls if we should send out hover events to the
+ // item itself. HoverHandlers are not included, and are dealt with separately below.
+ if (itemPrivate->hoverEnabled && isHovering && !clearHover) {
// Add the item to the list of hovered items (if it doesn't exist there
// from before), and update hoverId to mark that it's (still) hovered.
+ // Also set hoveredLeafItemFound, so that only propagate in a straight
+ // line towards the root from now on.
+ hoveredLeafItemFound = true;
hoverItems[item] = currentHoverId;
if (wasHovering)
accepted = sendHoverEvent(QEvent::HoverMove, item, scenePos, lastScenePos, modifiers, timestamp);
@@ -1111,6 +1145,7 @@ bool QQuickDeliveryAgentPrivate::deliverHoverEventToItem(
if (!itemPrivate->hasPointerHandlers())
return accepted;
+ // Next, send out hover events to the hover handlers.
// If the item didn't accept the hover event, 'accepted' is now false.
// Otherwise it's true, and then it should stay the way regardless of
// whether or not the hoverhandlers themselves are hovered.
@@ -1124,6 +1159,8 @@ bool QQuickDeliveryAgentPrivate::deliverHoverEventToItem(
for (QQuickPointerHandler *h : itemPrivate->extra->pointerHandlers) {
if (QQuickHoverHandler *hh = qmlobject_cast<QQuickHoverHandler *>(h)) {
+ if (!hh->isHovered())
+ continue;
hoverEvent.setAccepted(true);
QCoreApplication::sendEvent(hh, &hoverEvent);
}
@@ -1134,11 +1171,14 @@ bool QQuickDeliveryAgentPrivate::deliverHoverEventToItem(
for (QQuickPointerHandler *h : itemPrivate->extra->pointerHandlers) {
if (QQuickHoverHandler *hh = qmlobject_cast<QQuickHoverHandler *>(h)) {
+ if (!hh->enabled())
+ continue;
hoverEvent.setAccepted(true);
hh->handlePointerEvent(&hoverEvent);
if (hh->isHovered()) {
// Mark the whole item as updated, even if only the handler is
// actually in a hovered state (because of HoverHandler.margins)
+ hoveredLeafItemFound = true;
hoverItems[item] = currentHoverId;
if (hh->isBlocking()) {
qCDebug(lcHoverTrace) << "skipping rest of hover delivery due to blocking" << hh;
@@ -1157,7 +1197,7 @@ bool QQuickDeliveryAgentPrivate::deliverHoverEventToItem(
// in the usual reverse-paint-order until propagation is stopped
bool QQuickDeliveryAgentPrivate::deliverSinglePointEventUntilAccepted(QPointerEvent *event)
{
- Q_ASSERT(event->points().count() == 1);
+ Q_ASSERT(event->points().size() == 1);
QQuickPointerHandlerPrivate::deviceDeliveryTargets(event->pointingDevice()).clear();
QEventPoint &point = event->point(0);
QVector<QQuickItem *> targetItems = pointerTargets(rootItem, event, point, false, false);
@@ -1331,6 +1371,11 @@ bool QQuickDeliveryAgentPrivate::isMouseEvent(const QPointerEvent *ev)
}
}
+bool QQuickDeliveryAgentPrivate::isMouseOrWheelEvent(const QPointerEvent *ev)
+{
+ return isMouseEvent(ev) || ev->type() == QEvent::Wheel;
+}
+
bool QQuickDeliveryAgentPrivate::isHoverEvent(const QPointerEvent *ev)
{
switch (ev->type()) {
@@ -1377,6 +1422,11 @@ bool QQuickDeliveryAgentPrivate::isEventFromMouseOrTouchpad(const QPointerEvent
devType == QInputDevice::DeviceType::TouchPad;
}
+bool QQuickDeliveryAgentPrivate::isSynthMouse(const QPointerEvent *ev)
+{
+ return (!isEventFromMouseOrTouchpad(ev) && isMouseEvent(ev));
+}
+
QQuickPointingDeviceExtra *QQuickDeliveryAgentPrivate::deviceExtra(const QInputDevice *device)
{
QInputDevicePrivate *devPriv = QInputDevicePrivate::get(const_cast<QInputDevice *>(device));
@@ -1417,6 +1467,11 @@ QQuickPointingDeviceExtra *QQuickDeliveryAgentPrivate::deviceExtra(const QInputD
*/
bool QQuickDeliveryAgentPrivate::compressTouchEvent(QTouchEvent *event)
{
+ // If this is a subscene agent, don't store any events, because
+ // flushFrameSynchronousEvents() is only called on the window's DA.
+ if (isSubsceneAgent)
+ return false;
+
QEventPoint::States states = event->touchPointStates();
if (states.testFlag(QEventPoint::State::Pressed) || states.testFlag(QEventPoint::State::Released)) {
qCDebug(lcTouchCmprs) << "no compression" << event;
@@ -1554,17 +1609,18 @@ void QQuickDeliveryAgentPrivate::handleMouseEvent(QMouseEvent *event)
Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseMove,
event->position().x(), event->position().y());
-#if QT_CONFIG(cursor)
- QQuickWindowPrivate::get(rootItem->window())->updateCursor(event->scenePosition());
-#endif
const QPointF last = lastMousePosition.isNull() ? event->scenePosition() : lastMousePosition;
lastMousePosition = event->scenePosition();
qCDebug(lcHoverTrace) << q << "mouse pos" << last << "->" << lastMousePosition;
- if (!event->points().count() || !event->exclusiveGrabber(event->point(0))) {
+ if (!event->points().size() || !event->exclusiveGrabber(event->point(0))) {
bool accepted = deliverHoverEvent(event->scenePosition(), last, event->modifiers(), event->timestamp());
event->setAccepted(accepted);
}
deliverPointerEvent(event);
+#if QT_CONFIG(cursor)
+ // The pointer event could result in a cursor change (reaction), so update it afterwards.
+ QQuickWindowPrivate::get(rootItem->window())->updateCursor(event->scenePosition());
+#endif
break;
}
default:
@@ -1641,64 +1697,59 @@ void QQuickDeliveryAgentPrivate::onGrabChanged(QObject *grabber, QPointingDevice
handler->onGrabChanged(handler, transition, const_cast<QPointerEvent *>(event),
const_cast<QEventPoint &>(point));
}
- } else {
+ } else if (auto *grabberItem = qmlobject_cast<QQuickItem *>(grabber)) {
switch (transition) {
case QPointingDevice::CancelGrabExclusive:
case QPointingDevice::UngrabExclusive:
- if (auto *item = qmlobject_cast<QQuickItem *>(grabber)) {
- bool filtered = false;
- if (isDeliveringTouchAsMouse() ||
- point.device()->type() == QInputDevice::DeviceType::Mouse ||
- point.device()->type() == QInputDevice::DeviceType::TouchPad) {
- QMutableSinglePointEvent e(QEvent::UngrabMouse, point.device(), point);
- hasFiltered.clear();
- filtered = sendFilteredMouseEvent(&e, item, item->parentItem());
- if (!filtered) {
- lastUngrabbed = item;
- item->mouseUngrabEvent();
- }
+ if (isDeliveringTouchAsMouse()
+ || point.device()->type() == QInputDevice::DeviceType::Mouse
+ || point.device()->type() == QInputDevice::DeviceType::TouchPad) {
+ QMutableSinglePointEvent e(QEvent::UngrabMouse, point.device(), point);
+ hasFiltered.clear();
+ if (!sendFilteredMouseEvent(&e, grabberItem, grabberItem->parentItem())) {
+ lastUngrabbed = grabberItem;
+ grabberItem->mouseUngrabEvent();
}
- if (point.device()->type() == QInputDevice::DeviceType::TouchScreen) {
- bool allReleasedOrCancelled = true;
- if (transition == QPointingDevice::UngrabExclusive && event) {
- for (const auto &pt : event->points()) {
- if (pt.state() != QEventPoint::State::Released) {
- allReleasedOrCancelled = false;
- break;
- }
+ }
+ if (point.device()->type() == QInputDevice::DeviceType::TouchScreen) {
+ bool allReleasedOrCancelled = true;
+ if (transition == QPointingDevice::UngrabExclusive && event) {
+ for (const auto &pt : event->points()) {
+ if (pt.state() != QEventPoint::State::Released) {
+ allReleasedOrCancelled = false;
+ break;
}
}
- if (allReleasedOrCancelled)
- item->touchUngrabEvent();
}
+ if (allReleasedOrCancelled)
+ grabberItem->touchUngrabEvent();
}
break;
default:
break;
}
- auto grabberItem = static_cast<QQuickItem *>(grabber); // cannot be a handler: we checked above
- if (grabberItem) {
- auto itemPriv = QQuickItemPrivate::get(grabberItem);
- deliveryAgent = itemPriv->deliveryAgent();
- // An item that is NOT a subscene root needs to track whether it got a grab via a subscene delivery agent,
- // whereas the subscene root item already knows it has its own DA.
- if (isSubsceneAgent && grabGained && (!itemPriv->extra.isAllocated() || !itemPriv->extra->subsceneDeliveryAgent))
- itemPriv->maybeHasSubsceneDeliveryAgent = true;
- }
+ auto *itemPriv = QQuickItemPrivate::get(grabberItem);
+ deliveryAgent = itemPriv->deliveryAgent();
+ // An item that is NOT a subscene root needs to track whether it got a grab via a subscene delivery agent,
+ // whereas the subscene root item already knows it has its own DA.
+ if (isSubsceneAgent && grabGained && (!itemPriv->extra.isAllocated() || !itemPriv->extra->subsceneDeliveryAgent))
+ itemPriv->maybeHasSubsceneDeliveryAgent = true;
}
if (currentEventDeliveryAgent == q && event && event->device()) {
- auto epd = QPointingDevicePrivate::get(const_cast<QPointingDevice*>(event->pointingDevice()))->queryPointById(point.id());
- Q_ASSERT(epd);
switch (transition) {
case QPointingDevice::GrabPassive: {
+ auto epd = QPointingDevicePrivate::get(const_cast<QPointingDevice*>(event->pointingDevice()))->queryPointById(point.id());
+ Q_ASSERT(epd);
QPointingDevicePrivate::setPassiveGrabberContext(epd, grabber, q);
qCDebug(lcPtr) << "remembering that" << q << "handles point" << point.id() << "after" << transition;
} break;
- case QPointingDevice::GrabExclusive:
+ case QPointingDevice::GrabExclusive: {
+ auto epd = QPointingDevicePrivate::get(const_cast<QPointingDevice*>(event->pointingDevice()))->queryPointById(point.id());
+ Q_ASSERT(epd);
epd->exclusiveGrabberContext = q;
qCDebug(lcPtr) << "remembering that" << q << "handles point" << point.id() << "after" << transition;
- break;
+ } break;
case QPointingDevice::CancelGrabExclusive:
case QPointingDevice::UngrabExclusive:
// taken care of in QPointingDevicePrivate::setExclusiveGrabber(,,nullptr), removeExclusiveGrabber()
@@ -1831,7 +1882,7 @@ QVector<QQuickItem *> QQuickDeliveryAgentPrivate::pointerTargets(QQuickItem *ite
children.insert(it, item);
}
- for (int ii = children.count() - 1; ii >= 0; --ii) {
+ for (int ii = children.size() - 1; ii >= 0; --ii) {
QQuickItem *child = children.at(ii);
auto childPrivate = QQuickItemPrivate::get(child);
if (!child->isVisible() || !child->isEnabled() || childPrivate->culled ||
@@ -1855,8 +1906,8 @@ QVector<QQuickItem *> QQuickDeliveryAgentPrivate::mergePointerTargets(const QVec
// start at the end of list2
// if item not in list, append it
// if item found, move to next one, inserting before the last found one
- int insertPosition = targets.length();
- for (int i = list2.length() - 1; i >= 0; --i) {
+ int insertPosition = targets.size();
+ for (int i = list2.size() - 1; i >= 0; --i) {
int newInsertPosition = targets.lastIndexOf(list2.at(i), insertPosition);
if (newInsertPosition >= 0) {
Q_ASSERT(newInsertPosition <= insertPosition);
@@ -1912,7 +1963,7 @@ void QQuickDeliveryAgentPrivate::deliverUpdatedPoints(QPointerEvent *event)
continue;
}
QList<QPointer<QObject>> relevantPassiveGrabbers;
- for (int i = 0; i < epd->passiveGrabbersContext.count(); ++i) {
+ for (int i = 0; i < epd->passiveGrabbersContext.size(); ++i) {
if (epd->passiveGrabbersContext.at(i).data() == q)
relevantPassiveGrabbers << epd->passiveGrabbers.at(i);
}
@@ -1932,7 +1983,7 @@ void QQuickDeliveryAgentPrivate::deliverUpdatedPoints(QPointerEvent *event)
if (point.state() == QEventPoint::Pressed || qmlobject_cast<QQuickItem *>(event->exclusiveGrabber(point)))
continue;
QVector<QQuickItem *> targetItemsForPoint = pointerTargets(rootItem, event, point, false, false);
- if (targetItems.count()) {
+ if (targetItems.size()) {
targetItems = mergePointerTargets(targetItems, targetItemsForPoint);
} else {
targetItems = targetItemsForPoint;
@@ -1975,7 +2026,7 @@ bool QQuickDeliveryAgentPrivate::deliverPressOrReleaseEvent(QPointerEvent *event
for (int i = 0; i < event->pointCount(); ++i) {
auto &point = event->point(i);
QVector<QQuickItem *> targetItemsForPoint = pointerTargets(rootItem, event, point, !isTouch, isTouch);
- if (targetItems.count()) {
+ if (targetItems.size()) {
targetItems = mergePointerTargets(targetItems, targetItemsForPoint);
} else {
targetItems = targetItemsForPoint;
@@ -2069,7 +2120,7 @@ void QQuickDeliveryAgentPrivate::deliverMatchingPointsToItem(QQuickItem *item, b
item->mouseUngrabEvent();
lastUngrabbed = item;
}
- } else if (item->isEnabled() && item->isVisible() && point.state() != QEventPoint::State::Released) {
+ } else if (item->isEnabled() && item->isVisible() && point.state() == QEventPoint::State::Pressed) {
pointerEvent->setExclusiveGrabber(point, item);
}
point.setAccepted(true);
@@ -2099,18 +2150,16 @@ void QQuickDeliveryAgentPrivate::deliverMatchingPointsToItem(QQuickItem *item, b
qCDebug(lcTouch) << "actually delivering" << &touchEvent << " to " << item;
QCoreApplication::sendEvent(item, &touchEvent);
eventAccepted = touchEvent.isAccepted();
- } else if (Q_LIKELY(QCoreApplication::testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents))) {
+ } else {
// If the touch event wasn't accepted, synthesize a mouse event and see if the item wants it.
- if (!eventAccepted && (itemPrivate->acceptedMouseButtons() & Qt::LeftButton)) {
- // send mouse event
- if (deliverTouchAsMouse(item, &touchEvent))
- eventAccepted = true;
- }
+ if (Q_LIKELY(QCoreApplication::testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) &&
+ !eventAccepted && (itemPrivate->acceptedMouseButtons() & Qt::LeftButton))
+ deliverTouchAsMouse(item, &touchEvent);
+ return;
}
+ Q_ASSERT(item->acceptTouchEvents()); // else we would've returned early above
if (eventAccepted) {
- // If the touch was accepted (regardless by whom or in what form),
- // update accepted new points.
bool isPressOrRelease = pointerEvent->isBeginEvent() || pointerEvent->isEndEvent();
for (int i = 0; i < touchEvent.pointCount(); ++i) {
auto &point = touchEvent.point(i);
@@ -2163,6 +2212,7 @@ void QQuickDeliveryAgentPrivate::deliverDragEvent(QQuickDragGrabber *grabber, QE
QDragLeaveEvent leaveEvent;
for (; grabItem != grabber->end(); grabItem = grabber->release(grabItem))
QCoreApplication::sendEvent(**grabItem, &leaveEvent);
+ grabber->ignoreList().clear();
return;
} else {
QDragMoveEvent *moveEvent = static_cast<QDragMoveEvent *>(event);
@@ -2220,6 +2270,8 @@ void QQuickDeliveryAgentPrivate::deliverDragEvent(QQuickDragGrabber *grabber, QE
e->modifiers());
QQuickDropEventEx::copyActions(&enterEvent, *e);
event->setAccepted(deliverDragEvent(grabber, rootItem, &enterEvent));
+ } else {
+ grabber->ignoreList().clear();
}
}
@@ -2233,8 +2285,13 @@ bool QQuickDeliveryAgentPrivate::deliverDragEvent(
QPointF p = item->mapFromScene(event->position().toPoint());
bool itemContained = item->contains(p);
- if (!itemContained && itemPrivate->flags & QQuickItem::ItemClipsChildrenToShape) {
- return false;
+ const int itemIndex = grabber->ignoreList().indexOf(item);
+ if (!itemContained) {
+ if (itemIndex >= 0)
+ grabber->ignoreList().remove(itemIndex);
+
+ if (itemPrivate->flags & QQuickItem::ItemClipsChildrenToShape)
+ return false;
}
QDragEnterEvent enterEvent(
@@ -2247,7 +2304,7 @@ bool QQuickDeliveryAgentPrivate::deliverDragEvent(
QList<QQuickItem *> children = itemPrivate->paintOrderChildItems();
// Check children in front of this item first
- for (int ii = children.count() - 1; ii >= 0; --ii) {
+ for (int ii = children.size() - 1; ii >= 0; --ii) {
if (children.at(ii)->z() < 0)
continue;
if (deliverDragEvent(grabber, children.at(ii), &enterEvent, currentGrabItems, formerTarget))
@@ -2264,15 +2321,19 @@ bool QQuickDeliveryAgentPrivate::deliverDragEvent(
}
if (event->type() == QEvent::DragMove || itemPrivate->flags & QQuickItem::ItemAcceptsDrops) {
- if (event->type() == QEvent::DragEnter && formerTarget) {
- QQuickItem *formerTargetItem = qobject_cast<QQuickItem *>(formerTarget);
- if (formerTargetItem && currentGrabItems) {
- QDragLeaveEvent leaveEvent;
- QCoreApplication::sendEvent(formerTarget, &leaveEvent);
-
- // Remove the item from the currentGrabItems so a leave event won't be generated
- // later on
- currentGrabItems->removeAll(formerTarget);
+ if (event->type() == QEvent::DragEnter) {
+ if (formerTarget) {
+ QQuickItem *formerTargetItem = qobject_cast<QQuickItem *>(formerTarget);
+ if (formerTargetItem && currentGrabItems) {
+ QDragLeaveEvent leaveEvent;
+ QCoreApplication::sendEvent(formerTarget, &leaveEvent);
+
+ // Remove the item from the currentGrabItems so a leave event won't be generated
+ // later on
+ currentGrabItems->removeAll(formerTarget);
+ }
+ } else if (itemIndex >= 0) {
+ return false;
}
}
@@ -2288,6 +2349,8 @@ bool QQuickDeliveryAgentPrivate::deliverDragEvent(
grabber->grab(item);
grabber->setTarget(item);
return true;
+ } else if (itemIndex < 0) {
+ grabber->ignoreList().append(item);
}
} else {
return true;
@@ -2296,7 +2359,7 @@ bool QQuickDeliveryAgentPrivate::deliverDragEvent(
}
// Check children behind this item if this item or any higher children have not accepted
- for (int ii = children.count() - 1; ii >= 0; --ii) {
+ for (int ii = children.size() - 1; ii >= 0; --ii) {
if (children.at(ii)->z() >= 0)
continue;
if (deliverDragEvent(grabber, children.at(ii), &enterEvent, currentGrabItems, formerTarget))
@@ -2363,8 +2426,11 @@ bool QQuickDeliveryAgentPrivate::sendFilteredPointerEventImpl(QPointerEvent *eve
if (filteringParent->childMouseEventFilter(receiver, &filteringParentTouchEvent)) {
qCDebug(lcTouch) << "touch event intercepted by childMouseEventFilter of " << filteringParent;
skipDelivery.append(filteringParent);
- for (auto point : filteringParentTouchEvent.points())
- event->setExclusiveGrabber(point, filteringParent);
+ for (auto point : filteringParentTouchEvent.points()) {
+ const QQuickItem *exclusiveGrabber = qobject_cast<const QQuickItem *>(event->exclusiveGrabber(point));
+ if (!exclusiveGrabber || !exclusiveGrabber->keepTouchGrab())
+ event->setExclusiveGrabber(point, filteringParent);
+ }
return true;
} else if (Q_LIKELY(QCoreApplication::testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) &&
!filteringParent->acceptTouchEvents()) {
diff --git a/src/quick/util/qquickdeliveryagent_p_p.h b/src/quick/util/qquickdeliveryagent_p_p.h
index 66249f69c8..66db4bc88c 100644
--- a/src/quick/util/qquickdeliveryagent_p_p.h
+++ b/src/quick/util/qquickdeliveryagent_p_p.h
@@ -139,10 +139,12 @@ public:
static bool anyPointGrabbed(const QPointerEvent *ev);
static bool allPointsGrabbed(const QPointerEvent *ev);
static bool isMouseEvent(const QPointerEvent *ev);
+ static bool isMouseOrWheelEvent(const QPointerEvent *ev);
static bool isHoverEvent(const QPointerEvent *ev);
static bool isTouchEvent(const QPointerEvent *ev);
static bool isTabletEvent(const QPointerEvent *ev);
static bool isEventFromMouseOrTouchpad(const QPointerEvent *ev);
+ static bool isSynthMouse(const QPointerEvent *ev);
static QQuickPointingDeviceExtra *deviceExtra(const QInputDevice *device);
// delivery of pointer events:
diff --git a/src/quick/util/qquickframeanimation.cpp b/src/quick/util/qquickframeanimation.cpp
index 61e7e43875..bbdd0e79e0 100644
--- a/src/quick/util/qquickframeanimation.cpp
+++ b/src/quick/util/qquickframeanimation.cpp
@@ -263,10 +263,11 @@ int QQuickFrameAnimation::currentFrame() const
\code
Rectangle {
id: rect
- property real speed: 360
+ property real speed: 90
width: 100
height: 100
color: "red"
+ anchors.centerIn: parent
}
FrameAnimation {
@@ -274,7 +275,7 @@ int QQuickFrameAnimation::currentFrame() const
running: true
onTriggered: {
// Rotate the item speed-degrees / second.
- rect.rotation = rect.speed * frameTime
+ rect.rotation += rect.speed * frameTime
}
}
\endcode
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
index 1e9a419cfb..5b6ed25692 100644
--- a/src/quick/util/qquickglobal.cpp
+++ b/src/quick/util/qquickglobal.cpp
@@ -72,7 +72,7 @@ void QQmlQtQuick2DebugStatesDelegate::buildStatesList(bool cleanList,
m_allStates.clear();
//only root context has all instances
- for (int ii = 0; ii < instances.count(); ++ii) {
+ for (int ii = 0; ii < instances.size(); ++ii) {
buildStatesList(instances.at(ii));
}
}
@@ -84,7 +84,7 @@ void QQmlQtQuick2DebugStatesDelegate::buildStatesList(QObject *obj)
}
QObjectList children = obj->children();
- for (int ii = 0; ii < children.count(); ++ii) {
+ for (int ii = 0; ii < children.size(); ++ii) {
buildStatesList(children.at(ii));
}
}
@@ -99,7 +99,7 @@ void QQmlQtQuick2DebugStatesDelegate::updateBinding(QQmlContext *context,
typedef QPointer<QQuickState> QuickStatePointer;
QObject *object = property.object();
QString propertyName = property.name();
- for (const QuickStatePointer& statePointer : qAsConst(m_allStates)) {
+ for (const QuickStatePointer& statePointer : std::as_const(m_allStates)) {
if (QQuickState *state = statePointer.data()) {
// here we assume that the revert list on itself defines the base state
if (state->isStateActive() && state->containsPropertyInRevertList(object, propertyName)) {
diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp
index ee2414432d..e3b96ddad4 100644
--- a/src/quick/util/qquickimageprovider.cpp
+++ b/src/quick/util/qquickimageprovider.cpp
@@ -433,7 +433,7 @@ QQuickTextureFactory *QQuickImageProvider::requestTexture(const QString &id, QSi
\class QQuickAsyncImageProvider
\since 5.6
\inmodule QtQuick
- \brief The QQuickAsyncImageProvider class provides an interface for for asynchronous control of QML image requests.
+ \brief The QQuickAsyncImageProvider class provides an interface for asynchronous control of QML image requests.
See the \l {imageresponseprovider}{Image Response Provider Example} for a complete implementation.
diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp
index b8aaf4e7ae..a38de75753 100644
--- a/src/quick/util/qquickpath.cpp
+++ b/src/quick/util/qquickpath.cpp
@@ -271,7 +271,7 @@ qsizetype QQuickPath::pathElements_count(QQmlListProperty<QQuickPathElement> *pr
{
QQuickPathPrivate *d = privatePath(property->object);
- return d->_pathElements.count();
+ return d->_pathElements.size();
}
void QQuickPath::pathElements_clear(QQmlListProperty<QQuickPathElement> *property)
@@ -327,10 +327,10 @@ void QQuickPath::endpoint(const QString &name)
Q_D(QQuickPath);
const AttributePoint &first = d->_attributePoints.first();
qreal val = first.values.value(name);
- for (int ii = d->_attributePoints.count() - 1; ii >= 0; ii--) {
+ for (int ii = d->_attributePoints.size() - 1; ii >= 0; ii--) {
const AttributePoint &point = d->_attributePoints.at(ii);
if (point.values.contains(name)) {
- for (int jj = ii + 1; jj < d->_attributePoints.count(); ++jj) {
+ for (int jj = ii + 1; jj < d->_attributePoints.size(); ++jj) {
AttributePoint &setPoint = d->_attributePoints[jj];
setPoint.values.insert(name, val);
}
@@ -343,10 +343,10 @@ void QQuickPath::endpoint(QList<AttributePoint> &attributePoints, const QString
{
const AttributePoint &first = attributePoints.first();
qreal val = first.values.value(name);
- for (int ii = attributePoints.count() - 1; ii >= 0; ii--) {
+ for (int ii = attributePoints.size() - 1; ii >= 0; ii--) {
const AttributePoint &point = attributePoints.at(ii);
if (point.values.contains(name)) {
- for (int jj = ii + 1; jj < attributePoints.count(); ++jj) {
+ for (int jj = ii + 1; jj < attributePoints.size(); ++jj) {
AttributePoint &setPoint = attributePoints[jj];
setPoint.values.insert(name, val);
}
@@ -401,7 +401,7 @@ QPainterPath QQuickPath::createPath(const QPointF &startPoint, const QPointF &en
QPainterPath path;
AttributePoint first;
- for (int ii = 0; ii < attributes.count(); ++ii)
+ for (int ii = 0; ii < attributes.size(); ++ii)
first.values[attributes.at(ii)] = 0;
attributePoints << first;
@@ -413,7 +413,7 @@ QPainterPath QQuickPath::createPath(const QPointF &startPoint, const QPointF &en
bool usesPercent = false;
int index = 0;
- for (QQuickPathElement *pathElement : qAsConst(d->_pathElements)) {
+ for (QQuickPathElement *pathElement : std::as_const(d->_pathElements)) {
if (QQuickCurve *curve = qobject_cast<QQuickCurve *>(pathElement)) {
QQuickPathData data;
data.index = index;
@@ -427,11 +427,11 @@ QPainterPath QQuickPath::createPath(const QPointF &startPoint, const QPointF &en
} else if (QQuickPathAttribute *attribute = qobject_cast<QQuickPathAttribute *>(pathElement)) {
AttributePoint &point = attributePoints.last();
point.values[attribute->name()] = attribute->value();
- interpolate(attributePoints, attributePoints.count() - 1, attribute->name(), attribute->value());
+ interpolate(attributePoints, attributePoints.size() - 1, attribute->name(), attribute->value());
} else if (QQuickPathPercent *percent = qobject_cast<QQuickPathPercent *>(pathElement)) {
AttributePoint &point = attributePoints.last();
point.values[percentString] = percent->value();
- interpolate(attributePoints, attributePoints.count() - 1, percentString, percent->value());
+ interpolate(attributePoints, attributePoints.size() - 1, percentString, percent->value());
usesPercent = true;
} else if (QQuickPathText *text = qobject_cast<QQuickPathText *>(pathElement)) {
text->addToPath(path);
@@ -440,13 +440,13 @@ QPainterPath QQuickPath::createPath(const QPointF &startPoint, const QPointF &en
// Fixup end points
const AttributePoint &last = attributePoints.constLast();
- for (int ii = 0; ii < attributes.count(); ++ii) {
+ for (int ii = 0; ii < attributes.size(); ++ii) {
if (!last.values.contains(attributes.at(ii)))
endpoint(attributePoints, attributes.at(ii));
}
if (usesPercent && !last.values.contains(percentString)) {
d->_attributePoints.last().values[percentString] = 1;
- interpolate(d->_attributePoints.count() - 1, percentString, 1);
+ interpolate(d->_attributePoints.size() - 1, percentString, 1);
}
scalePath(path, d->scale);
@@ -454,7 +454,7 @@ QPainterPath QQuickPath::createPath(const QPointF &startPoint, const QPointF &en
qreal length = path.length();
qreal prevpercent = 0;
qreal prevorigpercent = 0;
- for (int ii = 0; ii < attributePoints.count(); ++ii) {
+ for (int ii = 0; ii < attributePoints.size(); ++ii) {
const AttributePoint &point = attributePoints.at(ii);
if (point.values.contains(percentString)) { //special string for QQuickPathPercent
if ( ii > 0) {
@@ -495,7 +495,7 @@ QPainterPath QQuickPath::createShapePath(const QPointF &startPoint, const QPoint
path.moveTo(startX, startY);
int index = 0;
- for (QQuickCurve *curve : qAsConst(d->_pathCurves)) {
+ for (QQuickCurve *curve : std::as_const(d->_pathCurves)) {
QQuickPathData data;
data.index = index;
data.endPoint = endPoint;
@@ -504,7 +504,7 @@ QPainterPath QQuickPath::createShapePath(const QPointF &startPoint, const QPoint
++index;
}
- for (QQuickPathText *text : qAsConst(d->_pathTexts))
+ for (QQuickPathText *text : std::as_const(d->_pathTexts))
text->addToPath(path);
if (closed) {
@@ -550,7 +550,7 @@ void QQuickPath::gatherAttributes()
QSet<QString> attributes;
// First gather up all the attributes
- for (QQuickPathElement *pathElement : qAsConst(d->_pathElements)) {
+ for (QQuickPathElement *pathElement : std::as_const(d->_pathElements)) {
if (QQuickCurve *curve = qobject_cast<QQuickCurve *>(pathElement))
d->_pathCurves.append(curve);
else if (QQuickPathText *text = qobject_cast<QQuickPathText *>(pathElement))
@@ -676,10 +676,10 @@ void QQuickPath::createPointCache() const
//find which set we are in
qreal prevPercent = 0;
qreal prevOrigPercent = 0;
- for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
+ for (int ii = 0; ii < d->_attributePoints.size(); ++ii) {
qreal percent = qreal(i)/segments;
const AttributePoint &point = d->_attributePoints.at(ii);
- if (percent < point.percent || ii == d->_attributePoints.count() - 1) { //### || is special case for very last item
+ if (percent < point.percent || ii == d->_attributePoints.size() - 1) { //### || is special case for very last item
qreal elementPercent = (percent - prevPercent);
qreal spc = prevOrigPercent + elementPercent * point.scale;
@@ -773,10 +773,10 @@ QPointF QQuickPath::forwardsPointAt(const QPainterPath &path, const qreal &pathL
//find which set we are in
qreal prevPercent = 0;
qreal prevOrigPercent = 0;
- for (int ii = 0; ii < attributePoints.count(); ++ii) {
+ for (int ii = 0; ii < attributePoints.size(); ++ii) {
qreal percent = p;
const AttributePoint &point = attributePoints.at(ii);
- if (percent < point.percent || ii == attributePoints.count() - 1) {
+ if (percent < point.percent || ii == attributePoints.size() - 1) {
qreal elementPercent = (percent - prevPercent);
qreal spc = prevOrigPercent + elementPercent * point.scale;
@@ -827,7 +827,7 @@ QPointF QQuickPath::backwardsPointAt(const QPainterPath &path, const qreal &path
qreal prevLength = currLength - bezLength;
qreal epc = prevLength / pathLength;
- for (int ii = attributePoints.count() - 1; ii > 0; --ii) {
+ for (int ii = attributePoints.size() - 1; ii > 0; --ii) {
qreal percent = p;
const AttributePoint &point = attributePoints.at(ii);
const AttributePoint &prevPoint = attributePoints.at(ii-1);
@@ -928,7 +928,7 @@ qreal QQuickPath::attributeAt(const QString &name, qreal percent) const
if (percent < 0 || percent > 1)
return 0;
- for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
+ for (int ii = 0; ii < d->_attributePoints.size(); ++ii) {
const AttributePoint &point = d->_attributePoints.at(ii);
if (point.percent == percent) {
@@ -1711,17 +1711,17 @@ void QQuickPathCatmullRomCurve::addToPath(QPainterPath &path, const QQuickPathDa
} else {
prev = path.currentPosition();
bool prevFarSet = false;
- if (index == -1 && data.curves.count() > 1) {
- if (qobject_cast<QQuickPathCatmullRomCurve*>(data.curves.at(data.curves.count()-1))) {
+ if (index == -1 && data.curves.size() > 1) {
+ if (qobject_cast<QQuickPathCatmullRomCurve*>(data.curves.at(data.curves.size()-1))) {
//TODO: profile and optimize
QPointF pos = prev;
QQuickPathData loopData;
loopData.endPoint = data.endPoint;
loopData.curves = data.curves;
- for (int i = data.index; i < data.curves.count(); ++i) {
+ for (int i = data.index; i < data.curves.size(); ++i) {
loopData.index = i;
pos = positionForCurve(loopData, pos);
- if (i == data.curves.count()-2)
+ if (i == data.curves.size()-2)
prevFar = pos;
}
if (pos == QPointF(path.elementAt(0))) {
@@ -1740,7 +1740,7 @@ void QQuickPathCatmullRomCurve::addToPath(QPainterPath &path, const QQuickPathDa
//get next point
index = data.index + 1;
- if (index < data.curves.count() && qobject_cast<QQuickPathCatmullRomCurve*>(data.curves.at(index))) {
+ if (index < data.curves.size() && qobject_cast<QQuickPathCatmullRomCurve*>(data.curves.at(index))) {
QQuickPathData nextData;
nextData.index = index;
nextData.endPoint = data.endPoint;
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 51be6f8e51..7644ab4447 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -466,7 +466,7 @@ static QString existingImageFileForPath(const QString &localFile)
return localFile;
QString tryFile = localFile + QStringLiteral(".xxxx");
- const int suffixIdx = localFile.length() + 1;
+ const int suffixIdx = localFile.size() + 1;
for (const QString &suffix : backendSupport()->fileSuffixes) {
tryFile.replace(suffixIdx, 10, suffix);
if (QFileInfo::exists(tryFile))
@@ -499,7 +499,7 @@ QQuickPixmapReader::~QQuickPixmapReader()
mutex.lock();
// manually cancel all outstanding jobs.
- for (QQuickPixmapReply *reply : qAsConst(jobs)) {
+ for (QQuickPixmapReply *reply : std::as_const(jobs)) {
if (reply->data && reply->data->reply == reply)
reply->data->reply = nullptr;
delete reply;
@@ -514,10 +514,10 @@ QQuickPixmapReader::~QQuickPixmapReader()
}
};
- for (auto *reply : qAsConst(networkJobs))
+ for (auto *reply : std::as_const(networkJobs))
cancelJob(reply);
- for (auto *reply : qAsConst(asyncResponses))
+ for (auto *reply : std::as_const(asyncResponses))
cancelJob(reply);
#endif
if (threadObject) threadObject->processJobs();
@@ -660,7 +660,7 @@ void QQuickPixmapReader::processJobs()
// Clean cancelled jobs
if (!cancelled.isEmpty()) {
- for (int i = 0; i < cancelled.count(); ++i) {
+ for (int i = 0; i < cancelled.size(); ++i) {
QQuickPixmapReply *job = cancelled.at(i);
#if QT_CONFIG(qml_network)
QNetworkReply *reply = networkJobs.key(job, 0);
@@ -688,7 +688,7 @@ void QQuickPixmapReader::processJobs()
if (!jobs.isEmpty()) {
// Find a job we can use
bool usableJob = false;
- for (int i = jobs.count() - 1; !usableJob && i >= 0; i--) {
+ for (int i = jobs.size() - 1; !usableJob && i >= 0; i--) {
QQuickPixmapReply *job = jobs.at(i);
const QUrl url = job->url;
QString localFile;
@@ -706,7 +706,7 @@ void QQuickPixmapReader::processJobs()
localFile = QQmlFile::urlToLocalFileOrQrc(url);
usableJob = !localFile.isEmpty()
#if QT_CONFIG(qml_network)
- || networkJobs.count() < IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT
+ || networkJobs.size() < IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT
#endif
;
}
@@ -1301,7 +1301,7 @@ void QQuickPixmapData::addToCache()
pixmapStore()->m_cache.insert(key, this);
inCache = true;
PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
- url, pixmapStore()->m_cache.count()));
+ url, pixmapStore()->m_cache.size()));
}
}
@@ -1315,7 +1315,7 @@ void QQuickPixmapData::removeFromCache(QQuickPixmapStore *store)
store->m_cache.remove(key);
inCache = false;
PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
- url, store->m_cache.count()));
+ url, store->m_cache.size()));
}
}
@@ -1747,8 +1747,7 @@ void QQuickPixmap::loadImageFromDevice(QQmlEngine *engine, QIODevice *device, co
QQuickPixmapReader::readerMutex.lock();
d->reply = QQuickPixmapReader::instance(engine)->getImage(d);
if (oldD) {
- QObject::connect(d->reply, &QQuickPixmapReply::finished, [oldD, this]() {
- oldD->declarativePixmaps.remove(this);
+ QObject::connect(d->reply, &QQuickPixmapReply::finished, [oldD]() {
oldD->release();
});
}
diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp
index efa6b1dfa0..fcb6e71e17 100644
--- a/src/quick/util/qquickpropertychanges.cpp
+++ b/src/quick/util/qquickpropertychanges.cpp
@@ -238,7 +238,7 @@ void QQuickPropertyChangesPrivate::decode()
if (decoded)
return;
- for (const QV4::CompiledData::Binding *binding : qAsConst(bindings))
+ for (const QV4::CompiledData::Binding *binding : std::as_const(bindings))
decodeBinding(QString(), compilationUnit, binding);
bindings.clear();
@@ -333,7 +333,7 @@ void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix,
void QQuickPropertyChangesParser::verifyBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props)
{
- for (int ii = 0; ii < props.count(); ++ii)
+ for (int ii = 0; ii < props.size(); ++ii)
verifyList(compilationUnit, props.at(ii));
}
@@ -358,7 +358,7 @@ QQuickPropertyChanges::QQuickPropertyChanges()
QQuickPropertyChanges::~QQuickPropertyChanges()
{
Q_D(QQuickPropertyChanges);
- for(int ii = 0; ii < d->signalReplacements.count(); ++ii)
+ for(int ii = 0; ii < d->signalReplacements.size(); ++ii)
delete d->signalReplacements.at(ii);
}
@@ -427,7 +427,7 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions()
ActionList list;
- for (int ii = 0; ii < d->properties.count(); ++ii) {
+ for (int ii = 0; ii < d->properties.size(); ++ii) {
QQmlProperty prop = d->property(d->properties.at(ii).first);
QQuickStateAction a(d->object, prop, d->properties.at(ii).first,
@@ -439,7 +439,7 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions()
}
}
- for (int ii = 0; ii < d->signalReplacements.count(); ++ii) {
+ for (int ii = 0; ii < d->signalReplacements.size(); ++ii) {
QQuickReplaceSignalHandler *handler = d->signalReplacements.at(ii);
if (handler->property.isValid()) {
@@ -449,7 +449,7 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions()
}
}
- for (int ii = 0; ii < d->expressions.count(); ++ii) {
+ for (int ii = 0; ii < d->expressions.size(); ++ii) {
QQuickPropertyChangesPrivate::ExpressionChange e = d->expressions.at(ii);
const QString &property = e.name;
diff --git a/src/quick/util/qquickshortcut.cpp b/src/quick/util/qquickshortcut.cpp
index 7b93936cfe..51de063090 100644
--- a/src/quick/util/qquickshortcut.cpp
+++ b/src/quick/util/qquickshortcut.cpp
@@ -209,7 +209,7 @@ void QQuickShortcut::setSequences(const QVariantList &values)
// if nothing has changed, just return:
if (m_shortcuts.size() == requestedShortcuts.size()) {
bool changed = false;
- for (int i = 0; i < requestedShortcuts.count(); ++i) {
+ for (int i = 0; i < requestedShortcuts.size(); ++i) {
const Shortcut &requestedShortcut = requestedShortcuts[i];
const Shortcut &shortcut = m_shortcuts[i];
if (!(requestedShortcut.userValue == shortcut.userValue
@@ -373,7 +373,7 @@ bool QQuickShortcut::event(QEvent *event)
QShortcutEvent *se = static_cast<QShortcutEvent *>(event);
bool match = m_shortcut.matches(se);
int i = 0;
- while (!match && i < m_shortcuts.count())
+ while (!match && i < m_shortcuts.size())
match |= m_shortcuts.at(i++).matches(se);
if (match) {
if (se->isAmbiguous())
diff --git a/src/quick/util/qquickshortcut_p.h b/src/quick/util/qquickshortcut_p.h
index f303043008..baa884b6f0 100644
--- a/src/quick/util/qquickshortcut_p.h
+++ b/src/quick/util/qquickshortcut_p.h
@@ -22,12 +22,13 @@
#include <QtQml/qqmlparserstatus.h>
#include <QtQml/qqml.h>
#include <QtCore/private/qglobal_p.h>
+#include <QtQuick/private/qtquickglobal_p.h>
QT_BEGIN_NAMESPACE
class QShortcutEvent;
-class QQuickShortcut : public QObject, public QQmlParserStatus
+class Q_QUICK_PRIVATE_EXPORT QQuickShortcut : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
diff --git a/src/quick/util/qquicksmoothedanimation.cpp b/src/quick/util/qquicksmoothedanimation.cpp
index 5e05da302d..4681d5919e 100644
--- a/src/quick/util/qquicksmoothedanimation.cpp
+++ b/src/quick/util/qquicksmoothedanimation.cpp
@@ -351,7 +351,7 @@ QQuickSmoothedAnimationPrivate::~QQuickSmoothedAnimationPrivate()
void QQuickSmoothedAnimationPrivate::updateRunningAnimations()
{
- for (QSmoothedAnimation *ease : qAsConst(activeAnimations)) {
+ for (QSmoothedAnimation *ease : std::as_const(activeAnimations)) {
ease->maximumEasingTime = anim->maximumEasingTime;
ease->reversingMode = anim->reversingMode;
ease->velocity = anim->velocity;
diff --git a/src/quick/util/qquickstate.cpp b/src/quick/util/qquickstate.cpp
index 09eaf60819..51bc9852f4 100644
--- a/src/quick/util/qquickstate.cpp
+++ b/src/quick/util/qquickstate.cpp
@@ -243,7 +243,7 @@ QQmlListProperty<QQuickStateOperation> QQuickState::changes()
int QQuickState::operationCount() const
{
Q_D(const QQuickState);
- return d->operations.count();
+ return d->operations.size();
}
QQuickStateOperation *QQuickState::operationAt(int index) const
@@ -263,8 +263,8 @@ void QQuickStatePrivate::complete()
{
Q_Q(QQuickState);
- for (int ii = 0; ii < reverting.count(); ++ii) {
- for (int jj = 0; jj < revertList.count(); ++jj) {
+ for (int ii = 0; ii < reverting.size(); ++ii) {
+ for (int jj = 0; jj < revertList.size(); ++jj) {
const QQuickRevertAction &revert = reverting.at(ii);
const QQuickSimpleAction &simple = revertList.at(jj);
if ((revert.event && simple.event() == revert.event) ||
@@ -295,7 +295,7 @@ QQuickStatePrivate::generateActionList() const
if (!extends.isEmpty()) {
QList<QQuickState *> states = group ? group->states() : QList<QQuickState *>();
- for (int ii = 0; ii < states.count(); ++ii)
+ for (int ii = 0; ii < states.size(); ++ii)
if (states.at(ii)->name() == extends) {
qmlExecuteDeferred(states.at(ii));
applyList = static_cast<QQuickStatePrivate*>(states.at(ii)->d_func())->generateActionList();
@@ -447,7 +447,7 @@ void QQuickState::addEntriesToRevertList(const QList<QQuickStateAction> &actionL
Q_D(QQuickState);
if (isStateActive()) {
QList<QQuickSimpleAction> simpleActionList;
- simpleActionList.reserve(actionList.count());
+ simpleActionList.reserve(actionList.size());
for (const QQuickStateAction &action : actionList) {
QQuickSimpleAction simpleAction(action);
@@ -520,14 +520,14 @@ void QQuickState::apply(QQuickTransition *trans, QQuickState *revert)
// List of actions that need to be reverted to roll back (just) this state
QQuickStatePrivate::SimpleActionList additionalReverts;
// First add the reverse of all the applyList actions
- for (int ii = 0; ii < applyList.count(); ++ii) {
+ for (int ii = 0; ii < applyList.size(); ++ii) {
QQuickStateAction &action = applyList[ii];
if (action.event) {
if (!action.event->isReversable())
continue;
bool found = false;
- for (int jj = 0; jj < d->revertList.count(); ++jj) {
+ for (int jj = 0; jj < d->revertList.size(); ++jj) {
QQuickStateActionEvent *event = d->revertList.at(jj).event();
if (event && event->type() == action.event->type()) {
if (action.event->mayOverride(event)) {
@@ -558,7 +558,7 @@ void QQuickState::apply(QQuickTransition *trans, QQuickState *revert)
bool found = false;
action.fromBinding = QQmlAnyBinding::ofProperty(action.property);
- for (int jj = 0; jj < d->revertList.count(); ++jj) {
+ for (int jj = 0; jj < d->revertList.size(); ++jj) {
if (d->revertList.at(jj).property() == action.property) {
found = true;
if (d->revertList.at(jj).binding() != action.fromBinding) {
@@ -583,13 +583,13 @@ void QQuickState::apply(QQuickTransition *trans, QQuickState *revert)
// Any reverts from a previous state that aren't carried forth
// into this state need to be translated into apply actions
- for (int ii = 0; ii < d->revertList.count(); ++ii) {
+ for (int ii = 0; ii < d->revertList.size(); ++ii) {
bool found = false;
if (d->revertList.at(ii).event()) {
QQuickStateActionEvent *event = d->revertList.at(ii).event();
if (!event->isReversable())
continue;
- for (int jj = 0; !found && jj < applyList.count(); ++jj) {
+ for (int jj = 0; !found && jj < applyList.size(); ++jj) {
const QQuickStateAction &action = applyList.at(jj);
if (action.event && action.event->type() == event->type()) {
if (action.event->mayOverride(event))
@@ -597,7 +597,7 @@ void QQuickState::apply(QQuickTransition *trans, QQuickState *revert)
}
}
} else {
- for (int jj = 0; !found && jj < applyList.count(); ++jj) {
+ for (int jj = 0; !found && jj < applyList.size(); ++jj) {
const QQuickStateAction &action = applyList.at(jj);
if (action.property == d->revertList.at(ii).property())
found = true;
@@ -636,7 +636,7 @@ void QQuickState::apply(QQuickTransition *trans, QQuickState *revert)
d->revertList << additionalReverts;
if (lcStates().isDebugEnabled()) {
- for (const QQuickStateAction &action : qAsConst(applyList)) {
+ for (const QQuickStateAction &action : std::as_const(applyList)) {
if (action.event)
qCDebug(lcStates) << "QQuickStateAction event:" << action.event->type();
else
diff --git a/src/quick/util/qquickstate_p_p.h b/src/quick/util/qquickstate_p_p.h
index 528682a5ba..cd7c1be5aa 100644
--- a/src/quick/util/qquickstate_p_p.h
+++ b/src/quick/util/qquickstate_p_p.h
@@ -206,7 +206,7 @@ public:
}
static qsizetype operations_count(QQmlListProperty<QQuickStateOperation> *prop) {
QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- return list->count();
+ return list->size();
}
static QQuickStateOperation *operations_at(QQmlListProperty<QQuickStateOperation> *prop, qsizetype index) {
QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp
index 2812b5824a..b4be946dc3 100644
--- a/src/quick/util/qquickstategroup.cpp
+++ b/src/quick/util/qquickstategroup.cpp
@@ -96,7 +96,7 @@ QQuickStateGroup::QQuickStateGroup(QObject *parent)
QQuickStateGroup::~QQuickStateGroup()
{
Q_D(const QQuickStateGroup);
- for (int i = 0; i < d->states.count(); ++i)
+ for (int i = 0; i < d->states.size(); ++i)
d->states.at(i)->setStateGroup(nullptr);
if (d->nullState)
d->nullState->setStateGroup(nullptr);
@@ -153,7 +153,7 @@ void QQuickStateGroupPrivate::append_state(QQmlListProperty<QQuickState> *list,
qsizetype QQuickStateGroupPrivate::count_state(QQmlListProperty<QQuickState> *list)
{
QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
- return _this->d_func()->states.count();
+ return _this->d_func()->states.size();
}
QQuickState *QQuickStateGroupPrivate::at_state(QQmlListProperty<QQuickState> *list, qsizetype index)
@@ -166,7 +166,7 @@ void QQuickStateGroupPrivate::clear_states(QQmlListProperty<QQuickState> *list)
{
QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
_this->d_func()->setCurrentStateInternal(QString(), true);
- for (qsizetype i = 0; i < _this->d_func()->states.count(); ++i) {
+ for (qsizetype i = 0; i < _this->d_func()->states.size(); ++i) {
_this->d_func()->states.at(i)->setStateGroup(nullptr);
}
_this->d_func()->states.clear();
@@ -190,7 +190,7 @@ void QQuickStateGroupPrivate::removeLast_states(QQmlListProperty<QQuickState> *l
{
auto *d = qobject_cast<QQuickStateGroup *>(list->object)->d_func();
if (d->currentState == d->states.last()->name())
- d->setCurrentStateInternal(d->states.length() > 1 ? d->states.first()->name() : QString(), true);
+ d->setCurrentStateInternal(d->states.size() > 1 ? d->states.first()->name() : QString(), true);
d->states.last()->setStateGroup(nullptr);
d->states.removeLast();
}
@@ -234,7 +234,7 @@ void QQuickStateGroupPrivate::append_transition(QQmlListProperty<QQuickTransitio
qsizetype QQuickStateGroupPrivate::count_transitions(QQmlListProperty<QQuickTransition> *list)
{
QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
- return _this->d_func()->transitions.count();
+ return _this->d_func()->transitions.size();
}
QQuickTransition *QQuickStateGroupPrivate::at_transition(QQmlListProperty<QQuickTransition> *list, qsizetype index)
@@ -257,14 +257,14 @@ void QQuickStateGroupPrivate::clear_transitions(QQmlListProperty<QQuickTransitio
This property is often used in scripts to change between states. For
example:
- \js
+ \qml
function toggle() {
if (button.state == 'On')
button.state = 'Off';
else
button.state = 'On';
}
- \endjs
+ \endqml
If the state group is in its base state (i.e. no explicit state has been
set), \c state will be a blank string. Likewise, you can return a
@@ -299,8 +299,8 @@ void QQuickStateGroup::componentComplete()
d->componentComplete = true;
QVarLengthArray<QString, 4> names;
- names.reserve(d->states.count());
- for (int ii = 0; ii < d->states.count(); ++ii) {
+ names.reserve(d->states.size());
+ for (int ii = 0; ii < d->states.size(); ++ii) {
QQuickState *state = d->states.at(ii);
if (!state->isNamed())
state->setName(QLatin1String("anonymousState") + QString::number(++d->unnamedCount));
@@ -338,7 +338,7 @@ bool QQuickStateGroupPrivate::updateAutoState()
return false;
bool revert = false;
- for (int ii = 0; ii < states.count(); ++ii) {
+ for (int ii = 0; ii < states.size(); ++ii) {
QQuickState *state = states.at(ii);
if (state->isWhenKnown()) {
if (state->isNamed()) {
@@ -353,11 +353,10 @@ bool QQuickStateGroupPrivate::updateAutoState()
if (abstractBinding && abstractBinding->kind() == QQmlAbstractBinding::QmlBinding) {
QQmlBinding *binding = static_cast<QQmlBinding *>(abstractBinding);
if (binding->hasValidContext()) {
- QVariant evalResult = binding->evaluate();
- if (evalResult.metaType() == QMetaType::fromType<QJSValue>())
- whenValue = evalResult.value<QJSValue>().toBool();
- else
- whenValue = evalResult.toBool();
+ const auto boolType = QMetaType::fromType<bool>();
+ const bool isUndefined = !binding->evaluate(&whenValue, boolType);
+ if (isUndefined)
+ whenValue = false;
}
}
@@ -391,7 +390,7 @@ QQuickTransition *QQuickStateGroupPrivate::findTransition(const QString &from, c
bool reversed = false;
bool done = false;
- for (int ii = 0; !done && ii < transitions.count(); ++ii) {
+ for (int ii = 0; !done && ii < transitions.size(); ++ii) {
QQuickTransition *t = transitions.at(ii);
if (!t->enabled())
continue;
@@ -405,10 +404,10 @@ QQuickTransition *QQuickStateGroupPrivate::findTransition(const QString &from, c
const QString toStateStr = t->toState();
auto fromState = QStringView{fromStateStr}.split(QLatin1Char(','));
- for (int jj = 0; jj < fromState.count(); ++jj)
+ for (int jj = 0; jj < fromState.size(); ++jj)
fromState[jj] = fromState.at(jj).trimmed();
auto toState = QStringView{toStateStr}.split(QLatin1Char(','));
- for (int jj = 0; jj < toState.count(); ++jj)
+ for (int jj = 0; jj < toState.size(); ++jj)
toState[jj] = toState.at(jj).trimmed();
if (ii == 1)
qSwap(fromState, toState);
@@ -476,7 +475,7 @@ void QQuickStateGroupPrivate::setCurrentStateInternal(const QString &state,
QQuickState *oldState = nullptr;
if (!currentState.isEmpty()) {
- for (int ii = 0; ii < states.count(); ++ii) {
+ for (int ii = 0; ii < states.size(); ++ii) {
if (states.at(ii)->name() == currentState) {
oldState = states.at(ii);
break;
@@ -488,7 +487,7 @@ void QQuickStateGroupPrivate::setCurrentStateInternal(const QString &state,
emit q->stateChanged(currentState);
QQuickState *newState = nullptr;
- for (int ii = 0; ii < states.count(); ++ii) {
+ for (int ii = 0; ii < states.size(); ++ii) {
if (states.at(ii)->name() == currentState) {
newState = states.at(ii);
break;
@@ -512,7 +511,7 @@ void QQuickStateGroupPrivate::setCurrentStateInternal(const QString &state,
QQuickState *QQuickStateGroup::findState(const QString &name) const
{
Q_D(const QQuickStateGroup);
- for (int i = 0; i < d->states.count(); ++i) {
+ for (int i = 0; i < d->states.size(); ++i) {
QQuickState *state = d->states.at(i);
if (state->name() == name)
return state;
diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp
index b542869913..1bee09a421 100644
--- a/src/quick/util/qquickstyledtext.cpp
+++ b/src/quick/util/qquickstyledtext.cpp
@@ -127,6 +127,13 @@ const QChar QQuickStyledTextPrivate::square(0x25a1);
const QChar QQuickStyledTextPrivate::lineFeed(QLatin1Char('\n'));
const QChar QQuickStyledTextPrivate::space(QLatin1Char(' '));
+namespace {
+bool is_equal_ignoring_case(QStringView s1, QLatin1StringView s2) noexcept
+{
+ return s1.compare(s2, Qt::CaseInsensitive) == 0;
+}
+}
+
QQuickStyledText::QQuickStyledText(const QString &string, QTextLayout &layout,
QList<QQuickStyledTextImgTag*> &imgTags,
const QUrl &baseUrl,
@@ -181,31 +188,31 @@ void QQuickStyledTextPrivate::parse()
hasSpace = true;
}
- if (rangeStart != drawText.length() && formatStack.count()) {
+ if (rangeStart != drawText.size() && formatStack.size()) {
if (formatChanged) {
QTextLayout::FormatRange formatRange;
formatRange.format = formatStack.top();
formatRange.start = rangeStart;
- formatRange.length = drawText.length() - rangeStart;
+ formatRange.length = drawText.size() - rangeStart;
ranges.append(formatRange);
formatChanged = false;
- } else if (ranges.count()) {
- ranges.last().length += drawText.length() - rangeStart;
+ } else if (ranges.size()) {
+ ranges.last().length += drawText.size() - rangeStart;
}
}
- rangeStart = drawText.length();
+ rangeStart = drawText.size();
++ch;
if (*ch == slash) {
++ch;
if (parseCloseTag(ch, text, drawText)) {
- if (formatStack.count()) {
+ if (formatStack.size()) {
formatChanged = true;
formatStack.pop();
}
}
} else {
QTextCharFormat format;
- if (formatStack.count())
+ if (formatStack.size())
format = formatStack.top();
if (parseTag(ch, text, drawText, format)) {
formatChanged = true;
@@ -245,15 +252,15 @@ void QQuickStyledTextPrivate::parse()
}
if (textLength)
appendText(text, textStart, textLength, drawText);
- if (rangeStart != drawText.length() && formatStack.count()) {
+ if (rangeStart != drawText.size() && formatStack.size()) {
if (formatChanged) {
QTextLayout::FormatRange formatRange;
formatRange.format = formatStack.top();
formatRange.start = rangeStart;
- formatRange.length = drawText.length() - rangeStart;
+ formatRange.length = drawText.size() - rangeStart;
ranges.append(formatRange);
- } else if (ranges.count()) {
- ranges.last().length += drawText.length() - rangeStart;
+ } else if (ranges.size()) {
+ ranges.last().length += drawText.size() - rangeStart;
}
}
@@ -296,12 +303,12 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn,
if (tagLength == 0)
return false;
auto tag = QStringView(textIn).mid(tagStart, tagLength);
- const QChar char0 = tag.at(0);
+ const QChar char0 = tag.at(0).toLower();
if (char0 == QLatin1Char('b')) {
if (tagLength == 1) {
format.setFontWeight(QFont::Bold);
return true;
- } else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) {
+ } else if (tagLength == 2 && tag.at(1).toLower() == QLatin1Char('r')) {
textOut.append(QChar(QChar::LineSeparator));
hasSpace = true;
prependSpace = false;
@@ -318,7 +325,7 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn,
textOut.append(QChar::LineSeparator);
hasSpace = true;
prependSpace = false;
- } else if (tag == QLatin1String("pre")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("pre"))) {
preFormat = true;
if (!hasNewLine)
textOut.append(QChar::LineSeparator);
@@ -330,7 +337,7 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn,
if (tagLength == 1) {
format.setFontUnderline(true);
return true;
- } else if (tag == QLatin1String("ul")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("ul"))) {
List listItem;
listItem.level = 0;
listItem.type = Unordered;
@@ -352,20 +359,20 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn,
if (tagLength == 1) {
format.setFontStrikeOut(true);
return true;
- } else if (tag == QLatin1String("strong")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("strong"))) {
format.setFontWeight(QFont::Bold);
return true;
}
- } else if (tag == QLatin1String("del")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("del"))) {
format.setFontStrikeOut(true);
return true;
- } else if (tag == QLatin1String("ol")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("ol"))) {
List listItem;
listItem.level = 0;
listItem.type = Ordered;
listItem.format = Decimal;
listStack.push(listItem);
- } else if (tag == QLatin1String("li")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("li"))) {
if (!hasNewLine)
textOut.append(QChar(QChar::LineSeparator));
if (!listStack.isEmpty()) {
@@ -405,20 +412,20 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn,
} else if (ch->isSpace()) {
// may have params.
auto tag = QStringView(textIn).mid(tagStart, tagLength);
- if (tag == QLatin1String("font"))
+ if (is_equal_ignoring_case(tag, QLatin1String("font")))
return parseFontAttributes(ch, textIn, format);
- if (tag == QLatin1String("ol")) {
+ if (is_equal_ignoring_case(tag, QLatin1String("ol"))) {
parseOrderedListAttributes(ch, textIn);
return false; // doesn't modify format
}
- if (tag == QLatin1String("ul")) {
+ if (is_equal_ignoring_case(tag, QLatin1String("ul"))) {
parseUnorderedListAttributes(ch, textIn);
return false; // doesn't modify format
}
- if (tag == QLatin1String("a")) {
+ if (is_equal_ignoring_case(tag, QLatin1String("a"))) {
return parseAnchorAttributes(ch, textIn, format);
}
- if (tag == QLatin1String("img")) {
+ if (is_equal_ignoring_case(tag, QLatin1String("img"))) {
parseImageAttributes(ch, textIn, textOut);
return false;
}
@@ -443,12 +450,12 @@ bool QQuickStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &tex
if (tagLength == 0)
return false;
auto tag = QStringView(textIn).mid(tagStart, tagLength);
- const QChar char0 = tag.at(0);
+ const QChar char0 = tag.at(0).toLower();
hasNewLine = false;
if (char0 == QLatin1Char('b')) {
if (tagLength == 1)
return true;
- else if (tag.at(1) == QLatin1Char('r') && tagLength == 2)
+ else if (tag.at(1).toLower() == QLatin1Char('r') && tagLength == 2)
return false;
} else if (char0 == QLatin1Char('i')) {
if (tagLength == 1)
@@ -462,7 +469,7 @@ bool QQuickStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &tex
hasNewLine = true;
hasSpace = true;
return false;
- } else if (tag == QLatin1String("pre")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("pre"))) {
preFormat = false;
if (!hasNewLine)
textOut.append(QChar::LineSeparator);
@@ -473,10 +480,10 @@ bool QQuickStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &tex
} else if (char0 == QLatin1Char('u')) {
if (tagLength == 1)
return true;
- else if (tag == QLatin1String("ul")) {
+ else if (is_equal_ignoring_case(tag, QLatin1String("ul"))) {
if (!listStack.isEmpty()) {
listStack.pop();
- if (!listStack.count())
+ if (!listStack.size())
textOut.append(QChar::LineSeparator);
}
return false;
@@ -486,24 +493,24 @@ bool QQuickStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &tex
hasNewLine = true;
hasSpace = true;
return true;
- } else if (tag == QLatin1String("font")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("font"))) {
return true;
} else if (char0 == QLatin1Char('s')) {
if (tagLength == 1) {
return true;
- } else if (tag == QLatin1String("strong")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("strong"))) {
return true;
}
- } else if (tag == QLatin1String("del")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("del"))) {
return true;
- } else if (tag == QLatin1String("ol")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("ol"))) {
if (!listStack.isEmpty()) {
listStack.pop();
- if (!listStack.count())
+ if (!listStack.size())
textOut.append(QChar::LineSeparator);
}
return false;
- } else if (tag == QLatin1String("li")) {
+ } else if (is_equal_ignoring_case(tag, QLatin1String("li"))) {
return false;
}
return false;
@@ -545,10 +552,10 @@ bool QQuickStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QStrin
QPair<QStringView,QStringView> attr;
do {
attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("color")) {
+ if (is_equal_ignoring_case(attr.first, QLatin1String("color"))) {
valid = true;
format.setForeground(QColor::fromString(attr.second));
- } else if (attr.first == QLatin1String("size")) {
+ } else if (is_equal_ignoring_case(attr.first, QLatin1String("size"))) {
valid = true;
int size = attr.second.toInt();
if (attr.second.at(0) == QLatin1Char('-') || attr.second.at(0) == QLatin1Char('+'))
@@ -573,7 +580,7 @@ bool QQuickStyledTextPrivate::parseOrderedListAttributes(const QChar *&ch, const
QPair<QStringView,QStringView> attr;
do {
attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("type")) {
+ if (is_equal_ignoring_case(attr.first, QLatin1String("type"))) {
valid = true;
if (attr.second == QLatin1String("a"))
listItem.format = LowerAlpha;
@@ -602,11 +609,11 @@ bool QQuickStyledTextPrivate::parseUnorderedListAttributes(const QChar *&ch, con
QPair<QStringView,QStringView> attr;
do {
attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("type")) {
+ if (is_equal_ignoring_case(attr.first, QLatin1String("type"))) {
valid = true;
- if (attr.second == QLatin1String("disc"))
+ if (is_equal_ignoring_case(attr.second, QLatin1String("disc")))
listItem.format = Disc;
- else if (attr.second == QLatin1String("square"))
+ else if (is_equal_ignoring_case(attr.second, QLatin1String("square")))
listItem.format = Square;
}
} while (!ch->isNull() && !attr.first.isEmpty());
@@ -622,7 +629,7 @@ bool QQuickStyledTextPrivate::parseAnchorAttributes(const QChar *&ch, const QStr
QPair<QStringView,QStringView> attr;
do {
attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("href")) {
+ if (is_equal_ignoring_case(attr.first, QLatin1String("href"))) {
format.setAnchorHref(attr.second.toString());
format.setAnchor(true);
format.setFontUnderline(true);
@@ -642,21 +649,21 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
if (!updateImagePositions) {
QQuickStyledTextImgTag *image = new QQuickStyledTextImgTag;
- image->position = textOut.length() + (trailingSpace ? 0 : 1);
+ image->position = textOut.size() + (trailingSpace ? 0 : 1);
QPair<QStringView,QStringView> attr;
do {
attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("src")) {
+ if (is_equal_ignoring_case(attr.first, QLatin1String("src"))) {
image->url = QUrl(attr.second.toString());
- } else if (attr.first == QLatin1String("width")) {
+ } else if (is_equal_ignoring_case(attr.first, QLatin1String("width"))) {
image->size.setWidth(attr.second.toString().toInt());
- } else if (attr.first == QLatin1String("height")) {
+ } else if (is_equal_ignoring_case(attr.first, QLatin1String("height"))) {
image->size.setHeight(attr.second.toString().toInt());
- } else if (attr.first == QLatin1String("align")) {
- if (attr.second.toString() == QLatin1String("top")) {
+ } else if (is_equal_ignoring_case(attr.first, QLatin1String("align"))) {
+ if (is_equal_ignoring_case(attr.second, QLatin1String("top"))) {
image->align = QQuickStyledTextImgTag::Top;
- } else if (attr.second.toString() == QLatin1String("middle")) {
+ } else if (is_equal_ignoring_case(attr.second, QLatin1String("middle"))) {
image->align = QQuickStyledTextImgTag::Middle;
}
}
@@ -686,7 +693,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
// if we already have a list of img tags for this text
// we only want to update the positions of these tags.
QQuickStyledTextImgTag *image = imgTags->value(nbImages);
- image->position = textOut.length() + (trailingSpace ? 0 : 1);
+ image->position = textOut.size() + (trailingSpace ? 0 : 1);
imgWidth = image->size.width();
image->offset = -std::fmod(imgWidth, spaceWidth) / 2.0;
QPair<QStringView,QStringView> attr;
diff --git a/src/quick/util/qquicksvgparser.cpp b/src/quick/util/qquicksvgparser.cpp
index a4f1ac8e80..5f88805ef7 100644
--- a/src/quick/util/qquicksvgparser.cpp
+++ b/src/quick/util/qquicksvgparser.cpp
@@ -249,7 +249,7 @@ bool QQuickSvgParser::parsePathDataFast(const QString &dataStr, QPainterPath &pa
if (pathElem == QLatin1Char('z') || pathElem == QLatin1Char('Z'))
arg.append(0);//dummy
const qreal *num = arg.constData();
- int count = arg.count();
+ int count = arg.size();
while (count > 0) {
qreal offsetX = x; // correction offsets
qreal offsetY = y; // for relative commands
diff --git a/src/quick/util/qquicktimeline.cpp b/src/quick/util/qquicktimeline.cpp
index ab59969ce5..e53dbe0fd9 100644
--- a/src/quick/util/qquicktimeline.cpp
+++ b/src/quick/util/qquicktimeline.cpp
@@ -786,7 +786,7 @@ int QQuickTimeLinePrivate::advance(int t)
std::sort(updates.begin(), updates.end());
updateQueue = &updates;
- for (int ii = 0; ii < updates.count(); ++ii) {
+ for (int ii = 0; ii < updates.size(); ++ii) {
const Update &v = updates.at(ii).second;
if (v.g) {
v.g->setValue(v.v);
@@ -836,7 +836,7 @@ void QQuickTimeLine::remove(QQuickTimeLineObject *v)
}
if (d->updateQueue) {
- for (int ii = 0; ii < d->updateQueue->count(); ++ii) {
+ for (int ii = 0; ii < d->updateQueue->size(); ++ii) {
if (d->updateQueue->at(ii).second.g == v ||
d->updateQueue->at(ii).second.e.callbackObject() == v) {
d->updateQueue->removeAt(ii);
diff --git a/src/quick/util/qquicktransition.cpp b/src/quick/util/qquicktransition.cpp
index 1d2c9e2f41..062e6e2656 100644
--- a/src/quick/util/qquicktransition.cpp
+++ b/src/quick/util/qquicktransition.cpp
@@ -115,7 +115,7 @@ void QQuickTransitionPrivate::append_animation(QQmlListProperty<QQuickAbstractAn
qsizetype QQuickTransitionPrivate::animation_count(QQmlListProperty<QQuickAbstractAnimation> *list)
{
QQuickTransition *q = static_cast<QQuickTransition *>(list->object);
- return q->d_func()->animations.count();
+ return q->d_func()->animations.size();
}
QQuickAbstractAnimation* QQuickTransitionPrivate::animation_at(QQmlListProperty<QQuickAbstractAnimation> *list, qsizetype pos)
@@ -127,7 +127,7 @@ QQuickAbstractAnimation* QQuickTransitionPrivate::animation_at(QQmlListProperty<
void QQuickTransitionPrivate::clear_animations(QQmlListProperty<QQuickAbstractAnimation> *list)
{
QQuickTransition *q = static_cast<QQuickTransition *>(list->object);
- while (q->d_func()->animations.count()) {
+ while (q->d_func()->animations.size()) {
QQuickAbstractAnimation *firstAnim = q->d_func()->animations.at(0);
q->d_func()->animations.removeAll(firstAnim);
}
@@ -232,8 +232,8 @@ QQuickTransitionInstance *QQuickTransition::prepare(QQuickStateOperation::Action
group->manager = manager;
QQuickAbstractAnimation::TransitionDirection direction = d->reversed ? QQuickAbstractAnimation::Backward : QQuickAbstractAnimation::Forward;
- int start = d->reversed ? d->animations.count() - 1 : 0;
- int end = d->reversed ? -1 : d->animations.count();
+ int start = d->reversed ? d->animations.size() - 1 : 0;
+ int end = d->reversed ? -1 : d->animations.size();
QAbstractAnimationJob *anim = nullptr;
for (int i = start; i != end;) {
diff --git a/src/quick/util/qquicktransitionmanager.cpp b/src/quick/util/qquicktransitionmanager.cpp
index 53aa6608aa..efaa01c305 100644
--- a/src/quick/util/qquicktransitionmanager.cpp
+++ b/src/quick/util/qquicktransitionmanager.cpp
@@ -59,7 +59,7 @@ void QQuickTransitionManager::complete()
// Explicitly take a copy in case the write action triggers a script that modifies the list.
QQuickTransitionManagerPrivate::SimpleActionList completeListCopy = d->completeList;
- for (const QQuickSimpleAction &action : qAsConst(completeListCopy))
+ for (const QQuickSimpleAction &action : std::as_const(completeListCopy))
action.property().write(action.value());
d->completeList.clear();
@@ -72,7 +72,7 @@ void QQuickTransitionManager::complete()
void QQuickTransitionManagerPrivate::applyBindings()
{
- for (const QQuickStateAction &action : qAsConst(bindingsList)) {
+ for (const QQuickStateAction &action : std::as_const(bindingsList)) {
if (auto binding = action.toBinding; binding) {
binding.installOn(action.property, QQmlAnyBinding::RespectInterceptors);
} else if (action.event) {
@@ -101,11 +101,13 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
QQuickStateOperation::ActionList applyList = list;
// Determine which actions are binding changes and disable any current bindings
- for (const QQuickStateAction &action : qAsConst(applyList)) {
+ for (const QQuickStateAction &action : std::as_const(applyList)) {
if (action.toBinding)
d->bindingsList << action;
- if (action.fromBinding)
- QQmlPropertyPrivate::removeBinding(action.property); // Disable current binding
+ if (action.fromBinding) {
+ auto property = action.property;
+ QQmlAnyBinding::removeBindingFrom(property); // Disable current binding
+ }
if (action.event && action.event->changesBindings()) { //### assume isReversable()?
d->bindingsList << action;
action.event->clearBindings();
@@ -123,7 +125,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
if (transition && !d->bindingsList.isEmpty()) {
// Apply all the property and binding changes
- for (const QQuickStateAction &action : qAsConst(applyList)) {
+ for (const QQuickStateAction &action : std::as_const(applyList)) {
if (auto binding = action.toBinding; binding) {
binding.installOn(action.property);
} else if (!action.event) {
@@ -148,7 +150,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
}
// Revert back to the original values
- for (const QQuickStateAction &action : qAsConst(applyList)) {
+ for (const QQuickStateAction &action : std::as_const(applyList)) {
if (action.event) {
if (action.event->isReversable()) {
action.event->clearBindings();
@@ -158,8 +160,10 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
continue;
}
- if (action.toBinding)
- QQmlPropertyPrivate::removeBinding(action.property); // Make sure this is disabled during the transition
+ if (action.toBinding) {
+ auto property = action.property;
+ QQmlAnyBinding::removeBindingFrom(property); // Make sure this is disabled during the transition
+ }
QQmlPropertyPrivate::write(action.property, action.fromValue, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
}
@@ -194,7 +198,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
// be applied immediately. We skip applying bindings, as they are all
// applied at the end in applyBindings() to avoid any nastiness mid
// transition
- for (const QQuickStateAction &action : qAsConst(applyList)) {
+ for (const QQuickStateAction &action : std::as_const(applyList)) {
if (action.event && !action.event->changesBindings()) {
if (action.event->isReversable() && action.reverseEvent)
action.event->reverse();
@@ -205,7 +209,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
}
}
if (lcStates().isDebugEnabled()) {
- for (const QQuickStateAction &action : qAsConst(applyList)) {
+ for (const QQuickStateAction &action : std::as_const(applyList)) {
if (action.event)
qCDebug(lcStates) << "no transition for event:" << action.event->type();
else
@@ -224,9 +228,10 @@ void QQuickTransitionManager::cancel()
if (d->transitionInstance && d->transitionInstance->isRunning())
RETURN_IF_DELETED(d->transitionInstance->stop());
- for (const QQuickStateAction &action : qAsConst(d->bindingsList)) {
+ for (const QQuickStateAction &action : std::as_const(d->bindingsList)) {
if (action.toBinding && action.deletableToBinding) {
- QQmlPropertyPrivate::removeBinding(action.property);
+ auto property = action.property;
+ QQmlAnyBinding::removeBindingFrom(property);
} else if (action.event) {
//### what do we do here?
}
diff --git a/src/quickcontrols2/basic/HorizontalHeaderView.qml b/src/quickcontrols2/basic/HorizontalHeaderView.qml
index 140c9f3ae8..bad08d947d 100644
--- a/src/quickcontrols2/basic/HorizontalHeaderView.qml
+++ b/src/quickcontrols2/basic/HorizontalHeaderView.qml
@@ -19,7 +19,7 @@ T.HorizontalHeaderView {
color: "#f6f6f6"
border.color: "#e4e4e4"
- Text {
+ Label {
id: text
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole]
: model[control.textRole])
diff --git a/src/quickcontrols2/basic/TreeViewDelegate.qml b/src/quickcontrols2/basic/TreeViewDelegate.qml
index 9f6eecd62b..fc9a072c43 100644
--- a/src/quickcontrols2/basic/TreeViewDelegate.qml
+++ b/src/quickcontrols2/basic/TreeViewDelegate.qml
@@ -1,4 +1,4 @@
-// Copyright (C) 2021 The Qt Company Lt.
+// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import QtQuick
@@ -34,8 +34,8 @@ T.TreeViewDelegate {
readonly property real __indicatorIndent: control.leftMargin + (control.depth * control.indentation)
x: !control.mirrored ? __indicatorIndent : control.width - __indicatorIndent - width
y: (control.height - height) / 2
- width: 16
- height: 16
+ implicitWidth: 20
+ implicitHeight: 40 // same as Button.qml
ColorImage {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
@@ -43,11 +43,11 @@ T.TreeViewDelegate {
source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/arrow-indicator.png"
color: control.palette.windowText
defaultColor: "#353637"
- scale: 0.5
}
}
background: Rectangle {
+ implicitHeight: 40 // same as Button.qml
color: control.highlighted
? control.palette.highlight
: (control.treeView.alternatingRows && control.row % 2 !== 0
diff --git a/src/quickcontrols2/basic/VerticalHeaderView.qml b/src/quickcontrols2/basic/VerticalHeaderView.qml
index a59e228d20..cb942c978f 100644
--- a/src/quickcontrols2/basic/VerticalHeaderView.qml
+++ b/src/quickcontrols2/basic/VerticalHeaderView.qml
@@ -19,7 +19,7 @@ T.VerticalHeaderView {
color: "#f6f6f6"
border.color: "#e4e4e4"
- Text {
+ Label {
id: text
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole]
: model[control.textRole])
diff --git a/src/quickcontrols2/designer/qtquickcontrols2.metainfo b/src/quickcontrols2/designer/qtquickcontrols2.metainfo
index 1075cec62e..0cd3959cf8 100644
--- a/src/quickcontrols2/designer/qtquickcontrols2.metainfo
+++ b/src/quickcontrols2/designer/qtquickcontrols2.metainfo
@@ -9,6 +9,7 @@ MetaInfo {
libraryIcon: "images/busyindicator-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("Indicates activity while, for example, content is being loaded.")
}
}
@@ -22,6 +23,7 @@ MetaInfo {
libraryIcon: "images/button-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A button with text.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Button\")" }
}
@@ -37,6 +39,7 @@ MetaInfo {
libraryIcon: "images/checkbox-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A checkbox with a text label.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Check Box\")" }
}
@@ -52,6 +55,7 @@ MetaInfo {
libraryIcon: "images/checkbox-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("Presents items from a model as checkboxes.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Check Delegate\")" }
}
@@ -67,6 +71,7 @@ MetaInfo {
libraryIcon: "images/combobox-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("An editable drop-down list.")
}
}
@@ -80,6 +85,7 @@ MetaInfo {
libraryIcon: "images/control-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("An abstract base type for UI controls.")
}
}
@@ -93,6 +99,7 @@ MetaInfo {
libraryIcon: "images/delaybutton-icon.png"
version: "2.2"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A button with a delay preventing accidental presses.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Delay Button\")" }
}
@@ -108,6 +115,8 @@ MetaInfo {
libraryIcon: "images/dial-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+
+ toolTip: qsTr("A circular dial that is rotated to set a value.")
}
}
@@ -121,6 +130,7 @@ MetaInfo {
libraryIcon: "images/frame-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("An untitled container for a group of controls.")
Property { name: "width"; type: "int"; value: 200 }
Property { name: "height"; type: "int"; value: 200 }
@@ -137,6 +147,7 @@ MetaInfo {
libraryIcon: "images/groupbox-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A titled container for a group of controls.")
Property { name: "width"; type: "int"; value: 200 }
Property { name: "height"; type: "int"; value: 200 }
@@ -154,6 +165,7 @@ MetaInfo {
libraryIcon: "images/itemdelegate-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("Presents a standard view item. It can be used as a delegate in various views and controls, such as ListView and ComboBox.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Item Delegate\")" }
}
@@ -169,6 +181,7 @@ MetaInfo {
libraryIcon: "images/label-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A text label.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Label\")" }
}
@@ -184,6 +197,7 @@ MetaInfo {
libraryIcon: "images/page-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A page with header and footer.")
Property { name: "width"; type: "int"; value: 200 }
Property { name: "height"; type: "int"; value: 200 }
@@ -200,6 +214,7 @@ MetaInfo {
libraryIcon: "images/pageindicator-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("Indicates the currently active page.")
Property { name: "count"; type: "int"; value: 3 }
}
@@ -215,6 +230,7 @@ MetaInfo {
libraryIcon: "images/pane-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("Provides a background matching the application style and theme.")
Property { name: "width"; type: "int"; value: 200 }
Property { name: "height"; type: "int"; value: 200 }
@@ -231,6 +247,7 @@ MetaInfo {
libraryIcon: "images/progressbar-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A bar indicating the progress of an operation.")
Property { name: "value"; type: "real"; value: 0.5 }
}
@@ -246,6 +263,7 @@ MetaInfo {
libraryIcon: "images/radiobutton-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("An option button that you can toggle on or off.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Radio Button\")" }
}
@@ -261,6 +279,7 @@ MetaInfo {
libraryIcon: "images/radiobutton-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("Presents items from a model as radio buttons.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Radio Delegate\")" }
}
@@ -276,6 +295,7 @@ MetaInfo {
libraryIcon: "images/rangeslider-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A bar with adjustable start and end points.")
Property { name: "first.value"; type: "real"; value: 0.25 }
Property { name: "second.value"; type: "real"; value: 0.75 }
@@ -292,6 +312,8 @@ MetaInfo {
libraryIcon: "images/roundbutton-icon.png"
version: "2.1"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A round button with text.")
+
Property { name: "text"; type: "string"; value: "+" }
}
}
@@ -306,6 +328,7 @@ MetaInfo {
libraryIcon: "images/slider-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("An adjustable slider.")
Property { name: "value"; type: "real"; value: 0.5 }
}
@@ -321,6 +344,7 @@ MetaInfo {
libraryIcon: "images/spinbox-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A box with an adjustable number.")
}
}
@@ -334,6 +358,7 @@ MetaInfo {
libraryIcon: "images/scrollview-icon.png"
version: "2.2"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A scrollable area.")
Property { name: "width"; type: "int"; value: 200 }
Property { name: "height"; type: "int"; value: 200 }
@@ -350,6 +375,7 @@ MetaInfo {
libraryIcon: "images/stackview-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("Provides a stack-based navigation for a set of pages.")
Property { name: "width"; type: "int"; value: 200 }
Property { name: "height"; type: "int"; value: 200 }
@@ -366,6 +392,7 @@ MetaInfo {
libraryIcon: "images/itemdelegate-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("Presents items from a model as items that you can swipe to expose more options.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Swipe Delegate\")" }
}
@@ -381,6 +408,7 @@ MetaInfo {
libraryIcon: "images/swipeview-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("Provides a view where you can navigate pages by swiping.")
Property { name: "width"; type: "int"; value: 200 }
Property { name: "height"; type: "int"; value: 200 }
@@ -397,6 +425,7 @@ MetaInfo {
libraryIcon: "images/switch-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A button that you can toggle on and off.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Switch\")" }
}
@@ -412,6 +441,7 @@ MetaInfo {
libraryIcon: "images/switch-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("Presents items from a model as toggle switches.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Switch Delegate\")" }
}
@@ -427,6 +457,8 @@ MetaInfo {
libraryIcon: "images/toolbar-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A tab-based navigation model.")
+
Property { name: "width"; type: "int"; value: 240 }
}
}
@@ -441,6 +473,8 @@ MetaInfo {
libraryIcon: "images/toolbutton-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A button suitable for a tab bar.")
+
Property { name: "text"; type: "binding"; value: "qsTr(\"Tab Button\")" }
}
}
@@ -455,6 +489,7 @@ MetaInfo {
libraryIcon: "images/textarea-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A multi-line text box.")
Property { name: "placeholderText"; type: "binding"; value: "qsTr(\"Text Area\")" }
}
@@ -470,6 +505,7 @@ MetaInfo {
libraryIcon: "images/textfield-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A single-line text box.")
Property { name: "placeholderText"; type: "binding"; value: "qsTr(\"Text Field\")" }
}
@@ -485,6 +521,7 @@ MetaInfo {
libraryIcon: "images/toolbar-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A row that can hold actions and buttons.")
Property { name: "width"; type: "int"; value: 360 }
}
@@ -500,6 +537,7 @@ MetaInfo {
libraryIcon: "images/toolbutton-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A button suitable for a tool bar.")
Property { name: "text"; type: "binding"; value: "qsTr(\"Tool Button\")" }
}
@@ -515,6 +553,7 @@ MetaInfo {
libraryIcon: "images/toolseparator-icon.png"
version: "2.1"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A line to separate sections in a tool bar.")
}
}
@@ -528,6 +567,7 @@ MetaInfo {
libraryIcon: "images/tumbler-icon.png"
version: "2.0"
requiredImport: "QtQuick.Controls"
+ toolTip: qsTr("A spinnable wheel of selectable items.")
Property { name: "model"; type: "int"; value: "10" }
}
diff --git a/src/quickcontrols2/doc/snippets/qtquickcontrols2-swipedelegate.qml b/src/quickcontrols2/doc/snippets/qtquickcontrols2-swipedelegate.qml
index fb2df4f6d3..9f6ec74537 100644
--- a/src/quickcontrols2/doc/snippets/qtquickcontrols2-swipedelegate.qml
+++ b/src/quickcontrols2/doc/snippets/qtquickcontrols2-swipedelegate.qml
@@ -21,6 +21,7 @@ ListView {
required property string sender
required property string title
+ required property int index
ListView.onRemove: SequentialAnimation {
PropertyAction {
@@ -52,8 +53,6 @@ ListView {
SwipeDelegate.onClicked: listView.model.remove(index)
- required property int index
-
background: Rectangle {
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
}
diff --git a/src/quickcontrols2/doc/src/includes/qquickimaginestyle.qdocinc b/src/quickcontrols2/doc/src/includes/qquickimaginestyle.qdocinc
index f6fe5a970a..411c6c1088 100644
--- a/src/quickcontrols2/doc/src/includes/qquickimaginestyle.qdocinc
+++ b/src/quickcontrols2/doc/src/includes/qquickimaginestyle.qdocinc
@@ -53,5 +53,8 @@
\note Due to a technical limitation, the path should not be named
\e "imagine" if it is relative to the \c qtquickcontrols2.conf file.
+ \li \c QT_QUICK_CONTROLS_IMAGINE_SMOOTH
+ \li Set to \c 1 to enable smooth scaling for 9-patch images.
+ This environment variable was added in Qt 6.5.
\endtable
//! [env]
diff --git a/src/quickcontrols2/doc/src/includes/qquicktooltip.qdocinc b/src/quickcontrols2/doc/src/includes/qquicktooltip.qdocinc
new file mode 100644
index 0000000000..0046a2d8b0
--- /dev/null
+++ b/src/quickcontrols2/doc/src/includes/qquicktooltip.qdocinc
@@ -0,0 +1,6 @@
+//! [customize-note]
+\note to customize the \l {Attached Tool Tips}{attached ToolTip}, it
+must be provided as part of
+\l {Creating a Custom Style}{your own style}. To do a one-off
+customization of a \c ToolTip, see \l {Custom Tool Tips}.
+//! [customize-note]
diff --git a/src/quickcontrols2/doc/src/qtquickcontrols2-customize.qdoc b/src/quickcontrols2/doc/src/qtquickcontrols2-customize.qdoc
index bd362270fc..e30d393771 100644
--- a/src/quickcontrols2/doc/src/qtquickcontrols2-customize.qdoc
+++ b/src/quickcontrols2/doc/src/qtquickcontrols2-customize.qdoc
@@ -85,6 +85,12 @@
An added benefit of these three methods is that it's not necessary to
implement the template from scratch.
+ \note the three approaches mentioned here do not work for customizing the
+ attached \l ToolTip, as that is a shared item created internally. To do
+ a one-off customization of a \c ToolTip, see \l {Custom Tool Tips}. To
+ customize the attached \c ToolTip, it must be provided as part of
+ \l {Creating a Custom Style}{your own style}.
+
\section1 Creating a Custom Style
There are several ways to go about creating your own styles. Below, we'll
@@ -518,7 +524,7 @@
\l {ApplicationWindow::background}{background}.
\code
- import
+ import QtQuick
import QtQuick.Controls
ApplicationWindow {
@@ -1003,6 +1009,7 @@
\printuntil }
\printuntil }
+ \include qquicktooltip.qdocinc customize-note
\section2 Customizing Tumbler
diff --git a/src/quickcontrols2/doc/src/qtquickcontrols2-delegates.qdoc b/src/quickcontrols2/doc/src/qtquickcontrols2-delegates.qdoc
index a5ccb95bc3..5d498ced1f 100644
--- a/src/quickcontrols2/doc/src/qtquickcontrols2-delegates.qdoc
+++ b/src/quickcontrols2/doc/src/qtquickcontrols2-delegates.qdoc
@@ -62,10 +62,10 @@
\image qtquickcontrols2-treeviewdelegate.png
- \l A TreeViewDelegate is a delegate that can be assigned to the delegate property
+ A \l TreeViewDelegate is a delegate that can be assigned to the delegate property
of a TreeView.
- \b {See also} \l {TreeView Control}.
+ \b {See also} \l {TreeView}.
\section1 Related Information
\list
diff --git a/src/quickcontrols2/doc/src/qtquickcontrols2-ios.qdoc b/src/quickcontrols2/doc/src/qtquickcontrols2-ios.qdoc
index e81fb468f8..1ef9a1dccf 100644
--- a/src/quickcontrols2/doc/src/qtquickcontrols2-ios.qdoc
+++ b/src/quickcontrols2/doc/src/qtquickcontrols2-ios.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \page qtquickcontrols2-iOS.html
+ \page qtquickcontrols2-ios.html
\title iOS Style
The iOS Style is a native-looking style for iOS based on image assets.
@@ -51,9 +51,6 @@
\section2 Customization
- The iOS style allows customizing the \l {ios-theme-attached-prop}{theme} attribute.
- By default it follows the system's theme.
-
\section3 Palette
The iOS style supports palette customization via the \l {Item::}{palette}
diff --git a/src/quickcontrols2/doc/src/qtquickcontrols2-macos.qdoc b/src/quickcontrols2/doc/src/qtquickcontrols2-macos.qdoc
index befa0d59c8..911baf6c20 100644
--- a/src/quickcontrols2/doc/src/qtquickcontrols2-macos.qdoc
+++ b/src/quickcontrols2/doc/src/qtquickcontrols2-macos.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \page qtquickcontrols2-macOS.html
+ \page qtquickcontrols2-macos.html
\title macOS Style
The macOS style is a style that looks native on macOS.
diff --git a/src/quickcontrols2/doc/src/qtquickcontrols2-windows.qdoc b/src/quickcontrols2/doc/src/qtquickcontrols2-windows.qdoc
index 3bacc3f4ec..e068f3c86d 100644
--- a/src/quickcontrols2/doc/src/qtquickcontrols2-windows.qdoc
+++ b/src/quickcontrols2/doc/src/qtquickcontrols2-windows.qdoc
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \page qtquickcontrols2-Windows.html
+ \page qtquickcontrols2-windows.html
\title Windows Style
The Windows style is a style that looks native on Windows.
diff --git a/src/quickcontrols2/fusion/CMakeLists.txt b/src/quickcontrols2/fusion/CMakeLists.txt
index 86a389822c..49bd660a65 100644
--- a/src/quickcontrols2/fusion/CMakeLists.txt
+++ b/src/quickcontrols2/fusion/CMakeLists.txt
@@ -51,6 +51,7 @@ set(qml_files
"ToolButton.qml"
"ToolSeparator.qml"
"ToolTip.qml"
+ "TreeViewDelegate.qml"
"Tumbler.qml"
"VerticalHeaderView.qml"
)
diff --git a/src/quickcontrols2/fusion/HorizontalHeaderView.qml b/src/quickcontrols2/fusion/HorizontalHeaderView.qml
index aafe0fb2fd..77a39cc5a5 100644
--- a/src/quickcontrols2/fusion/HorizontalHeaderView.qml
+++ b/src/quickcontrols2/fusion/HorizontalHeaderView.qml
@@ -3,6 +3,8 @@
import QtQuick
import QtQuick.Templates as T
+import QtQuick.Controls.Fusion
+import QtQuick.Controls.Fusion.impl
T.HorizontalHeaderView {
id: control
@@ -16,20 +18,19 @@ T.HorizontalHeaderView {
implicitWidth: text.implicitWidth + (cellPadding * 2)
implicitHeight: Math.max(control.height, text.implicitHeight + (cellPadding * 2))
- border.color: "#cacaca"
gradient: Gradient {
GradientStop {
position: 0
- color: "#fbfbfb"
+ color: Fusion.gradientStart(control.palette.button)
}
GradientStop {
position: 1
- color: "#e0dfe0"
+ color: Fusion.gradientStop(control.palette.button)
}
}
- Text {
+ Label {
id: text
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole]
: model[control.textRole])
@@ -38,7 +39,6 @@ T.HorizontalHeaderView {
height: parent.height
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
- color: "#ff26282a"
}
}
}
diff --git a/src/quickcontrols2/fusion/TreeViewDelegate.qml b/src/quickcontrols2/fusion/TreeViewDelegate.qml
new file mode 100644
index 0000000000..5223361872
--- /dev/null
+++ b/src/quickcontrols2/fusion/TreeViewDelegate.qml
@@ -0,0 +1,62 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Templates as T
+import QtQuick.Controls.impl
+import QtQuick.Controls.Fusion
+
+T.TreeViewDelegate {
+ id: control
+
+ implicitWidth: leftMargin + __contentIndent + implicitContentWidth + rightPadding + rightMargin
+ implicitHeight: Math.max(implicitBackgroundHeight, implicitContentHeight, implicitIndicatorHeight)
+
+ indentation: indicator ? indicator.width : 12
+ leftMargin: 5
+ rightMargin: 5
+ spacing: 5
+
+ topPadding: contentItem ? (height - contentItem.implicitHeight) / 2 : 0
+ leftPadding: !mirrored ? leftMargin + __contentIndent : width - leftMargin - __contentIndent - implicitContentWidth
+
+ highlighted: control.selected || control.current
+ || ((control.treeView.selectionBehavior === TableView.SelectRows
+ || control.treeView.selectionBehavior === TableView.SelectionDisabled)
+ && control.row === control.treeView.currentRow)
+
+ required property int row
+ required property var model
+ readonly property real __contentIndent: !isTreeNode ? 0 : (depth * indentation) + (indicator ? indicator.width + spacing : 0)
+
+ indicator: Item {
+ readonly property real __indicatorIndent: control.leftMargin + (control.depth * control.indentation)
+ x: !control.mirrored ? __indicatorIndent : control.width - __indicatorIndent - width
+ y: (control.height - height) / 2
+ implicitWidth: Math.max(arrow.implicitWidth, 20)
+ implicitHeight: 24 // same as Button.qml
+
+ property ColorImage arrow : ColorImage {
+ parent: control.indicator
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ rotation: control.expanded ? 0 : (control.mirrored ? 90 : -90)
+ source: "qrc:/qt-project.org/imports/QtQuick/Controls/Fusion/images/arrow.png"
+ color: control.palette.windowText
+ defaultColor: "#353637"
+ }
+ }
+
+ background: Rectangle {
+ implicitHeight: 24 // same as Button.qml
+ color: control.highlighted
+ ? control.palette.highlight
+ : (control.treeView.alternatingRows && control.row % 2 !== 0
+ ? control.palette.alternateBase : control.palette.base)
+ }
+
+ contentItem: Label {
+ text: control.model.display
+ elide: Text.ElideRight
+ }
+}
diff --git a/src/quickcontrols2/fusion/VerticalHeaderView.qml b/src/quickcontrols2/fusion/VerticalHeaderView.qml
index 7ae2fcdd62..a6072c0930 100644
--- a/src/quickcontrols2/fusion/VerticalHeaderView.qml
+++ b/src/quickcontrols2/fusion/VerticalHeaderView.qml
@@ -3,6 +3,8 @@
import QtQuick
import QtQuick.Templates as T
+import QtQuick.Controls.Fusion
+import QtQuick.Controls.Fusion.impl
T.VerticalHeaderView {
id: control
@@ -16,20 +18,19 @@ T.VerticalHeaderView {
implicitWidth: Math.max(control.width, text.implicitWidth + (cellPadding * 2))
implicitHeight: text.implicitHeight + (cellPadding * 2)
- border.color: "#cacaca"
gradient: Gradient {
GradientStop {
position: 0
- color: "#fbfbfb"
+ color: Fusion.gradientStart(control.palette.button)
}
GradientStop {
position: 1
- color: "#e0dfe0"
+ color: Fusion.gradientStop(control.palette.button)
}
}
- Text {
+ Label {
id: text
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole]
: model[control.textRole])
@@ -38,7 +39,6 @@ T.VerticalHeaderView {
height: parent.height
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
- color: "#ff26282a"
}
}
}
diff --git a/src/quickcontrols2/fusion/qquickfusiontheme.cpp b/src/quickcontrols2/fusion/qquickfusiontheme.cpp
index bef0628125..335d3be73f 100644
--- a/src/quickcontrols2/fusion/qquickfusiontheme.cpp
+++ b/src/quickcontrols2/fusion/qquickfusiontheme.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2017 The Qt Company Ltd.
+// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qquickfusiontheme_p.h"
@@ -8,17 +8,11 @@
QT_BEGIN_NAMESPACE
+extern QPalette qt_fusionPalette();
+
void QQuickFusionTheme::initialize(QQuickTheme *theme)
{
- const bool isDarkSystemTheme = QQuickStylePrivate::isDarkSystemTheme();
- QPalette systemPalette;
- systemPalette.setColor(QPalette::Active, QPalette::ButtonText,
- isDarkSystemTheme ? QColor::fromRgb(0xe7e7e7) : QColor::fromRgb(0x252525));
- systemPalette.setColor(QPalette::Inactive, QPalette::ButtonText,
- isDarkSystemTheme ? QColor::fromRgb(0xe7e7e7) : QColor::fromRgb(0x252525));
- systemPalette.setColor(QPalette::Disabled, QPalette::ButtonText,
- isDarkSystemTheme ? QColor::fromRgb(0x777777) : QColor::fromRgb(0xb6b6b6));
- theme->setPalette(QQuickTheme::System, systemPalette);
+ theme->setPalette(QQuickTheme::System, qt_fusionPalette());
}
QT_END_NAMESPACE
diff --git a/src/quickcontrols2/fusion/qquickfusiontheme_p.h b/src/quickcontrols2/fusion/qquickfusiontheme_p.h
index 7ab953c5f5..a41c9d7315 100644
--- a/src/quickcontrols2/fusion/qquickfusiontheme_p.h
+++ b/src/quickcontrols2/fusion/qquickfusiontheme_p.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2021 The Qt Company Ltd.
+// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QQUICKFUSIONTHEME_P_H
diff --git a/src/quickcontrols2/imagine/ComboBox.qml b/src/quickcontrols2/imagine/ComboBox.qml
index 960d58334a..254313454c 100644
--- a/src/quickcontrols2/imagine/ComboBox.qml
+++ b/src/quickcontrols2/imagine/ComboBox.qml
@@ -11,10 +11,10 @@ T.ComboBox {
id: control
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
- contentItem.implicitWidth + background ? (background.leftPadding + background.rightPadding) : 0)
+ implicitContentWidth + (background ? background.leftPadding + background.rightPadding : 0))
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
Math.max(implicitContentHeight,
- implicitIndicatorHeight) + background ? (background.topPadding + background.bottomPadding) : 0)
+ implicitIndicatorHeight) + (background ? background.topPadding + background.bottomPadding : 0))
leftPadding: padding + (!control.mirrored || !indicator || !indicator.visible ? 0 : indicator.width + spacing)
rightPadding: padding + (control.mirrored || !indicator || !indicator.visible ? 0 : indicator.width + spacing)
diff --git a/src/quickcontrols2/imagine/HorizontalHeaderView.qml b/src/quickcontrols2/imagine/HorizontalHeaderView.qml
index 140c9f3ae8..bad08d947d 100644
--- a/src/quickcontrols2/imagine/HorizontalHeaderView.qml
+++ b/src/quickcontrols2/imagine/HorizontalHeaderView.qml
@@ -19,7 +19,7 @@ T.HorizontalHeaderView {
color: "#f6f6f6"
border.color: "#e4e4e4"
- Text {
+ Label {
id: text
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole]
: model[control.textRole])
diff --git a/src/quickcontrols2/imagine/VerticalHeaderView.qml b/src/quickcontrols2/imagine/VerticalHeaderView.qml
index a59e228d20..cb942c978f 100644
--- a/src/quickcontrols2/imagine/VerticalHeaderView.qml
+++ b/src/quickcontrols2/imagine/VerticalHeaderView.qml
@@ -19,7 +19,7 @@ T.VerticalHeaderView {
color: "#f6f6f6"
border.color: "#e4e4e4"
- Text {
+ Label {
id: text
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole]
: model[control.textRole])
diff --git a/src/quickcontrols2/imagine/impl/shaders/OpacityMask.frag b/src/quickcontrols2/imagine/impl/shaders/OpacityMask.frag
index 84f9bc3ee6..e3b17752a7 100644
--- a/src/quickcontrols2/imagine/impl/shaders/OpacityMask.frag
+++ b/src/quickcontrols2/imagine/impl/shaders/OpacityMask.frag
@@ -1,3 +1,6 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
varying highp vec2 qt_TexCoord0;
uniform highp float qt_Opacity;
uniform lowp sampler2D source;
diff --git a/src/quickcontrols2/ios/CMakeLists.txt b/src/quickcontrols2/ios/CMakeLists.txt
index 8168d0d89b..7d8557fd0b 100644
--- a/src/quickcontrols2/ios/CMakeLists.txt
+++ b/src/quickcontrols2/ios/CMakeLists.txt
@@ -35,6 +35,9 @@ set(qml_files
"MenuBar.qml"
"Drawer.qml"
"Popup.qml"
+ "Menu.qml"
+ "MenuItem.qml"
+ "MenuSeparator.qml"
)
set_source_files_properties(Slider.qml PROPERTIES
@@ -70,7 +73,7 @@ qt_internal_add_qml_module(qtquickcontrols2iosstyleplugin
Qt::QuickControls2ImplPrivate
)
-qt_internal_extend_target(Core CONDITION APPLE AND IOS
+qt_internal_extend_target(qtquickcontrols2iosstyleplugin CONDITION APPLE AND IOS
LIBRARIES
${FWUIKit}
)
diff --git a/src/quickcontrols2/ios/Menu.qml b/src/quickcontrols2/ios/Menu.qml
new file mode 100644
index 0000000000..db142868a9
--- /dev/null
+++ b/src/quickcontrols2/ios/Menu.qml
@@ -0,0 +1,71 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Templates as T
+import QtQuick.Controls.impl
+import QtQuick.Controls.iOS
+
+T.Menu {
+ id: control
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ contentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ contentHeight + topPadding + bottomPadding)
+
+ delegate: MenuItem {}
+
+ margins: 0
+ cascade: true
+ dim: modal || control.parent && control.parent.menu
+ overlap: control.width
+
+ enter: Transition {
+ NumberAnimation { property: "scale"; from: 0.2; to: 1.0; easing.type: Easing.OutQuint; duration: 220 }
+ NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; easing.type: Easing.OutCubic; duration: 150 }
+ }
+
+ exit: Transition {
+ NumberAnimation { property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuint; duration: 220 }
+ NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.OutCubic; duration: 150 }
+ }
+
+ contentItem: ListView {
+ implicitHeight: contentHeight
+ model: control.contentModel
+ interactive: Window.window
+ ? contentHeight + control.topPadding + control.bottomPadding > Window.window.height
+ : false
+ clip: true
+ currentIndex: control.currentIndex
+
+ T.ScrollIndicator.vertical: ScrollIndicator { }
+ }
+
+ background: Item {
+ implicitHeight: 44
+ implicitWidth: 250
+ NinePatchImage {
+ width: parent.width
+ height: parent.height
+ source: control.IOS.url + "menu-background"
+ NinePatchImageSelector on source {
+ states: [
+ {"light": control.IOS.theme === IOS.Light},
+ {"dark": control.IOS.theme === IOS.Dark}
+ ]
+ }
+ }
+ }
+
+ T.Overlay.modal: Rectangle {
+ color: Color.transparent("black", 0.5)
+ Behavior on opacity { NumberAnimation { duration: 150 } }
+ }
+
+ T.Overlay.modeless: Rectangle {
+ color: Color.transparent("black", 0.5)
+ Behavior on opacity { NumberAnimation { duration: 150 } }
+ }
+}
diff --git a/src/quickcontrols2/ios/MenuItem.qml b/src/quickcontrols2/ios/MenuItem.qml
new file mode 100644
index 0000000000..8b05c33d45
--- /dev/null
+++ b/src/quickcontrols2/ios/MenuItem.qml
@@ -0,0 +1,104 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Templates as T
+import QtQuick.Controls.impl
+import QtQuick.Controls.iOS
+
+T.MenuItem {
+ id: control
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ implicitContentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ implicitContentHeight + topPadding + bottomPadding,
+ implicitIndicatorHeight + topPadding + bottomPadding)
+
+ leftPadding: 12
+ rightPadding: 18
+ spacing: 9
+
+ icon.width: 19
+ icon.height: 19
+ icon.color: control.palette.windowText
+
+ property bool isSingleItem: control.menu && control.menu.count === 1
+ property bool isFirstItem: !isSingleItem && control.menu && control.menu.itemAt(0) === control ? true : false
+ property bool isLastItem: !isSingleItem && control.menu && control.menu.itemAt(control.menu.count - 1) === control ? true : false
+ property real indicatorWidth: 12
+
+ contentItem: IconLabel {
+ readonly property real padding: control.indicatorWidth + control.spacing
+ leftPadding: !control.mirrored ? padding : 0
+ rightPadding: control.mirrored ? padding : 0
+
+ spacing: control.spacing
+ mirrored: control.mirrored
+ display: control.display
+ alignment: Qt.AlignLeft
+
+ icon: control.icon
+ text: control.text
+ font: control.font
+ color: control.palette.windowText
+ }
+
+ arrow: ColorImage {
+ x: control.mirrored ? control.width - width - control.rightPadding : control.leftPadding
+ y: control.topPadding + (control.availableHeight - height) / 2
+ width: 7
+ height: 12
+ rotation: control.subMenu && (control.down || control.subMenu.visible) ? 90 : 0
+
+ visible: control.subMenu
+ opacity: control.enabled ? 1 : 0.5
+ mirror: control.mirrored
+ color: control.palette.windowText
+ source: control.subMenu ? "qrc:/qt-project.org/imports/QtQuick/Controls/iOS/images/arrow-indicator-light.png" : ""
+
+ Behavior on rotation { RotationAnimation { duration: 100 } }
+ }
+
+ indicator: ColorImage {
+ x: control.mirrored ? control.width - width - control.rightPadding : control.leftPadding
+ y: control.topPadding + (control.availableHeight - height) / 2
+ width: control.indicatorWidth
+ height: control.indicatorWidth
+
+ visible: control.checked
+ source: control.checkable ? "qrc:/qt-project.org/imports/QtQuick/Controls/iOS/images/radiodelegate-indicator-light.png" : ""
+ color: control.palette.windowText
+ }
+
+ background: Item {
+ implicitHeight: 44
+ implicitWidth: 250
+ NinePatchImage {
+ y: control.isLastItem ? -1 : 0
+ width: parent.width
+ height: control.isLastItem ? parent.height + 1 : parent.height
+ rotation: control.isLastItem ? 180 : 0
+ visible: !(isSingleItem && !control.down)
+ source: control.IOS.url + "menuitem-background"
+ NinePatchImageSelector on source {
+ states: [
+ {"edge": control.isFirstItem || control.isLastItem},
+ {"single": control.isSingleItem},
+ {"light": control.IOS.theme === IOS.Light},
+ {"dark": control.IOS.theme === IOS.Dark},
+ {"pressed": control.down}
+ ]
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "submenu-opened"
+ when: control.subMenu && control.subMenu.visible
+ PropertyChanges { target: control.menu; scale: 0.9 }
+ }
+ ]
+}
+
diff --git a/src/quickcontrols2/ios/MenuSeparator.qml b/src/quickcontrols2/ios/MenuSeparator.qml
new file mode 100644
index 0000000000..5d64365219
--- /dev/null
+++ b/src/quickcontrols2/ios/MenuSeparator.qml
@@ -0,0 +1,26 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Templates as T
+import QtQuick.Controls.impl
+import QtQuick.Controls.iOS
+
+T.MenuSeparator {
+ id: control
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ implicitContentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ implicitContentHeight + topPadding + bottomPadding)
+
+ contentItem: NinePatchImage {
+ source: control.IOS.url + "menuseparator-separator"
+ NinePatchImageSelector on source {
+ states: [
+ {"light": control.IOS.theme === IOS.Light},
+ {"dark": control.IOS.theme === IOS.Dark}
+ ]
+ }
+ }
+}
diff --git a/src/quickcontrols2/ios/ProgressBar.qml b/src/quickcontrols2/ios/ProgressBar.qml
index 439ba5a309..b487d13528 100644
--- a/src/quickcontrols2/ios/ProgressBar.qml
+++ b/src/quickcontrols2/ios/ProgressBar.qml
@@ -24,7 +24,7 @@ T.ProgressBar {
readonly property NinePatchImage progress: NinePatchImage {
parent: control.contentItem
- visible: control.value
+ visible: control.indeterminate || control.value
y: (parent.height - height) / 2
width: control.indeterminate ? control.width * 0.4 : control.position * parent.width
@@ -44,8 +44,14 @@ T.ProgressBar {
easing.type: Easing.Linear
loops: Animation.Infinite
// TODO: workaround for QTBUG-38932; remove once that is fixed
- onFromChanged: restart()
- onToChanged: restart()
+ onFromChanged: {
+ if (control.indeterminate)
+ restart()
+ }
+ onToChanged: {
+ if (control.indeterminate)
+ restart()
+ }
}
}
}
diff --git a/src/quickcontrols2/ios/TreeViewDelegate.qml b/src/quickcontrols2/ios/TreeViewDelegate.qml
index 7f7099ecfb..571fcd4a29 100644
--- a/src/quickcontrols2/ios/TreeViewDelegate.qml
+++ b/src/quickcontrols2/ios/TreeViewDelegate.qml
@@ -1,4 +1,4 @@
-// Copyright (C) 2022 The Qt Company Lt.
+// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import QtQuick
@@ -20,6 +20,11 @@ T.TreeViewDelegate {
topPadding: contentItem ? (height - contentItem.implicitHeight) / 2 : 0
leftPadding: !mirrored ? leftMargin + __contentIndent : width - leftMargin - __contentIndent - implicitContentWidth
+ highlighted: control.selected || control.current
+ || ((control.treeView.selectionBehavior === TableView.SelectRows
+ || control.treeView.selectionBehavior === TableView.SelectionDisabled)
+ && control.row === control.treeView.currentRow)
+
required property int row
required property var model
readonly property real __contentIndent: !isTreeNode ? 0 : (depth * indentation) + (indicator ? indicator.width + spacing : 0)
@@ -54,7 +59,7 @@ T.TreeViewDelegate {
NinePatchImage {
height: parent.height
width: parent.width
- source: control.IOS.url + "itemdelegate-background"
+ source: control.IOS.url + (control.highlighted ? "itemdelegate-background-pressed" : "itemdelegate-background")
NinePatchImageSelector on source {
states: [
{"light": control.IOS.theme === IOS.Light},
diff --git a/src/quickcontrols2/ios/images/menu-background-dark.9.png b/src/quickcontrols2/ios/images/menu-background-dark.9.png
new file mode 100644
index 0000000000..863a3c1759
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menu-background-dark.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menu-background-dark@2x.9.png b/src/quickcontrols2/ios/images/menu-background-dark@2x.9.png
new file mode 100644
index 0000000000..ddddaa3532
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menu-background-dark@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menu-background-dark@3x.9.png b/src/quickcontrols2/ios/images/menu-background-dark@3x.9.png
new file mode 100644
index 0000000000..a640f6fe06
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menu-background-dark@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menu-background-light.9.png b/src/quickcontrols2/ios/images/menu-background-light.9.png
new file mode 100644
index 0000000000..410abed278
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menu-background-light.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menu-background-light@2x.9.png b/src/quickcontrols2/ios/images/menu-background-light@2x.9.png
new file mode 100644
index 0000000000..82d99af518
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menu-background-light@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menu-background-light@3x.9.png b/src/quickcontrols2/ios/images/menu-background-light@3x.9.png
new file mode 100644
index 0000000000..48f3f7ed4e
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menu-background-light@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-dark.9.png b/src/quickcontrols2/ios/images/menuitem-background-dark.9.png
new file mode 100644
index 0000000000..463def221b
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-dark.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-dark@2x.9.png b/src/quickcontrols2/ios/images/menuitem-background-dark@2x.9.png
new file mode 100644
index 0000000000..53fdaa7c35
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-dark@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-dark@3x.9.png b/src/quickcontrols2/ios/images/menuitem-background-dark@3x.9.png
new file mode 100644
index 0000000000..a514f80071
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-dark@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-dark.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-dark.9.png
new file mode 100644
index 0000000000..514c0901e6
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-dark.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-dark@2x.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-dark@2x.9.png
new file mode 100644
index 0000000000..1ca1ee8d9e
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-dark@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-dark@3x.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-dark@3x.9.png
new file mode 100644
index 0000000000..6a4277a7c3
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-dark@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-light.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-light.9.png
new file mode 100644
index 0000000000..262c12d7b7
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-light.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-light@2x.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-light@2x.9.png
new file mode 100644
index 0000000000..4838abb511
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-light@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-light@3x.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-light@3x.9.png
new file mode 100644
index 0000000000..0e17b608da
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-light@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark.9.png
new file mode 100644
index 0000000000..290101b99b
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark@2x.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark@2x.9.png
new file mode 100644
index 0000000000..a738f20650
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark@3x.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark@3x.9.png
new file mode 100644
index 0000000000..ef05342d0b
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-dark@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light.9.png
new file mode 100644
index 0000000000..706f642552
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light@2x.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light@2x.9.png
new file mode 100644
index 0000000000..e196a71bbe
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light@3x.9.png b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light@3x.9.png
new file mode 100644
index 0000000000..4f5a71ff86
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-edge-pressed-light@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-light.9.png b/src/quickcontrols2/ios/images/menuitem-background-light.9.png
new file mode 100644
index 0000000000..644f207a26
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-light.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-light@2x.9.png b/src/quickcontrols2/ios/images/menuitem-background-light@2x.9.png
new file mode 100644
index 0000000000..d7c78cb5dc
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-light@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-light@3x.9.png b/src/quickcontrols2/ios/images/menuitem-background-light@3x.9.png
new file mode 100644
index 0000000000..70ce76a961
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-light@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-pressed-dark.9.png b/src/quickcontrols2/ios/images/menuitem-background-pressed-dark.9.png
new file mode 100644
index 0000000000..4f1fdfc82c
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-pressed-dark.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-pressed-dark@2x.9.png b/src/quickcontrols2/ios/images/menuitem-background-pressed-dark@2x.9.png
new file mode 100644
index 0000000000..f72729f45d
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-pressed-dark@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-pressed-dark@3x.9.png b/src/quickcontrols2/ios/images/menuitem-background-pressed-dark@3x.9.png
new file mode 100644
index 0000000000..eaa574174b
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-pressed-dark@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-pressed-light.9.png b/src/quickcontrols2/ios/images/menuitem-background-pressed-light.9.png
new file mode 100644
index 0000000000..5141095a95
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-pressed-light.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-pressed-light@2x.9.png b/src/quickcontrols2/ios/images/menuitem-background-pressed-light@2x.9.png
new file mode 100644
index 0000000000..b8fb91997f
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-pressed-light@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-pressed-light@3x.9.png b/src/quickcontrols2/ios/images/menuitem-background-pressed-light@3x.9.png
new file mode 100644
index 0000000000..250247d322
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-pressed-light@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark.9.png b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark.9.png
new file mode 100644
index 0000000000..708285fe39
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark@2x.9.png b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark@2x.9.png
new file mode 100644
index 0000000000..0cb6f175ff
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark@3x.9.png b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark@3x.9.png
new file mode 100644
index 0000000000..cb7c1f210c
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-dark@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-single-pressed-light.9.png b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-light.9.png
new file mode 100644
index 0000000000..5a71309c91
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-light.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-single-pressed-light@2x.9.png b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-light@2x.9.png
new file mode 100644
index 0000000000..7798409aa3
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-light@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuitem-background-single-pressed-light@3x.9.png b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-light@3x.9.png
new file mode 100644
index 0000000000..77a69bd247
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuitem-background-single-pressed-light@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuseparator-separator-dark.9.png b/src/quickcontrols2/ios/images/menuseparator-separator-dark.9.png
new file mode 100644
index 0000000000..819e465354
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuseparator-separator-dark.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuseparator-separator-dark@2x.9.png b/src/quickcontrols2/ios/images/menuseparator-separator-dark@2x.9.png
new file mode 100644
index 0000000000..81e3cdd391
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuseparator-separator-dark@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuseparator-separator-dark@3x.9.png b/src/quickcontrols2/ios/images/menuseparator-separator-dark@3x.9.png
new file mode 100644
index 0000000000..95d88ee659
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuseparator-separator-dark@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuseparator-separator-light.9.png b/src/quickcontrols2/ios/images/menuseparator-separator-light.9.png
new file mode 100644
index 0000000000..46276666e2
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuseparator-separator-light.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuseparator-separator-light@2x.9.png b/src/quickcontrols2/ios/images/menuseparator-separator-light@2x.9.png
new file mode 100644
index 0000000000..0e2b9986a9
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuseparator-separator-light@2x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/images/menuseparator-separator-light@3x.9.png b/src/quickcontrols2/ios/images/menuseparator-separator-light@3x.9.png
new file mode 100644
index 0000000000..d3eb183bf3
--- /dev/null
+++ b/src/quickcontrols2/ios/images/menuseparator-separator-light@3x.9.png
Binary files differ
diff --git a/src/quickcontrols2/ios/qquickiosstyle.cpp b/src/quickcontrols2/ios/qquickiosstyle.cpp
index cc629d88e2..f773833f00 100644
--- a/src/quickcontrols2/ios/qquickiosstyle.cpp
+++ b/src/quickcontrols2/ios/qquickiosstyle.cpp
@@ -21,6 +21,7 @@ QQuickIOSStyle::QQuickIOSStyle(QObject *parent)
: QQuickAttachedObject(parent)
{
init();
+ m_theme = qquickios_effective_theme();
}
QQuickIOSStyle *QQuickIOSStyle::qmlAttachedProperties(QObject *object)
@@ -41,7 +42,6 @@ void QQuickIOSStyle::init()
// globalsInitialized = true;
// }
QQuickAttachedObject::init(); // TODO: lazy init?
- setTheme(qquickios_effective_theme());
}
QQuickIOSStyle::Theme QQuickIOSStyle::theme() const
@@ -49,13 +49,4 @@ QQuickIOSStyle::Theme QQuickIOSStyle::theme() const
return m_theme;
}
-void QQuickIOSStyle::setTheme(Theme theme)
-{
- if (m_theme == theme)
- return;
- m_theme = theme;
-
- themeChanged();
-}
-
QT_END_NAMESPACE
diff --git a/src/quickcontrols2/ios/qquickiosstyle_p.h b/src/quickcontrols2/ios/qquickiosstyle_p.h
index 2134440377..f24b435190 100644
--- a/src/quickcontrols2/ios/qquickiosstyle_p.h
+++ b/src/quickcontrols2/ios/qquickiosstyle_p.h
@@ -25,7 +25,7 @@ class QQuickIOSStyle : public QQuickAttachedObject
{
Q_OBJECT
Q_PROPERTY(QUrl url READ url CONSTANT)
- Q_PROPERTY(Theme theme READ theme WRITE setTheme NOTIFY themeChanged FINAL)
+ Q_PROPERTY(Theme theme READ theme NOTIFY themeChanged FINAL)
QML_NAMED_ELEMENT(IOS)
QML_ATTACHED(QQuickIOSStyle)
QML_UNCREATABLE("")
@@ -43,7 +43,6 @@ public:
static QQuickIOSStyle *qmlAttachedProperties(QObject *object);
Theme theme() const;
- void setTheme(Theme theme);
QUrl url() const;
diff --git a/src/quickcontrols2/macos/TreeViewDelegate.qml b/src/quickcontrols2/macos/TreeViewDelegate.qml
index c357f97a89..43930cc7a9 100644
--- a/src/quickcontrols2/macos/TreeViewDelegate.qml
+++ b/src/quickcontrols2/macos/TreeViewDelegate.qml
@@ -1,4 +1,4 @@
-// Copyright (C) 2021 The Qt Company Lt.
+// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import QtQuick
diff --git a/src/quickcontrols2/material/CMakeLists.txt b/src/quickcontrols2/material/CMakeLists.txt
index 19c68ebff9..2ca69fcad9 100644
--- a/src/quickcontrols2/material/CMakeLists.txt
+++ b/src/quickcontrols2/material/CMakeLists.txt
@@ -53,6 +53,7 @@ set(qml_files
"ToolButton.qml"
"ToolSeparator.qml"
"ToolTip.qml"
+ "TreeViewDelegate.qml"
"Tumbler.qml"
"VerticalHeaderView.qml"
)
diff --git a/src/quickcontrols2/material/HorizontalHeaderView.qml b/src/quickcontrols2/material/HorizontalHeaderView.qml
index 671728c004..430508cbdc 100644
--- a/src/quickcontrols2/material/HorizontalHeaderView.qml
+++ b/src/quickcontrols2/material/HorizontalHeaderView.qml
@@ -20,7 +20,7 @@ T.HorizontalHeaderView {
implicitHeight: Math.max(control.height, text.implicitHeight + (cellPadding * 2))
color: control.Material.backgroundColor
- Text {
+ Label {
id: text
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole]
: model[control.textRole])
diff --git a/src/quickcontrols2/material/TreeViewDelegate.qml b/src/quickcontrols2/material/TreeViewDelegate.qml
new file mode 100644
index 0000000000..a7be36a555
--- /dev/null
+++ b/src/quickcontrols2/material/TreeViewDelegate.qml
@@ -0,0 +1,62 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Templates as T
+import QtQuick.Controls.impl
+import QtQuick.Controls.Material
+
+T.TreeViewDelegate {
+ id: control
+
+ implicitWidth: leftMargin + __contentIndent + implicitContentWidth + rightPadding + rightMargin
+ implicitHeight: Math.max(implicitBackgroundHeight, implicitContentHeight, implicitIndicatorHeight)
+
+ indentation: indicator ? indicator.width : 12
+ leftMargin: 16
+ rightMargin: 16
+ spacing: 14
+
+ topPadding: contentItem ? (height - contentItem.implicitHeight) / 2 : 0
+ leftPadding: !mirrored ? leftMargin + __contentIndent : width - leftMargin - __contentIndent - implicitContentWidth
+
+ highlighted: control.selected || control.current
+ || ((control.treeView.selectionBehavior === TableView.SelectRows
+ || control.treeView.selectionBehavior === TableView.SelectionDisabled)
+ && control.row === control.treeView.currentRow)
+
+ required property int row
+ required property var model
+ readonly property real __contentIndent: !isTreeNode ? 0 : (depth * indentation) + (indicator ? indicator.width + spacing : 0)
+
+ indicator: Item {
+ readonly property real __indicatorIndent: control.leftMargin + (control.depth * control.indentation)
+ x: !control.mirrored ? __indicatorIndent : control.width - __indicatorIndent - width
+ y: (control.height - height) / 2
+ implicitWidth: Math.max(arrow.implicitWidth, 20)
+ implicitHeight: control.Material.buttonHeight
+
+ property ColorImage arrow : ColorImage {
+ parent: control.indicator
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ rotation: control.expanded ? 90 : (control.mirrored ? 180 : 0)
+ source: "qrc:/qt-project.org/imports/QtQuick/Controls/Material/images/arrow-indicator.png"
+ color: control.palette.windowText
+ defaultColor: "#353637"
+ }
+ }
+
+ background: Rectangle {
+ implicitHeight: control.Material.buttonHeight
+ color: control.highlighted
+ ? control.palette.highlight
+ : (control.treeView.alternatingRows && control.row % 2 !== 0
+ ? control.palette.alternateBase : control.palette.base)
+ }
+
+ contentItem: Label {
+ text: control.model.display
+ elide: Text.ElideRight
+ }
+}
diff --git a/src/quickcontrols2/material/VerticalHeaderView.qml b/src/quickcontrols2/material/VerticalHeaderView.qml
index e497d4a84c..322df3e593 100644
--- a/src/quickcontrols2/material/VerticalHeaderView.qml
+++ b/src/quickcontrols2/material/VerticalHeaderView.qml
@@ -20,7 +20,7 @@ T.VerticalHeaderView {
implicitHeight: text.implicitHeight + (cellPadding * 2)
color: control.Material.backgroundColor
- Text {
+ Label {
id: text
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole]
: model[control.textRole])
diff --git a/src/quickcontrols2/material/qt_attribution.json b/src/quickcontrols2/material/qt_attribution.json
index 85fdadf9e0..9d53b8b014 100644
--- a/src/quickcontrols2/material/qt_attribution.json
+++ b/src/quickcontrols2/material/qt_attribution.json
@@ -2,8 +2,8 @@
"Id": "shadow_angular_material",
"Name": "Shadow values from Angular Material",
"QDocModule": "qtquickcontrols",
- "QtUsage": "Used in the Material Style of Qt Quick Controls 2.",
- "Files": "ElevationEffect.qml",
+ "QtUsage": "Used in the Material Style of Qt Quick Controls.",
+ "Files": "impl/ElevationEffect.qml",
"Description": "Shadow values for the elevation effect.",
"Homepage": "https://angularjs.org/",
"License": "MIT License",
diff --git a/src/quickcontrols2/universal/HorizontalHeaderView.qml b/src/quickcontrols2/universal/HorizontalHeaderView.qml
index 878fb1e10e..f1112bb8f8 100644
--- a/src/quickcontrols2/universal/HorizontalHeaderView.qml
+++ b/src/quickcontrols2/universal/HorizontalHeaderView.qml
@@ -21,7 +21,7 @@ T.HorizontalHeaderView {
implicitHeight: Math.max(control.height, text.implicitHeight + (cellPadding * 2))
color: control.Universal.background
- Text {
+ Label {
id: text
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole]
: model[control.textRole])
diff --git a/src/quickcontrols2/universal/VerticalHeaderView.qml b/src/quickcontrols2/universal/VerticalHeaderView.qml
index 189bed0906..c8fb52a58f 100644
--- a/src/quickcontrols2/universal/VerticalHeaderView.qml
+++ b/src/quickcontrols2/universal/VerticalHeaderView.qml
@@ -21,7 +21,7 @@ T.VerticalHeaderView {
implicitHeight: text.implicitHeight + (cellPadding * 2)
color: control.Universal.background
- Text {
+ Label {
id: text
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole]
: model[control.textRole])
diff --git a/src/quickcontrols2/windows/SpinBox.qml b/src/quickcontrols2/windows/SpinBox.qml
index 2d07b92d1f..0d54e1a4c5 100644
--- a/src/quickcontrols2/windows/SpinBox.qml
+++ b/src/quickcontrols2/windows/SpinBox.qml
@@ -8,12 +8,9 @@ import QtQuick.NativeStyle as NativeStyle
T.SpinBox {
id: control
- property bool __nativeBackground: background instanceof NativeStyle.StyleItem
property bool nativeIndicators: up.indicator.hasOwnProperty("_qt_default")
&& down.indicator.hasOwnProperty("_qt_default")
- font.pixelSize: __nativeBackground ? background.styleFont(control).pixelSize : undefined
-
implicitWidth: Math.max(contentItem.implicitWidth + leftInset + rightInset,
90 /* minimum */ )
implicitHeight: Math.max(contentItem.implicitHeight, up.implicitIndicatorHeight + down.implicitIndicatorHeight)
@@ -21,10 +18,10 @@ T.SpinBox {
spacing: 2
- leftPadding: __nativeBackground ? background.contentPadding.left: 0
- topPadding: __nativeBackground ? background.contentPadding.top: 0
- rightPadding: (__nativeBackground ? background.contentPadding.right : 0) + rightInset
- bottomPadding: __nativeBackground ? background.contentPadding.bottom: 0
+ leftPadding: 0
+ topPadding: 0
+ rightPadding: rightInset
+ bottomPadding: 0
validator: IntValidator {
locale: control.locale.name
diff --git a/src/quickcontrols2impl/qquickimageselector.cpp b/src/quickcontrols2impl/qquickimageselector.cpp
index a7c431ba7a..35f6555684 100644
--- a/src/quickcontrols2impl/qquickimageselector.cpp
+++ b/src/quickcontrols2impl/qquickimageselector.cpp
@@ -30,14 +30,14 @@ static inline int cacheSize()
static QList<QStringList> permutations(const QStringList &input, int count = -1)
{
if (count == -1)
- count = input.count();
+ count = input.size();
QList<QStringList> output;
- for (int i = 0; i < input.count(); ++i) {
+ for (int i = 0; i < input.size(); ++i) {
QStringList sub = input.mid(i, count);
if (count > 1) {
- if (i + count > input.count())
+ if (i + count > input.size())
sub += input.mid(0, count - i + 1);
std::sort(sub.begin(), sub.end());
@@ -49,7 +49,7 @@ static QList<QStringList> permutations(const QStringList &input, int count = -1)
output += sub;
}
- if (count == input.count())
+ if (count == input.size())
break;
}
@@ -256,7 +256,7 @@ void QQuickImageSelector::setUrl(const QUrl &url)
bool QQuickImageSelector::updateActiveStates()
{
QStringList active;
- for (const QVariant &v : qAsConst(m_allStates)) {
+ for (const QVariant &v : std::as_const(m_allStates)) {
const QVariantMap state = v.toMap();
if (state.isEmpty())
continue;
@@ -275,8 +275,8 @@ bool QQuickImageSelector::updateActiveStates()
int QQuickImageSelector::calculateScore(const QStringList &states) const
{
int score = 0;
- for (int i = 0; i < states.count(); ++i)
- score += (m_activeStates.count() - m_activeStates.indexOf(states.at(i))) << 1;
+ for (int i = 0; i < states.size(); ++i)
+ score += (m_activeStates.size() - m_activeStates.indexOf(states.at(i))) << 1;
return score;
}
diff --git a/src/quickcontrols2impl/qquickmnemoniclabel.cpp b/src/quickcontrols2impl/qquickmnemoniclabel.cpp
index c88f0994c9..982ffeeb66 100644
--- a/src/quickcontrols2impl/qquickmnemoniclabel.cpp
+++ b/src/quickcontrols2impl/qquickmnemoniclabel.cpp
@@ -58,7 +58,7 @@ void QQuickMnemonicLabel::updateMnemonic()
QString text(m_fullText.size(), QChar::Null);
int idx = 0;
int pos = 0;
- int len = m_fullText.length();
+ int len = m_fullText.size();
QList<QTextLayout::FormatRange> formats;
while (len) {
if (m_fullText.at(pos) == QLatin1Char('&') && (len == 1 || m_fullText.at(pos + 1) != QLatin1Char('&'))) {
diff --git a/src/quickcontrols2impl/qquickninepatchimage.cpp b/src/quickcontrols2impl/qquickninepatchimage.cpp
index cdd4708e30..cc3869ded9 100644
--- a/src/quickcontrols2impl/qquickninepatchimage.cpp
+++ b/src/quickcontrols2impl/qquickninepatchimage.cpp
@@ -54,6 +54,9 @@ QList<qreal> QQuickNinePatchData::coordsForSize(qreal size) const
return coords;
}
+/*
+ Adds the 0 index coordinate if appropriate, and the one at "size".
+*/
void QQuickNinePatchData::fill(const QList<qreal> &coords, qreal size)
{
data.clear();
@@ -174,6 +177,31 @@ public:
QQuickNinePatchData yDivs;
};
+/*
+ Examines each pixel in a horizontal or vertical (if offset is equal to the image's width)
+ line, storing the start and end index ("coordinate") of each 9-patch line.
+
+ For instance, in the 7x3 (9x5 actual size) 9-patch image below, which has no horizontal
+ stretchable area, it would return {}:
+
+ +-----+
+ | |
+ +-----+
+
+ If indices 3 to 5 were marked, it would return {2, 5}:
+
+ xxx
+ +-----+
+ | |
+ +-----+
+
+ If indices 3 and 5 were marked, it would store {0, 2, 3, 4, 5, 7}:
+
+ x x
+ +-----+
+ | |
+ +-----+
+*/
static QList<qreal> readCoords(const QRgb *data, int from, int count, int offset, QRgb color)
{
int p1 = -1;
@@ -182,12 +210,16 @@ static QList<qreal> readCoords(const QRgb *data, int from, int count, int offset
int p2 = from + i * offset;
if (data[p2] == color) {
// colored pixel
- if (p1 == -1)
+ if (p1 == -1) {
+ // This is the start of a 9-patch line.
p1 = i;
+ }
} else {
// empty pixel
if (p1 != -1) {
+ // This is the end of a 9-patch line; add the start and end indices as coordinates...
coords << p1 << i;
+ // ... and reset p1 so that we can search for the next one.
p1 = -1;
}
}
@@ -195,6 +227,12 @@ static QList<qreal> readCoords(const QRgb *data, int from, int count, int offset
return coords;
}
+/*
+ Called whenever a 9-patch image is set as the image's source.
+
+ Reads the 9-patch lines from the source image and sets the
+ inset and padding properties accordingly.
+*/
void QQuickNinePatchImagePrivate::updatePatches()
{
if (ninePatch.isNull())
@@ -228,7 +266,7 @@ void QQuickNinePatchImagePrivate::updatePaddings(const QSizeF &size, const QList
qreal oldRightPadding = rightPadding;
qreal oldBottomPadding = bottomPadding;
- if (horizontal.count() >= 2) {
+ if (horizontal.size() >= 2) {
leftPadding = horizontal.first();
rightPadding = size.width() - horizontal.last() - 2;
} else {
@@ -236,7 +274,7 @@ void QQuickNinePatchImagePrivate::updatePaddings(const QSizeF &size, const QList
rightPadding = 0;
}
- if (vertical.count() >= 2) {
+ if (vertical.size() >= 2) {
topPadding = vertical.first();
bottomPadding = size.height() - vertical.last() - 2;
} else {
@@ -262,26 +300,26 @@ void QQuickNinePatchImagePrivate::updateInsets(const QList<qreal> &horizontal, c
qreal oldRightInset = rightInset;
qreal oldBottomInset = bottomInset;
- if (horizontal.count() >= 2 && horizontal.first() == 0)
+ if (horizontal.size() >= 2 && horizontal.first() == 0)
leftInset = horizontal.at(1);
else
leftInset = 0;
- if (horizontal.count() == 2 && horizontal.first() > 0)
+ if (horizontal.size() == 2 && horizontal.first() > 0)
rightInset = horizontal.last() - horizontal.first();
- else if (horizontal.count() == 4)
+ else if (horizontal.size() == 4)
rightInset = horizontal.last() - horizontal.at(2);
else
rightInset = 0;
- if (vertical.count() >= 2 && vertical.first() == 0)
+ if (vertical.size() >= 2 && vertical.first() == 0)
topInset = vertical.at(1);
else
topInset = 0;
- if (vertical.count() == 2 && vertical.first() > 0)
+ if (vertical.size() == 2 && vertical.first() > 0)
bottomInset = vertical.last() - vertical.first();
- else if (vertical.count() == 4)
+ else if (vertical.size() == 4)
bottomInset = vertical.last() - vertical.at(2);
else
bottomInset = 0;
@@ -299,6 +337,8 @@ void QQuickNinePatchImagePrivate::updateInsets(const QList<qreal> &horizontal, c
QQuickNinePatchImage::QQuickNinePatchImage(QQuickItem *parent)
: QQuickImage(*(new QQuickNinePatchImagePrivate), parent)
{
+ Q_D(QQuickNinePatchImage);
+ d->smooth = qEnvironmentVariableIntValue("QT_QUICK_CONTROLS_IMAGINE_SMOOTH");
}
qreal QQuickNinePatchImage::topPadding() const
@@ -403,6 +443,9 @@ QSGNode *QQuickNinePatchImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNode
d->resetNode = false;
}
+ if (d->ninePatch.isNull())
+ return QQuickImage::updatePaintNode(oldNode, data);
+
QSizeF sz = size();
QImage image = d->pix.image();
if (!sz.isValid() || image.isNull()) {
@@ -412,9 +455,6 @@ QSGNode *QQuickNinePatchImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNode
return nullptr;
}
- if (d->ninePatch.isNull())
- return QQuickImage::updatePaintNode(oldNode, data);
-
QQuickNinePatchNode *patchNode = static_cast<QQuickNinePatchNode *>(oldNode);
if (!patchNode)
patchNode = new QQuickNinePatchNode;
@@ -432,6 +472,8 @@ QSGNode *QQuickNinePatchImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNode
QSGTexture *texture = window()->createTextureFromImage(image);
patchNode->initialize(texture, sz * d->devicePixelRatio, image.size(), d->xDivs, d->yDivs, d->devicePixelRatio);
+ auto patchNodeMaterial = static_cast<QSGTextureMaterial *>(patchNode->material());
+ patchNodeMaterial->setFiltering(d->smooth ? QSGTexture::Linear : QSGTexture::Nearest);
return patchNode;
}
diff --git a/src/quickcontrolstestutils/CMakeLists.txt b/src/quickcontrolstestutils/CMakeLists.txt
index 3cb27c71e7..268dc4198d 100644
--- a/src/quickcontrolstestutils/CMakeLists.txt
+++ b/src/quickcontrolstestutils/CMakeLists.txt
@@ -23,3 +23,11 @@ qt_internal_add_module(QuickControlsTestUtilsPrivate
Qt::QuickTemplates2Private
Qt::QuickTestUtilsPrivate
)
+
+# This is used by both C++ and QML tests, so we need it to be a library and a QML plugin,
+# hence qt_internal_add_qml_module. We use it in addition to qt_internal_add_module,
+# because otherwise syncqt complains that there is no "QtQuickControlsTestUtilsPrivate" module.
+qt_internal_add_qml_module(QuickControlsTestUtilsPrivate
+ URI "Qt.test.controls"
+ VERSION "${PROJECT_VERSION}"
+)
diff --git a/src/quickcontrolstestutils/controlstestutils.cpp b/src/quickcontrolstestutils/controlstestutils.cpp
index df65c3234b..f565751c0d 100644
--- a/src/quickcontrolstestutils/controlstestutils.cpp
+++ b/src/quickcontrolstestutils/controlstestutils.cpp
@@ -4,6 +4,7 @@
#include "controlstestutils_p.h"
#include <QtTest/qsignalspy.h>
+#include <QtQml/qqmlcomponent.h>
#include <QtQuickControls2/qquickstyle.h>
#include <QtQuickTemplates2/private/qquickabstractbutton_p.h>
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
@@ -16,11 +17,19 @@ QQuickControlsTestUtils::QQuickControlsApplicationHelper::QQuickControlsApplicat
appWindow = qobject_cast<QQuickApplicationWindow*>(cleanup.data());
}
+/*!
+ \internal
+
+ If \a style is different from the current style, this function will
+ recreate the QML engine, clear type registrations and set the new style.
+
+ Returns \c true if successful or if \c style is already set.
+*/
bool QQuickControlsTestUtils::QQuickStyleHelper::updateStyle(const QString &style)
{
// If it's not the first time a style has been set and the new style is not different, do nothing.
if (!currentStyle.isEmpty() && style == currentStyle)
- return false;
+ return true;
engine.reset();
currentStyle = style;
@@ -30,8 +39,9 @@ bool QQuickControlsTestUtils::QQuickStyleHelper::updateStyle(const QString &styl
QQmlComponent component(engine.data());
component.setData(QString::fromUtf8("import QtQuick\nimport QtQuick.Controls\n Control { }").toUtf8(), QUrl());
-
- return true;
+ if (!component.isReady())
+ qWarning() << "Failed to load component:" << component.errorString();
+ return component.isReady();
}
void QQuickControlsTestUtils::forEachControl(QQmlEngine *engine, const QString &qqc2ImportPath,
@@ -127,7 +137,7 @@ bool QQuickControlsTestUtils::clickButton(QQuickAbstractButton *button)
const QPoint buttonCenter = button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint();
QTest::mouseClick(button->window(), Qt::LeftButton, Qt::NoModifier, buttonCenter);
- if (spy.count() != 1) {
+ if (spy.size() != 1) {
qWarning() << "clicked signal of button" << button << "was not emitted after clicking";
return false;
}
@@ -148,10 +158,23 @@ bool QQuickControlsTestUtils::doubleClickButton(QQuickAbstractButton *button)
const QPoint buttonCenter = button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint();
QTest::mouseDClick(button->window(), Qt::LeftButton, Qt::NoModifier, buttonCenter);
- if (spy.count() != 1) {
+ if (spy.size() != 1) {
qWarning() << "doubleClicked signal of button" << button << "was not emitted after double-clicking";
return false;
}
return true;
}
+
+/*!
+ Allows creating QQmlComponents in C++, which is useful for tests that need
+ to check if items created from the component have the correct QML context.
+*/
+Q_INVOKABLE QQmlComponent *QQuickControlsTestUtils::ComponentCreator::createComponent(const QByteArray &data)
+{
+ std::unique_ptr<QQmlComponent> component(new QQmlComponent(qmlEngine(this)));
+ component->setData(data, QUrl());
+ if (component->isError())
+ qmlWarning(this) << "Failed to create component from the following data:\n" << data;
+ return component.release();
+}
diff --git a/src/quickcontrolstestutils/controlstestutils_p.h b/src/quickcontrolstestutils/controlstestutils_p.h
index 4d79d4af52..487d3b79fe 100644
--- a/src/quickcontrolstestutils/controlstestutils_p.h
+++ b/src/quickcontrolstestutils/controlstestutils_p.h
@@ -19,6 +19,7 @@
QT_BEGIN_NAMESPACE
+class QQmlComponent;
class QQmlEngine;
class QQuickApplicationWindow;
class QQuickAbstractButton;
@@ -53,6 +54,17 @@ namespace QQuickControlsTestUtils
[[nodiscard]] bool verifyButtonClickable(QQuickAbstractButton *button);
[[nodiscard]] bool clickButton(QQuickAbstractButton *button);
[[nodiscard]] bool doubleClickButton(QQuickAbstractButton *button);
+
+ class ComponentCreator : public QObject
+ {
+ Q_OBJECT
+ QML_ELEMENT
+ QML_SINGLETON
+ Q_MOC_INCLUDE(<QtQml/qqmlcomponent.h>)
+
+ public:
+ Q_INVOKABLE QQmlComponent *createComponent(const QByteArray &data);
+ };
}
QT_END_NAMESPACE
diff --git a/src/quickcontrolstestutils/dialogstestutils.cpp b/src/quickcontrolstestutils/dialogstestutils.cpp
index 972ef63f21..71622fabb0 100644
--- a/src/quickcontrolstestutils/dialogstestutils.cpp
+++ b/src/quickcontrolstestutils/dialogstestutils.cpp
@@ -40,9 +40,17 @@ bool QQuickDialogTestUtils::verifyFileDialogDelegates(QQuickListView *fileDialog
}
if (actualFiles != expectedFiles) {
+ QString expectedFilesStr = QDebug::toString(expectedFiles);
+ QString actualFilesStr = QDebug::toString(actualFiles);
failureMessage = QString::fromLatin1("Mismatch in actual vs expected "
- "delegates in fileDialogListView:\n expected: %1\n actual: %2")
- .arg(QDebug::toString(expectedFiles), QDebug::toString(actualFiles));
+ "delegates in fileDialogListView:\n expected: %1\n actual: %2");
+ if (failureMessage.size() + expectedFilesStr.size() + actualFilesStr.size() > 1024) {
+ // If we've exceeded QTest's character limit for failure messages,
+ // just show the number of files.
+ expectedFilesStr = QString::number(expectedFiles.size());
+ actualFilesStr = QString::number(actualFiles.size());
+ }
+ failureMessage = failureMessage.arg(expectedFilesStr, actualFilesStr);
return false;
}
diff --git a/src/quickcontrolstestutils/qtest_quickcontrols_p.h b/src/quickcontrolstestutils/qtest_quickcontrols_p.h
index bd86e4a18b..1294781114 100644
--- a/src/quickcontrolstestutils/qtest_quickcontrols_p.h
+++ b/src/quickcontrolstestutils/qtest_quickcontrols_p.h
@@ -22,7 +22,7 @@
#include <QtQuickControls2/qquickstyle.h>
#include <QtQuickControls2/private/qquickstyle_p.h>
-static QStringList testStyles()
+inline QStringList testStyles()
{
// It's not enough to check if the name is empty, because since Qt 6
// we set an appropriate style for the platform if no style was specified.
@@ -33,7 +33,7 @@ static QStringList testStyles()
return QStringList(QQuickStyle::name());
}
-static int runTests(QObject *testObject, int argc, char *argv[])
+inline int runTests(QObject *testObject, int argc, char *argv[])
{
int res = 0;
QTest::qInit(testObject, argc, argv);
diff --git a/src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf b/src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf
index 6d59f69817..d4f7595f0f 100644
--- a/src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf
+++ b/src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf
@@ -24,6 +24,8 @@ depends = qtcore qtqmlcore qtgui qtdoc qtqml qtquick qtquickcontrols qtlabsplatf
# This module has no documented C++ types, clear the module header
moduleheader =
+exampledirs += snippets
+
headerdirs += ..
sourcedirs += .. \
src
diff --git a/src/quickdialogs2/quickdialogs2/doc/snippets/qtquickdialogs-filedialog.qml b/src/quickdialogs2/quickdialogs2/doc/snippets/qtquickdialogs-filedialog.qml
new file mode 100644
index 0000000000..ab3f33f910
--- /dev/null
+++ b/src/quickdialogs2/quickdialogs2/doc/snippets/qtquickdialogs-filedialog.qml
@@ -0,0 +1,34 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+//! [file]
+import QtCore
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Dialogs
+
+ApplicationWindow {
+ width: 640
+ height: 480
+ visible: true
+
+ header: ToolBar {
+ Button {
+ text: qsTr("Choose Image...")
+ onClicked: fileDialog.open()
+ }
+ }
+
+ Image {
+ id: image
+ anchors.fill: parent
+ fillMode: Image.PreserveAspectFit
+ }
+
+ FileDialog {
+ id: fileDialog
+ currentFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
+ onAccepted: image.source = selectedFile
+ }
+}
+//! [file]
diff --git a/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp b/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp
index 4caaec96cf..6b1cdb860c 100644
--- a/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp
+++ b/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp
@@ -36,23 +36,7 @@ Q_LOGGING_CATEGORY(lcFileDialog, "qt.quick.dialogs.filedialog")
properties are updated only after the final selection has been made by
accepting the dialog.
- \code
- MenuItem {
- text: "Open..."
- onTriggered: fileDialog.open()
- }
-
- FileDialog {
- id: fileDialog
- currentFile: document.source
- folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
- }
-
- MyDocument {
- id: document
- source: fileDialog.file
- }
- \endcode
+ \snippet qtquickdialogs-filedialog.qml file
\section2 Availability
@@ -179,7 +163,7 @@ void QQuickFileDialog::setSelectedFiles(const QList<QUrl> &selectedFiles)
if (m_fileMode != SaveFile) {
for (const auto &selectedFile : selectedFiles) {
- const QString selectedFilePath = selectedFile.toLocalFile();
+ const QString selectedFilePath = QQmlFile::urlToLocalFileOrQrc(selectedFile);
if (!QFileInfo::exists(selectedFilePath)) {
qmlWarning(this) << "Cannot set " << selectedFilePath
<< " as a selected file because it doesn't exist";
@@ -342,7 +326,7 @@ void QQuickFileDialog::setNameFilters(const QStringList &filters)
m_options->setNameFilters(filters);
if (m_selectedNameFilter) {
int index = m_selectedNameFilter->index();
- if (index < 0 || index >= filters.count())
+ if (index < 0 || index >= filters.size())
index = 0;
m_selectedNameFilter->update(filters.value(index));
}
diff --git a/src/quickdialogs2/quickdialogs2/qquickfolderdialog.cpp b/src/quickdialogs2/quickdialogs2/qquickfolderdialog.cpp
index a2c3a45ba6..692a68c7a6 100644
--- a/src/quickdialogs2/quickdialogs2/qquickfolderdialog.cpp
+++ b/src/quickdialogs2/quickdialogs2/qquickfolderdialog.cpp
@@ -30,19 +30,19 @@ Q_DECLARE_LOGGING_CATEGORY(lcDialogs)
\code
MenuItem {
- text: "Open..."
+ text: qsTr("Open...")
onTriggered: folderDialog.open()
}
FolderDialog {
id: folderDialog
- currentFolder: viewer.folder
- folder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
+ currentFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
+ selectedFolder: viewer.folder
}
MyViewer {
id: viewer
- folder: folderDialog.folder
+ folder: folderDialog.selectedFolder
}
\endcode
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/CMakeLists.txt b/src/quickdialogs2/quickdialogs2quickimpl/CMakeLists.txt
index abbee6dfd2..6feb99f204 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/CMakeLists.txt
+++ b/src/quickdialogs2/quickdialogs2quickimpl/CMakeLists.txt
@@ -67,6 +67,10 @@ qt_internal_add_qml_module(QuickDialogs2QuickImpl
qquickcolordialogimpl.cpp
qquickcolordialogimpl_p.h
qquickcolordialogimpl_p_p.h
+ qquickcolordialogutils_p.h
+ qquickcolordialogutils.cpp
+ qquickcolorinputs.cpp
+ qquickcolorinputs_p.h
qquickdialogimplfactory.cpp
qquickdialogimplfactory_p.h
qquickfiledialogdelegate.cpp
@@ -204,4 +208,5 @@ qt_internal_add_shaders(QuickDialogs2QuickImpl "QuickDialogs2QuickImplShaders"
"/qt-project.org/imports/QtQuick/Dialogs/quickimpl"
FILES
"shaders/SaturationLightness.frag"
+ SILENT
)
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Fusion/ColorDialog.qml b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Fusion/ColorDialog.qml
index 441e032fa4..3ad3c80369 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Fusion/ColorDialog.qml
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Fusion/ColorDialog.qml
@@ -33,6 +33,7 @@ ColorDialogImpl {
ColorDialogImpl.eyeDropperButton: eyeDropperButton
ColorDialogImpl.buttonBox: buttonBox
ColorDialogImpl.colorPicker: colorPicker
+ ColorDialogImpl.colorInputs: inputs
ColorDialogImpl.alphaSlider: alphaSlider
background: Rectangle {
@@ -132,7 +133,6 @@ ColorDialogImpl {
Slider {
id: alphaSlider
objectName: "alphaSlider"
- visible: control.showAlpha
orientation: Qt.Horizontal
value: control.alpha
implicitHeight: 20
@@ -187,28 +187,8 @@ ColorDialogImpl {
ColorInputs {
id: inputs
- spacing: 12
- currentColor: control.color
- red: control.red
- green: control.green
- blue: control.blue
- hue: control.hue
- saturation: control.saturation
- value: control.value
- lightness: control.lightness
- alpha: control.alpha
- showAlpha: control.showAlpha
- onEmitHex: function (hex) { control.color = hex; }
- onEmitRed: function (r) { control.red = r; }
- onEmitGreen: function (g) { control.green = g; }
- onEmitBlue: function (b) { control.blue = b; }
- onEmitHue: function (h) { control.hue = h; }
- onEmitSaturation: function (s) { control.saturation = s; }
- onEmitValue: function(v) { control.value = v; }
- onEmitLightness: function (l) { control.lightness = l; }
- onEmitAlpha: function (a) { control.alpha = a; }
+ color: control.color
- Layout.fillWidth: true
Layout.leftMargin: 12
Layout.rightMargin: 12
Layout.bottomMargin: 12
@@ -246,6 +226,12 @@ ColorDialogImpl {
Layout.bottomMargin: 6
}
+ Item {
+ Layout.fillWidth: true
+ Layout.topMargin: 6
+ Layout.bottomMargin: 6
+ }
+
DialogButtonBox {
id: buttonBox
standardButtons: control.standardButtons
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Fusion/FileDialog.qml b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Fusion/FileDialog.qml
index 26b6bec534..a928a4b0cc 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Fusion/FileDialog.qml
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Fusion/FileDialog.qml
@@ -43,6 +43,8 @@ FileDialogImpl {
FileDialogImpl.nameFiltersComboBox: nameFiltersComboBox
FileDialogImpl.fileDialogListView: fileDialogListView
FileDialogImpl.breadcrumbBar: breadcrumbBar
+ FileDialogImpl.fileNameLabel: fileNameLabel
+ FileDialogImpl.fileNameTextField: fileNameTextField
background: Rectangle {
implicitWidth: 600
@@ -127,16 +129,40 @@ FileDialogImpl {
}
}
- footer: RowLayout {
- id: rowLayout
- spacing: 12
+ footer: GridLayout {
+ columnSpacing: 12
+ columns: 3
+
+ Label {
+ id: fileNameLabel
+ text: qsTr("File name")
+ Layout.leftMargin: 12
+ visible: false
+ }
+
+ TextField {
+ id: fileNameTextField
+ objectName: "fileNameTextField"
+ text: control.fileName
+ visible: false
+
+ Layout.fillWidth: true
+ }
+
+ Label {
+ text: qsTr("Filter")
+ Layout.column: 0
+ Layout.row: 1
+ Layout.leftMargin: 12
+ Layout.bottomMargin: 12
+ }
+
ComboBox {
// OK to use IDs here, since users shouldn't be overriding this stuff.
id: nameFiltersComboBox
model: control.nameFilters
- Layout.leftMargin: 12
Layout.fillWidth: true
Layout.bottomMargin: 12
}
@@ -149,6 +175,10 @@ FileDialogImpl {
verticalPadding: 0
background: null
+ // TODO: make the orientation vertical
+ Layout.row: 1
+ Layout.column: 2
+ Layout.columnSpan: 1
Layout.rightMargin: 12
Layout.bottomMargin: 12
}
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Imagine/ColorDialog.qml b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Imagine/ColorDialog.qml
index b4713cbb76..f0150c8fdd 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Imagine/ColorDialog.qml
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Imagine/ColorDialog.qml
@@ -43,6 +43,7 @@ ColorDialogImpl {
ColorDialogImpl.buttonBox: buttonBox
ColorDialogImpl.colorPicker: colorPicker
ColorDialogImpl.alphaSlider: alphaSlider
+ ColorDialogImpl.colorInputs: inputs
background: NinePatchImage {
source: Imagine.url + "dialog-background"
@@ -136,7 +137,6 @@ ColorDialogImpl {
Slider {
id: alphaSlider
objectName: "alphaSlider"
- visible: control.showAlpha
orientation: Qt.Horizontal
value: control.alpha
implicitHeight: 20
@@ -194,28 +194,8 @@ ColorDialogImpl {
ColorInputs {
id: inputs
- spacing: 20
- currentColor: control.color
- red: control.red
- green: control.green
- blue: control.blue
- hue: control.hue
- saturation: control.saturation
- value: control.value
- lightness: control.lightness
- alpha: control.alpha
- showAlpha: control.showAlpha
- onEmitHex: function (hex) { control.color = hex; }
- onEmitRed: function (r) { control.red = r; }
- onEmitGreen: function (g) { control.green = g; }
- onEmitBlue: function (b) { control.blue = b; }
- onEmitHue: function (h) { control.hue = h; }
- onEmitSaturation: function (s) { control.saturation = s; }
- onEmitValue: function(v) { control.value = v; }
- onEmitLightness: function (l) { control.lightness = l; }
- onEmitAlpha: function (a) { control.alpha = a; }
+ color: control.color
- Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.bottomMargin: 16
@@ -255,6 +235,11 @@ ColorDialogImpl {
Layout.bottomMargin: 16
}
+ Item {
+ // empty filler
+ Layout.fillWidth: true
+ }
+
DialogButtonBox {
id: buttonBox
standardButtons: control.standardButtons
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Imagine/FileDialog.qml b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Imagine/FileDialog.qml
index 762cf8c5cc..664965e571 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Imagine/FileDialog.qml
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Imagine/FileDialog.qml
@@ -43,6 +43,8 @@ FileDialogImpl {
FileDialogImpl.nameFiltersComboBox: nameFiltersComboBox
FileDialogImpl.fileDialogListView: fileDialogListView
FileDialogImpl.breadcrumbBar: breadcrumbBar
+ FileDialogImpl.fileNameLabel: fileNameLabel
+ FileDialogImpl.fileNameTextField: fileNameTextField
background: NinePatchImage {
source: Imagine.url + "dialog-background"
@@ -116,17 +118,42 @@ FileDialogImpl {
}
}
- footer: RowLayout {
- id: rowLayout
- spacing: 20
+ footer: GridLayout {
+ columnSpacing: 20
+ columns: 3
+
+ Label {
+ id: fileNameLabel
+ text: qsTr("File name")
+ visible: false
+
+ Layout.leftMargin: 16
+ }
+
+ TextField {
+ id: fileNameTextField
+ objectName: "fileNameTextField"
+ text: control.fileName
+ visible: false
+
+ Layout.fillWidth: true
+ }
+
+ Label {
+ text: qsTr("Filter")
+
+ Layout.column: 0
+ Layout.row: 1
+ Layout.leftMargin: 16
+ Layout.bottomMargin: 16
+ }
ComboBox {
id: nameFiltersComboBox
model: control.nameFilters
- Layout.leftMargin: 16
- Layout.bottomMargin: 16
Layout.fillWidth: true
+ Layout.bottomMargin: 16
}
DialogButtonBox {
@@ -134,6 +161,9 @@ FileDialogImpl {
standardButtons: control.standardButtons
spacing: 12
+ Layout.row: 1
+ Layout.column: 2
+ Layout.columnSpan: 1
Layout.bottomMargin: 16
Layout.rightMargin: 16
}
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Material/ColorDialog.qml b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Material/ColorDialog.qml
index 718f5e6730..9f07f9fd3e 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Material/ColorDialog.qml
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Material/ColorDialog.qml
@@ -33,6 +33,7 @@ ColorDialogImpl {
ColorDialogImpl.buttonBox: buttonBox
ColorDialogImpl.colorPicker: colorPicker
ColorDialogImpl.alphaSlider: alphaSlider
+ ColorDialogImpl.colorInputs: inputs
Material.elevation: 24
@@ -127,7 +128,6 @@ ColorDialogImpl {
Slider {
id: alphaSlider
objectName: "alphaSlider"
- visible: control.showAlpha
orientation: Qt.Horizontal
value: control.alpha
implicitHeight: 20
@@ -185,28 +185,8 @@ ColorDialogImpl {
ColorInputs {
id: inputs
- spacing: 12
- currentColor: control.color
- red: control.red
- green: control.green
- blue: control.blue
- hue: control.hue
- saturation: control.saturation
- value: control.value
- lightness: control.lightness
- alpha: control.alpha
- showAlpha: control.showAlpha
- onEmitHex: function (hex) { control.color = hex; }
- onEmitRed: function (r) { control.red = r; }
- onEmitGreen: function (g) { control.green = g; }
- onEmitBlue: function (b) { control.blue = b; }
- onEmitHue: function (h) { control.hue = h; }
- onEmitSaturation: function (s) { control.saturation = s; }
- onEmitValue: function(v) { control.value = v; }
- onEmitLightness: function (l) { control.lightness = l; }
- onEmitAlpha: function (a) { control.alpha = a; }
+ color: control.color
- Layout.fillWidth: true
Layout.leftMargin: 12
Layout.rightMargin: 12
Layout.bottomMargin: 12
@@ -243,6 +223,10 @@ ColorDialogImpl {
}
}
+ Item {
+ Layout.fillWidth: true
+ }
+
DialogButtonBox {
id: buttonBox
standardButtons: control.standardButtons
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Material/FileDialog.qml b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Material/FileDialog.qml
index 73c9cea704..cd2c513c2e 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Material/FileDialog.qml
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Material/FileDialog.qml
@@ -36,6 +36,8 @@ FileDialogImpl {
FileDialogImpl.nameFiltersComboBox: nameFiltersComboBox
FileDialogImpl.fileDialogListView: fileDialogListView
FileDialogImpl.breadcrumbBar: breadcrumbBar
+ FileDialogImpl.fileNameLabel: fileNameLabel
+ FileDialogImpl.fileNameTextField: fileNameTextField
background: Rectangle {
implicitWidth: 600
@@ -98,15 +100,46 @@ FileDialogImpl {
}
}
- footer: RowLayout {
- id: rowLayout
- spacing: 20
+ footer: GridLayout {
+ columnSpacing: 20
+ columns: 3
+
+ Label {
+ id: fileNameLabel
+ text: qsTr("File name")
+ visible: false
+
+ Layout.topMargin: 12
+ Layout.leftMargin: 20
+ }
+
+ TextField {
+ id: fileNameTextField
+ objectName: "fileNameTextField"
+ text: control.fileName
+ visible: false
+
+ Layout.topMargin: 12
+ Layout.fillWidth: true
+ }
+
+ Label {
+ text: qsTr("Filter")
+
+ Layout.row: 1
+ Layout.topMargin: fileNameTextField.visible ? 0 : 12
+ Layout.leftMargin: 20
+ }
ComboBox {
id: nameFiltersComboBox
model: control.nameFilters
+ flat: true
- Layout.leftMargin: 20
+ verticalPadding: 0
+ topInset: 0
+ bottomInset: 0
+ Layout.topMargin: fileNameTextField.visible ? 0 : 12
Layout.fillWidth: true
}
@@ -114,9 +147,13 @@ FileDialogImpl {
id: buttonBox
standardButtons: control.standardButtons
spacing: 12
- horizontalPadding: 0
- verticalPadding: 20
+ padding: 0
+ topInset: 0
+ bottomInset: 0
+ Layout.row: 1
+ Layout.column: 2
+ Layout.topMargin: fileNameTextField.visible ? 0 : 12
Layout.rightMargin: 20
}
}
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Universal/ColorDialog.qml b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Universal/ColorDialog.qml
index 932c0baadc..f3ef9fe2e5 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Universal/ColorDialog.qml
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Universal/ColorDialog.qml
@@ -33,6 +33,7 @@ ColorDialogImpl {
ColorDialogImpl.buttonBox: buttonBox
ColorDialogImpl.colorPicker: colorPicker
ColorDialogImpl.alphaSlider: alphaSlider
+ ColorDialogImpl.colorInputs: inputs
background: Rectangle {
implicitWidth: 200
@@ -130,7 +131,6 @@ ColorDialogImpl {
Slider {
id: alphaSlider
objectName: "alphaSlider"
- visible: control.showAlpha
orientation: Qt.Horizontal
value: control.alpha
implicitHeight: 20
@@ -188,28 +188,8 @@ ColorDialogImpl {
ColorInputs {
id: inputs
- spacing: 12
- currentColor: control.color
- red: control.red
- green: control.green
- blue: control.blue
- hue: control.hue
- saturation: control.saturation
- value: control.value
- lightness: control.lightness
- alpha: control.alpha
- showAlpha: control.showAlpha
- onEmitHex: function (hex) { control.color = hex; }
- onEmitRed: function (r) { control.red = r; }
- onEmitGreen: function (g) { control.green = g; }
- onEmitBlue: function (b) { control.blue = b; }
- onEmitHue: function (h) { control.hue = h; }
- onEmitSaturation: function (s) { control.saturation = s; }
- onEmitValue: function(v) { control.value = v; }
- onEmitLightness: function (l) { control.lightness = l; }
- onEmitAlpha: function (a) { control.alpha = a; }
+ color: control.color
- Layout.fillWidth: true
Layout.leftMargin: 12
Layout.rightMargin: 12
Layout.bottomMargin: 12
@@ -251,6 +231,10 @@ ColorDialogImpl {
Layout.bottomMargin: 24
}
+ Item {
+ Layout.fillWidth: true
+ }
+
DialogButtonBox {
id: buttonBox
standardButtons: control.standardButtons
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Universal/FileDialog.qml b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Universal/FileDialog.qml
index a22d7884e6..c029b06293 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qml/+Universal/FileDialog.qml
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qml/+Universal/FileDialog.qml
@@ -34,6 +34,8 @@ FileDialogImpl {
FileDialogImpl.nameFiltersComboBox: nameFiltersComboBox
FileDialogImpl.fileDialogListView: fileDialogListView
FileDialogImpl.breadcrumbBar: breadcrumbBar
+ FileDialogImpl.fileNameLabel: fileNameLabel
+ FileDialogImpl.fileNameTextField: fileNameTextField
background: Rectangle {
implicitWidth: 600
@@ -100,15 +102,40 @@ FileDialogImpl {
}
}
- footer: RowLayout {
- id: rowLayout
- spacing: 24
+ footer: GridLayout {
+ columnSpacing: 24
+ columns: 3
+
+ Label {
+ id: fileNameLabel
+ text: qsTr("File name")
+ visible: false
+
+ Layout.leftMargin: 24
+ }
+
+ TextField {
+ id: fileNameTextField
+ objectName: "fileNameTextField"
+ text: control.fileName
+ visible: false
+
+ Layout.fillWidth: true
+ }
+
+ Label {
+ text: qsTr("Filter")
+
+ Layout.row: 1
+ Layout.column: 0
+ Layout.leftMargin: 24
+ Layout.bottomMargin: 24
+ }
ComboBox {
id: nameFiltersComboBox
model: control.nameFilters
- Layout.leftMargin: 24
Layout.fillWidth: true
Layout.topMargin: 6
Layout.bottomMargin: 24
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qml/ColorDialog.qml b/src/quickdialogs2/quickdialogs2quickimpl/qml/ColorDialog.qml
index 24b75b0add..c8395bacd0 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qml/ColorDialog.qml
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qml/ColorDialog.qml
@@ -37,6 +37,7 @@ ColorDialogImpl {
ColorDialogImpl.eyeDropperButton: eyeDropperButton
ColorDialogImpl.buttonBox: buttonBox
ColorDialogImpl.colorPicker: colorPicker
+ ColorDialogImpl.colorInputs: inputs
ColorDialogImpl.alphaSlider: alphaSlider
background: Rectangle {
@@ -128,7 +129,6 @@ ColorDialogImpl {
Slider {
id: alphaSlider
objectName: "alphaSlider"
- visible: control.showAlpha
orientation: Qt.Horizontal
value: control.alpha
implicitHeight: 20
@@ -186,26 +186,7 @@ ColorDialogImpl {
ColorInputs {
id: inputs
- spacing: 12
- currentColor: control.color
- red: control.red
- green: control.green
- blue: control.blue
- hue: control.hue
- saturation: control.saturation
- value: control.value
- lightness: control.lightness
- alpha: control.alpha
- showAlpha: control.showAlpha
- onEmitHex: function (hex) { control.color = hex; }
- onEmitRed: function (r) { control.red = r; }
- onEmitGreen: function (g) { control.green = g; }
- onEmitBlue: function (b) { control.blue = b; }
- onEmitHue: function (h) { control.hue = h; }
- onEmitSaturation: function (s) { control.saturation = s; }
- onEmitValue: function(v) { control.value = v; }
- onEmitLightness: function (l) { control.lightness = l; }
- onEmitAlpha: function (a) { control.alpha = a; }
+ color: control.color
Layout.fillWidth: true
Layout.leftMargin: 12
@@ -252,6 +233,11 @@ ColorDialogImpl {
}
}
+ Item {
+ // empty space filler
+ Layout.fillWidth: true
+ }
+
DialogButtonBox {
id: buttonBox
standardButtons: control.standardButtons
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qml/ColorInputs.qml b/src/quickdialogs2/quickdialogs2quickimpl/qml/ColorInputs.qml
index 1fc4d90e2d..42086629ff 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qml/ColorInputs.qml
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qml/ColorInputs.qml
@@ -4,269 +4,221 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
+import QtQuick.Dialogs.quickimpl
-RowLayout {
+ColorInputsImpl {
id: root
- required property color currentColor
- required property real red
- required property real green
- required property real blue
- required property real hue
- required property real saturation
- required property real value
- required property real lightness
- required property real alpha
- property bool showAlpha
- property alias currentIndex: colorSystemComboBox.currentIndex
- signal emitHex(string hex)
- signal emitRed(int r)
- signal emitGreen(int g)
- signal emitBlue(int b)
- signal emitHue(real h)
- signal emitSaturation(real s)
- signal emitValue(real v)
- signal emitLightness(real l)
- signal emitAlpha(real a)
- ComboBox {
- id: colorSystemComboBox
- objectName: "colorSystemComboBox"
- editable: false
- flat: true
- background.implicitWidth: 0
- implicitContentWidthPolicy: ComboBox.WidestText
- model: ListModel {
- ListElement {
- name: qsTr("Hex")
- }
- ListElement {
- name: qsTr("RGB")
- }
- ListElement {
- name: qsTr("HSV")
- }
- ListElement {
- name: qsTr("HSL")
- }
- }
+ hexInput: hex
+ redInput: rgbRed
+ greenInput: rgbGreen
+ blueInput: rgbBlue
+ rgbAlphaInput: rgbAlpha
+ hsvHueInput: hsvHue
+ hsvSaturationInput: hsvSaturation
+ valueInput: hsvValue
+ hsvAlphaInput: hsvAlpha
+ hslHueInput: hslHue
+ hslSaturationInput: hslSaturation
+ lightnessInput: hslLightness
+ hslAlphaInput: hslAlpha
+
+ implicitWidth: content.implicitWidth
+ implicitHeight: content.implicitHeight
+
+ TextMetrics {
+ id: fourM
+ text: "MMMM"
+ font: colorSystemComboBox.font
}
- StackLayout {
- objectName: "colorParameters"
- currentIndex: colorSystemComboBox.currentIndex
-
- Layout.fillWidth: true
- Layout.fillHeight: false
- TextField {
- horizontalAlignment: Qt.AlignHCenter
- text: root.currentColor
- selectByMouse: true
- maximumLength: 9
- validator: RegularExpressionValidator {
- regularExpression: /^#[0-9A-f]{6}(?:[0-9A-f]{2})?$/
- }
- onEditingFinished: function() {
- root.emitHex(text)
- }
- }
+ RowLayout {
+ id: content
+ anchors.fill: parent
+ spacing: 12
- RowLayout {
- Layout.fillWidth: true
-
- TextField {
- horizontalAlignment: Qt.AlignHCenter
- text: root.red
- maximumLength: 3
- validator: IntValidator {
- bottom: 0
- top: 999
+ ComboBox {
+ id: colorSystemComboBox
+ objectName: "colorSystemComboBox"
+ editable: false
+ flat: true
+ background.implicitWidth: 0
+ implicitContentWidthPolicy: ComboBox.WidestTextWhenCompleted
+ implicitWidth: implicitContentWidth + leftPadding + rightPadding // Workaround QTBUG-106098
+ model: ListModel {
+ ListElement {
+ name: qsTr("Hex")
}
-
- Layout.preferredWidth: 1
- Layout.fillWidth: true
-
- onEditingFinished: function() {
- root.emitRed(Math.max(Math.min(parseInt(text), 255), 0))
+ ListElement {
+ name: qsTr("RGB")
}
- }
- TextField {
- horizontalAlignment: Qt.AlignHCenter
- text: root.green
- maximumLength: 3
- validator: IntValidator {
- bottom: 0
- top: 999
+ ListElement {
+ name: qsTr("HSV")
}
-
- Layout.preferredWidth: 1
- Layout.fillWidth: true
-
- onEditingFinished: function() {
- root.emitGreen(Math.max(Math.min(parseInt(text), 255), 0))
- }
- }
- TextField {
- horizontalAlignment: Qt.AlignHCenter
- text: root.blue
- maximumLength: 3
- validator: IntValidator {
- bottom: 0
- top: 999
- }
-
- Layout.preferredWidth: 1
- Layout.fillWidth: true
-
- onEditingFinished: function() {
- root.emitBlue(Math.max(Math.min(parseInt(text), 255), 0))
- }
- }
- TextField {
- visible: root.showAlpha
- horizontalAlignment: Qt.AlignHCenter
- text: Math.round(root.alpha * 100).toString() + "%"
- maximumLength: 4
- validator: RegularExpressionValidator {
- regularExpression: /^[0-9]{0,3}%?$/
- }
-
- Layout.preferredWidth: 1
- Layout.fillWidth: true
-
- onEditingFinished: function() {
- root.emitAlpha(Math.max(Math.min(text.match(/^(\d+)%?$/)[1], 100), 0) / 100.0)
+ ListElement {
+ name: qsTr("HSL")
}
}
}
- RowLayout {
- Layout.fillWidth: true
-
- TextField {
- horizontalAlignment: Qt.AlignHCenter
- text: Math.round(root.hue === -1.0 ? 0 : control.hue * 360).toString() + "°"
- maximumLength: 4
- validator: RegularExpressionValidator {
- regularExpression: /^[0-9]{0,3}°?$/
- }
-
- Layout.preferredWidth: 1
- Layout.fillWidth: true
-
- onEditingFinished: function() {
- root.emitHue(Math.max(Math.min(text.match(/^(\d+)°?$/)[1], 360), 0) / 360.0)
- }
- }
- TextField {
- horizontalAlignment: Qt.AlignHCenter
- text: Math.round(root.saturation * 100).toString() + "%"
- maximumLength: 4
- validator: RegularExpressionValidator {
- regularExpression: /^[0-9]{0,3}%?$/
- }
-
- Layout.preferredWidth: 1
- Layout.fillWidth: true
-
- onEditingFinished: function() {
- root.emitSaturation(Math.max(Math.min(text.match(/^(\d+)%?$/)[1], 100), 0) / 100.0)
- }
- }
- TextField {
- horizontalAlignment: Qt.AlignHCenter
- text: Math.round(root.value * 100).toString() + "%"
- maximumLength: 4
- validator: RegularExpressionValidator {
- regularExpression: /^[0-9]{0,3}%?$/
- }
-
- Layout.preferredWidth: 1
- Layout.fillWidth: true
-
- onEditingFinished: function() {
- root.emitValue(Math.max(Math.min(text.match(/^(\d+)%?$/)[1], 100), 0) / 100.0)
- }
- }
- TextField {
- visible: root.showAlpha
- horizontalAlignment: Qt.AlignHCenter
- text: Math.round(root.alpha * 100).toString() + "%"
- maximumLength: 4
- validator: RegularExpressionValidator {
- regularExpression: /^[0-9]{0,3}%?$/
- }
-
- Layout.preferredWidth: 1
- Layout.fillWidth: true
-
- onEditingFinished: function() {
- root.emitAlpha(Math.max(Math.min(text.match(/^(\d+)%?$/)[1], 100), 0) / 100.0)
- }
- }
- }
+ StackLayout {
+ objectName: "colorParameters"
+ currentIndex: colorSystemComboBox.currentIndex
- RowLayout {
Layout.fillWidth: true
TextField {
- horizontalAlignment: Qt.AlignHCenter
- text: Math.round(root.hue === -1.0 ? 0 : control.hue * 360).toString() + "°"
- maximumLength: 4
+ id: hex
+ horizontalAlignment: Qt.AlignLeft
+ text: root.color
+ maximumLength: 9
validator: RegularExpressionValidator {
- regularExpression: /^[0-9]{0,3}°?$/
+ regularExpression: root.showAlpha ? /^#[0-9A-f]{6}(?:[0-9A-f]{2})?$/ : /^#[0-9A-f]{6}$/
}
-
- Layout.preferredWidth: 1
Layout.fillWidth: true
-
- onEditingFinished: function() {
- root.emitHue(Math.max(Math.min(text.match(/^(\d+)°?$/)[1], 360), 0) / 360.0)
- }
- }
- TextField {
- horizontalAlignment: Qt.AlignHCenter
- text: Math.round(root.saturation * 100).toString() + "%"
- maximumLength: 4
- validator: RegularExpressionValidator {
- regularExpression: /^[0-9]{0,3}%?$/
- }
-
- Layout.preferredWidth: 1
- Layout.fillWidth: true
-
- onEditingFinished: function() {
- root.emitSaturation(Math.max(Math.min(text.match(/^(\d+)%?$/)[1], 100), 0) / 100.0)
- }
}
- TextField {
- horizontalAlignment: Qt.AlignHCenter
- text: Math.round(root.lightness * 100).toString() + "%"
- maximumLength: 4
- validator: RegularExpressionValidator {
- regularExpression: /^[0-9]{0,3}%?$/
- }
-
- Layout.preferredWidth: 1
- Layout.fillWidth: true
-
- onEditingFinished: function() {
- root.emitLightness(Math.max(Math.min(text.match(/^(\d+)%?$/)[1], 100), 0) / 100.0)
- }
- }
- TextField {
- visible: root.showAlpha
- horizontalAlignment: Qt.AlignHCenter
- text: Math.round(root.alpha * 100).toString() + "%"
- maximumLength: 4
- validator: RegularExpressionValidator {
- regularExpression: /^[0-9]{0,3}%?$/
- }
-
- Layout.preferredWidth: 1
- Layout.fillWidth: true
- onEditingFinished: function() {
- root.emitAlpha(Math.max(Math.min(text.match(/^(\d+)%?$/)[1], 100), 0) / 100.0)
+ RowLayout {
+ TextField {
+ id: rgbRed
+ horizontalAlignment: Qt.AlignHCenter
+ text: root.red
+ maximumLength: 3
+ validator: IntValidator {
+ bottom: 0
+ top: 999
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
+ }
+ TextField {
+ id: rgbGreen
+ horizontalAlignment: Qt.AlignHCenter
+ text: root.green
+ maximumLength: 3
+ validator: IntValidator {
+ bottom: 0
+ top: 999
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
+ }
+ TextField {
+ id: rgbBlue
+ horizontalAlignment: Qt.AlignHCenter
+ text: root.blue
+ maximumLength: 3
+ validator: IntValidator {
+ bottom: 0
+ top: 999
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
+ }
+ TextField {
+ id: rgbAlpha
+ horizontalAlignment: Qt.AlignHCenter
+ text: Math.round(root.alpha * 100).toString() + "%"
+ maximumLength: 4
+ validator: RegularExpressionValidator {
+ regularExpression: /^[0-9]{0,3}%?$/
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
+ }
+ }
+
+ RowLayout {
+ TextField {
+ id: hsvHue
+ horizontalAlignment: Qt.AlignHCenter
+ text: Math.round(root.hue * 360).toString() + "°"
+ maximumLength: 4
+ validator: RegularExpressionValidator {
+ regularExpression: /^[0-9]{0,3}°?$/
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
+ }
+ TextField {
+ id: hsvSaturation
+ horizontalAlignment: Qt.AlignHCenter
+ text: Math.round(root.hsvSaturation * 100).toString() + "%"
+ maximumLength: 4
+ validator: RegularExpressionValidator {
+ regularExpression: /^[0-9]{0,3}%?$/
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
+ }
+ TextField {
+ id: hsvValue
+ horizontalAlignment: Qt.AlignHCenter
+ text: Math.round(root.value * 100).toString() + "%"
+ maximumLength: 4
+ validator: RegularExpressionValidator {
+ regularExpression: /^[0-9]{0,3}%?$/
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
+ }
+ TextField {
+ id: hsvAlpha
+ horizontalAlignment: Qt.AlignHCenter
+ text: Math.round(root.alpha * 100).toString() + "%"
+ maximumLength: 4
+ validator: RegularExpressionValidator {
+ regularExpression: /^[0-9]{0,3}%?$/
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
+ }
+ }
+
+ RowLayout {
+ TextField {
+ id: hslHue
+ horizontalAlignment: Qt.AlignHCenter
+ text: Math.round(root.hue * 360).toString() + "°"
+ maximumLength: 4
+ validator: RegularExpressionValidator {
+ regularExpression: /^[0-9]{0,3}°?$/
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
+ }
+ TextField {
+ id: hslSaturation
+ horizontalAlignment: Qt.AlignHCenter
+ text: Math.round(root.hslSaturation * 100).toString() + "%"
+ maximumLength: 4
+ validator: RegularExpressionValidator {
+ regularExpression: /^[0-9]{0,3}%?$/
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
+ }
+ TextField {
+ id: hslLightness
+ horizontalAlignment: Qt.AlignHCenter
+ text: Math.round(root.lightness * 100).toString() + "%"
+ maximumLength: 4
+ validator: RegularExpressionValidator {
+ regularExpression: /^[0-9]{0,3}%?$/
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
+ }
+ TextField {
+ id: hslAlpha
+ horizontalAlignment: Qt.AlignHCenter
+ text: Math.round(root.alpha * 100).toString() + "%"
+ maximumLength: 4
+ validator: RegularExpressionValidator {
+ regularExpression: /^[0-9]{0,3}%?$/
+ }
+ implicitWidth: fourM.width + leftPadding + rightPadding
+ Layout.fillWidth: true
}
}
}
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qml/FileDialog.qml b/src/quickdialogs2/quickdialogs2quickimpl/qml/FileDialog.qml
index 75aaa10b74..0f25dee35b 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qml/FileDialog.qml
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qml/FileDialog.qml
@@ -46,6 +46,8 @@ FileDialogImpl {
FileDialogImpl.nameFiltersComboBox: nameFiltersComboBox
FileDialogImpl.fileDialogListView: fileDialogListView
FileDialogImpl.breadcrumbBar: breadcrumbBar
+ FileDialogImpl.fileNameLabel: fileNameLabel
+ FileDialogImpl.fileNameTextField: fileNameTextField
background: Rectangle {
implicitWidth: 600
@@ -110,21 +112,48 @@ FileDialogImpl {
footer: Rectangle {
color: control.palette.light
- implicitWidth: rowLayout.implicitWidth
- implicitHeight: rowLayout.implicitHeight
+ implicitWidth: gridLayout.implicitWidth
+ implicitHeight: gridLayout.implicitHeight + 12
+
+ GridLayout {
+ // OK to use IDs here, since users shouldn't be overriding this stuff.
+ id: gridLayout
+ anchors.fill: parent
+ anchors.topMargin: 6
+ anchors.bottomMargin: 6
+ columnSpacing: 20
+ columns: 3
- RowLayout {
- id: rowLayout
- width: parent.width
- height: parent.height
- spacing: 20
+ Label {
+ id: fileNameLabel
+ text: qsTr("File name")
+ visible: false
+
+ Layout.leftMargin: 20
+ }
+
+ TextField {
+ id: fileNameTextField
+ objectName: "fileNameTextField"
+ text: control.fileName
+ visible: false
+
+ Layout.fillWidth: true
+ }
+
+ Label {
+ text: qsTr("Filter")
+
+ Layout.row: 1
+ Layout.column: 0
+ Layout.leftMargin: 20
+ }
ComboBox {
- // OK to use IDs here, since users shouldn't be overriding this stuff.
id: nameFiltersComboBox
model: control.nameFilters
+ verticalPadding: 0
- Layout.leftMargin: 20
Layout.fillWidth: true
}
@@ -133,9 +162,10 @@ FileDialogImpl {
standardButtons: control.standardButtons
palette.window: control.palette.light
spacing: 12
- horizontalPadding: 0
- verticalPadding: 20
+ padding: 0
+ Layout.row: 1
+ Layout.column: 2
Layout.rightMargin: 20
}
}
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker.cpp b/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker.cpp
index 96742b9ce8..4606c00502 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker.cpp
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker.cpp
@@ -3,16 +3,15 @@
#include "qquickabstractcolorpicker_p_p.h"
+#include "qquickcolordialogutils_p.h"
+
#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
#include <QtQuickTemplates2/private/qquickdeferredexecute_p_p.h>
#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
-QQuickAbstractColorPickerPrivate::QQuickAbstractColorPickerPrivate()
- : m_pressed(false), m_hsl(false)
-{
-}
+QQuickAbstractColorPickerPrivate::QQuickAbstractColorPickerPrivate() = default;
static inline QString handleName()
{
@@ -25,7 +24,6 @@ bool QQuickAbstractColorPickerPrivate::handlePress(const QPointF &point, ulong t
QQuickControlPrivate::handlePress(point, timestamp);
m_pressPoint = point;
q->setPressed(true);
-
q->updateColor(point);
return true;
}
@@ -111,6 +109,13 @@ QColor QQuickAbstractColorPicker::color() const
void QQuickAbstractColorPicker::setColor(const QColor &c)
{
Q_D(QQuickAbstractColorPicker);
+ // QColor represents a theoretical color, rather than simply an rgba value.
+ // Therefore, two QColor objects can be different,
+ // and yet translate to the same rgba value.
+ // Since the color picker can reuse the same rgba value for multiple pixels,
+ // we should not return early if the rgba() values are equal,
+ // but only if the QColor objects are exactly the same.
+
if (color() == c)
return;
@@ -352,24 +357,3 @@ void QQuickAbstractColorPicker::updateColor(const QPointF &pos)
emit colorPicked(c);
}
-
-std::pair<qreal, qreal> QQuickAbstractColorPicker::getSaturationAndValue(qreal saturation,
- qreal lightness)
-{
- const qreal v = lightness + saturation * qMin(lightness, 1 - lightness);
- if (v == .0)
- return { .0, .0 };
-
- const qreal s = 2 * (1 - lightness / v);
- return { s, v };
-}
-std::pair<qreal, qreal> QQuickAbstractColorPicker::getSaturationAndLightness(qreal saturation,
- qreal value)
-{
- const qreal l = value * (1 - saturation / 2);
- if (l == .0)
- return { .0, .0 };
-
- const qreal s = (value - l) / qMin(l, 1 - l);
- return { s, l };
-}
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker_p.h b/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker_p.h
index 6138581d4e..b29e488b3a 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker_p.h
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker_p.h
@@ -87,8 +87,6 @@ protected:
private:
void updateColor(const QPointF &pos);
- static std::pair<qreal, qreal> getSaturationAndValue(qreal saturation, qreal lightness);
- static std::pair<qreal, qreal> getSaturationAndLightness(qreal saturation, qreal value);
Q_DISABLE_COPY(QQuickAbstractColorPicker)
Q_DECLARE_PRIVATE(QQuickAbstractColorPicker)
};
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker_p_p.h b/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker_p_p.h
index eb93cbab07..73878a1cc0 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker_p_p.h
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickabstractcolorpicker_p_p.h
@@ -19,6 +19,7 @@
#include <QtQuickTemplates2/private/qquickdeferredexecute_p_p.h>
#include "qquickabstractcolorpicker_p.h"
+#include "qquickcolordialogutils_p.h"
QT_BEGIN_NAMESPACE
@@ -45,22 +46,13 @@ public:
void itemImplicitWidthChanged(QQuickItem *item) override;
void itemImplicitHeightChanged(QQuickItem *item) override;
- struct
- {
- qreal h = .0;
- qreal s = .0;
- union {
- qreal v = 1.0;
- qreal l;
- };
- qreal a = 1.0;
- } m_hsva;
+ HSVA m_hsva;
QPointF m_pressPoint;
QQuickDeferredPointer<QQuickItem> m_handle;
- bool m_pressed : 1;
+ bool m_pressed = false;
protected:
- bool m_hsl : 1; // Use hsv by default.
+ bool m_hsl = false; // Use hsv by default.
};
QT_END_NAMESPACE
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl.cpp b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl.cpp
index f26b90570c..6f13403766 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl.cpp
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl.cpp
@@ -4,6 +4,8 @@
#include "qquickcolordialogimpl_p.h"
#include "qquickcolordialogimpl_p_p.h"
+#include "qquickcolordialogutils_p.h"
+
#include <QtQuickTemplates2/private/qquickslider_p.h>
#include <qpa/qplatformintegration.h>
@@ -58,8 +60,7 @@ bool QQuickEyeDropperEventFilter::eventFilter(QObject *obj, QEvent *event)
}
}
-QQuickColorDialogImplPrivate::QQuickColorDialogImplPrivate()
-{}
+QQuickColorDialogImplPrivate::QQuickColorDialogImplPrivate() = default;
QQuickColorDialogImplPrivate::~QQuickColorDialogImplPrivate()
{
@@ -178,13 +179,38 @@ QColor QQuickColorDialogImpl::color() const
void QQuickColorDialogImpl::setColor(const QColor &c)
{
Q_D(QQuickColorDialogImpl);
-
if (color().rgba() == c.rgba())
return;
- d->m_hsva.h = d->m_hsl ? c.hslHueF() : c.hsvHueF();
- d->m_hsva.s = d->m_hsl ? c.hslSaturationF() : c.hsvSaturationF();
- d->m_hsva.v = d->m_hsl ? c.lightnessF() : c.valueF();
+ // If we get a QColor from an Hsv or Hsl color system,
+ // we want to get the raw values without the risk of QColor converting them,
+ // and possible deleting relevant information for achromatic cases.
+ if (c.spec() == QColor::Spec::Hsv) {
+ d->m_hsva.h = qBound(.0, c.hsvHueF(), 1.0);
+ if (d->m_hsl) {
+ const auto sl = getSaturationAndLightness(c.hsvSaturationF(), c.valueF());
+ d->m_hsva.s = qBound(.0, sl.first, 1.0);
+ d->m_hsva.l = qBound(.0, sl.second, 1.0);
+ } else {
+ d->m_hsva.s = qBound(.0, c.hsvSaturationF(), 1.0);
+ d->m_hsva.v = qBound(.0, c.valueF(), 1.0);
+ }
+ } else if (c.spec() == QColor::Spec::Hsl) {
+ d->m_hsva.h = qBound(.0, c.hslHueF(), 1.0);
+ if (d->m_hsl) {
+ d->m_hsva.s = qBound(.0, c.hslSaturationF(), 1.0);
+ d->m_hsva.l = qBound(.0, c.lightnessF(), 1.0);
+ } else {
+ const auto sv = getSaturationAndValue(c.hslSaturationF(), c.lightnessF());
+ d->m_hsva.s = qBound(.0, sv.first, 1.0);
+ d->m_hsva.v = qBound(.0, sv.second, 1.0);
+ }
+ } else {
+ d->m_hsva.h = qBound(.0, d->m_hsl ? c.hslHueF() : c.hsvHueF(), 1.0);
+ d->m_hsva.s = qBound(.0, d->m_hsl ? c.hslSaturationF() : c.hsvSaturationF(), 1.0);
+ d->m_hsva.v = qBound(.0, d->m_hsl ? c.lightnessF() : c.valueF(), 1.0);
+ }
+
d->m_hsva.a = c.alphaF();
emit colorChanged(color());
@@ -379,12 +405,6 @@ void QQuickColorDialogImpl::setHsl(bool hsl)
emit specChanged();
}
-bool QQuickColorDialogImpl::showAlpha()
-{
- Q_D(const QQuickColorDialogImpl);
- return d->m_showAlpha;
-}
-
QSharedPointer<QColorDialogOptions> QQuickColorDialogImpl::options() const
{
Q_D(const QQuickColorDialogImpl);
@@ -406,14 +426,10 @@ void QQuickColorDialogImpl::setOptions(const QSharedPointer<QColorDialogOptions>
if (d->options) {
attached->buttonBox()->setVisible(
!(d->options->options() & QColorDialogOptions::NoButtons));
- }
- }
- if (d->options) {
- const bool showAlpha = d->options->options() & QColorDialogOptions::ShowAlphaChannel;
- if (showAlpha != d->m_showAlpha) {
- d->m_showAlpha = showAlpha;
- emit showAlphaChanged();
+ const bool showAlpha = d->options->options() & QColorDialogOptions::ShowAlphaChannel;
+ attached->alphaSlider()->setVisible(showAlpha);
+ attached->colorInputs()->setShowAlpha(showAlpha);
}
}
}
@@ -424,25 +440,6 @@ void QQuickColorDialogImpl::invokeEyeDropper()
d->eyeDropperEnter();
}
-std::pair<qreal, qreal> QQuickColorDialogImpl::getSaturationAndValue(qreal saturation,
- qreal lightness)
-{
- const qreal v = lightness + saturation * qMin(lightness, 1 - lightness);
- if (v == .0)
- return { .0, .0 };
- const qreal s = 2 * (1 - lightness / v);
- return { s, v };
-}
-std::pair<qreal, qreal> QQuickColorDialogImpl::getSaturationAndLightness(qreal saturation,
- qreal value)
-{
- const qreal l = value * (1 - saturation / 2);
- if (l == .0)
- return { .0, .0 };
- const qreal s = (value - l) / qMin(l, 1 - l);
- return { s, l };
-}
-
QQuickColorDialogImplAttached::QQuickColorDialogImplAttached(QObject *parent)
: QObject(*(new QQuickColorDialogImplAttachedPrivate), parent)
{
@@ -581,4 +578,36 @@ void QQuickColorDialogImplAttached::setAlphaSlider(QQuickSlider *alphaSlider)
emit alphaSliderChanged();
}
+QQuickColorInputs *QQuickColorDialogImplAttached::colorInputs() const
+{
+ Q_D(const QQuickColorDialogImplAttached);
+ return d->colorInputs;
+}
+
+void QQuickColorDialogImplAttached::setColorInputs(QQuickColorInputs *colorInputs)
+{
+ Q_D(QQuickColorDialogImplAttached);
+
+ if (d->colorInputs == colorInputs)
+ return;
+
+ if (d->colorInputs) {
+ QQuickColorDialogImpl *colorDialogImpl = qobject_cast<QQuickColorDialogImpl *>(parent());
+ if (colorDialogImpl)
+ QObject::disconnect(d->colorInputs, &QQuickColorInputs::colorModified,
+ colorDialogImpl, &QQuickColorDialogImpl::setColor);
+ }
+
+ d->colorInputs = colorInputs;
+
+ if (d->colorInputs) {
+ QQuickColorDialogImpl *colorDialogImpl = qobject_cast<QQuickColorDialogImpl *>(parent());
+ if (colorDialogImpl)
+ QObject::connect(d->colorInputs, &QQuickColorInputs::colorModified,
+ colorDialogImpl, &QQuickColorDialogImpl::setColor);
+ }
+
+ emit colorInputsChanged();
+}
+
QT_END_NAMESPACE
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl_p.h b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl_p.h
index d5c81372ba..110298b5f2 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl_p.h
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl_p.h
@@ -23,6 +23,7 @@ QT_BEGIN_NAMESPACE
class QQuickDialogButtonBox;
class QQuickAbstractColorPicker;
+class QQuickColorInputs;
class QQuickSlider;
class QQuickColorDialogImplAttached;
@@ -42,7 +43,6 @@ class Q_QUICKDIALOGS2QUICKIMPL_PRIVATE_EXPORT QQuickColorDialogImpl : public QQu
Q_PROPERTY(int green READ green WRITE setGreen NOTIFY colorChanged FINAL)
Q_PROPERTY(int blue READ blue WRITE setBlue NOTIFY colorChanged FINAL)
Q_PROPERTY(bool isHsl READ isHsl WRITE setHsl NOTIFY specChanged FINAL)
- Q_PROPERTY(bool showAlpha READ showAlpha NOTIFY showAlphaChanged)
QML_NAMED_ELEMENT(ColorDialogImpl)
QML_ATTACHED(QQuickColorDialogImplAttached)
QML_ADDED_IN_VERSION(6, 4)
@@ -85,18 +85,13 @@ public:
bool isHsl() const;
void setHsl(bool hsl);
- bool showAlpha();
-
Q_INVOKABLE void invokeEyeDropper();
Q_SIGNALS:
void colorChanged(const QColor &color);
void specChanged();
- void showAlphaChanged();
private:
- static std::pair<qreal, qreal> getSaturationAndValue(qreal saturation, qreal lightness);
- static std::pair<qreal, qreal> getSaturationAndLightness(qreal saturation, qreal value);
Q_DISABLE_COPY(QQuickColorDialogImpl)
Q_DECLARE_PRIVATE(QQuickColorDialogImpl)
};
@@ -106,12 +101,17 @@ class Q_QUICKDIALOGS2QUICKIMPL_PRIVATE_EXPORT QQuickColorDialogImplAttached : pu
Q_OBJECT
Q_PROPERTY(QQuickDialogButtonBox *buttonBox READ buttonBox WRITE setButtonBox NOTIFY buttonBoxChanged FINAL)
Q_PROPERTY(QQuickAbstractButton *eyeDropperButton READ eyeDropperButton WRITE setEyeDropperButton NOTIFY eyeDropperButtonChanged FINAL)
- Q_PROPERTY(QQuickAbstractColorPicker *colorPicker READ colorPicker WRITE setColorPicker NOTIFY colorPickerChanged)
- Q_PROPERTY(QQuickSlider *alphaSlider READ alphaSlider WRITE setAlphaSlider NOTIFY alphaSliderChanged)
+ Q_PROPERTY(QQuickAbstractColorPicker *colorPicker READ colorPicker WRITE setColorPicker NOTIFY
+ colorPickerChanged FINAL)
+ Q_PROPERTY(QQuickColorInputs *colorInputs READ colorInputs WRITE setColorInputs NOTIFY
+ colorInputsChanged FINAL)
+ Q_PROPERTY(QQuickSlider *alphaSlider READ alphaSlider WRITE setAlphaSlider NOTIFY
+ alphaSliderChanged FINAL)
Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquickdialogbuttonbox_p.h>)
Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquickabstractbutton_p.h>)
Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquickslider_p.h>)
Q_MOC_INCLUDE("qquickabstractcolorpicker_p.h")
+ Q_MOC_INCLUDE("qquickcolorinputs_p.h")
public:
explicit QQuickColorDialogImplAttached(QObject *parent = nullptr);
@@ -125,6 +125,9 @@ public:
QQuickAbstractColorPicker *colorPicker() const;
void setColorPicker(QQuickAbstractColorPicker *colorPicker);
+ QQuickColorInputs *colorInputs() const;
+ void setColorInputs(QQuickColorInputs *colorInputs);
+
QQuickSlider *alphaSlider() const;
void setAlphaSlider(QQuickSlider *alphaSlider);
@@ -132,6 +135,7 @@ Q_SIGNALS:
void buttonBoxChanged();
void eyeDropperButtonChanged();
void colorPickerChanged();
+ void colorInputsChanged();
void alphaSliderChanged();
private:
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl_p_p.h b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl_p_p.h
index 5349fb7da4..b7c4dc8e2c 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl_p_p.h
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogimpl_p_p.h
@@ -17,6 +17,7 @@
#include "qquickcolordialogimpl_p.h"
#include "qquickabstractcolorpicker_p.h"
+#include "qquickcolorinputs_p.h"
#include <QtQuickTemplates2/private/qquickdialog_p_p.h>
#include <QtQuickTemplates2/private/qquickdialogbuttonbox_p.h>
@@ -69,16 +70,7 @@ public:
void alphaSliderMoved();
QSharedPointer<QColorDialogOptions> options;
- struct
- {
- qreal h = .0;
- qreal s = .0;
- union {
- qreal v = 1.0;
- qreal l;
- };
- qreal a = 1.0;
- } m_hsva;
+ HSVA m_hsva;
std::unique_ptr<QQuickEyeDropperEventFilter> eyeDropperEventFilter;
QPointer<QQuickWindow> m_eyeDropperWindow;
QColor m_eyeDropperPreviousColor;
@@ -92,6 +84,7 @@ class QQuickColorDialogImplAttachedPrivate : public QObjectPrivate
public:
QPointer<QQuickDialogButtonBox> buttonBox;
QPointer<QQuickAbstractButton> eyeDropperButton;
+ QPointer<QQuickColorInputs> colorInputs;
QPointer<QQuickAbstractColorPicker> colorPicker;
QPointer<QQuickSlider> alphaSlider;
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogutils.cpp b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogutils.cpp
new file mode 100644
index 0000000000..0a123f84a6
--- /dev/null
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogutils.cpp
@@ -0,0 +1,24 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qquickcolordialogutils_p.h"
+
+std::pair<qreal, qreal> getSaturationAndValue(qreal saturation, qreal lightness)
+{
+ const qreal v = lightness + saturation * qMin(lightness, 1 - lightness);
+ if (v == .0)
+ return { .0, .0 };
+ const qreal s = 2 * (1 - lightness / v);
+ return { s, v };
+}
+
+std::pair<qreal, qreal> getSaturationAndLightness(qreal saturation, qreal value)
+{
+ const qreal l = value * (1 - saturation / 2);
+ if (l == .0)
+ return { .0, .0 };
+ if (l == 1 && value == 1)
+ return { saturation, l };
+ const qreal s = (value - l) / qMin(l, 1 - l);
+ return { s, l };
+}
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogutils_p.h b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogutils_p.h
new file mode 100644
index 0000000000..6b5c2e026c
--- /dev/null
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolordialogutils_p.h
@@ -0,0 +1,36 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QQUICKCOLORDIALOGUTILS_P_H
+#define QQUICKCOLORDIALOGUTILS_P_H
+
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/QtGlobal>
+
+std::pair<qreal, qreal> getSaturationAndValue(qreal saturation, qreal lightness);
+
+std::pair<qreal, qreal> getSaturationAndLightness(qreal saturation, qreal value);
+
+struct HSVA
+{
+ qreal h = .0;
+ qreal s = .0;
+ union {
+ qreal v = 1.0;
+ qreal l;
+ };
+ qreal a = 1.0;
+};
+
+#endif // QQUICKCOLORDIALOGUTILS_P_H
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickcolorinputs.cpp b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolorinputs.cpp
new file mode 100644
index 0000000000..cc3743c494
--- /dev/null
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolorinputs.cpp
@@ -0,0 +1,509 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qquickcolorinputs_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQuickColorInputs::QQuickColorInputs() = default;
+
+QColor QQuickColorInputs::color() const
+{
+ return QColor::fromHsvF(m_hsva.h, m_hsva.s, m_hsva.v, m_hsva.a);
+}
+
+void QQuickColorInputs::setColor(const QColor &c)
+{
+ if (color().rgba() == c.rgba())
+ return;
+
+ // If we get a QColor from an Hsv or Hsl color system,
+ // we want to get the raw values without the risk of QColor converting them,
+ // and possible deleting relevant information for achromatic cases.
+ if (c.spec() == QColor::Spec::Hsl) {
+ const auto sv = getSaturationAndValue(c.hslSaturationF(), c.lightnessF());
+ m_hsva.h = qBound(.0, c.hslHueF(), 1.0);
+ m_hsva.s = qBound(.0, sv.first, 1.0);
+ m_hsva.v = qBound(.0, sv.second, 1.0);
+ } else {
+ m_hsva.h = qBound(.0, c.hsvHueF(), 1.0);
+ m_hsva.s = qBound(.0, c.hsvSaturationF(), 1.0);
+ m_hsva.v = qBound(.0, c.valueF(), 1.0);
+ }
+
+ m_hsva.a = c.alphaF();
+
+ emit colorChanged(color());
+}
+
+int QQuickColorInputs::red() const
+{
+ return color().red();
+}
+
+int QQuickColorInputs::green() const
+{
+ return color().green();
+}
+
+int QQuickColorInputs::blue() const
+{
+ return color().blue();
+}
+
+qreal QQuickColorInputs::alpha() const
+{
+ return m_hsva.a;
+}
+
+qreal QQuickColorInputs::hue() const
+{
+ return m_hsva.h;
+}
+
+qreal QQuickColorInputs::hslSaturation() const
+{
+ return getSaturationAndLightness(m_hsva.s, m_hsva.v).first;
+}
+
+qreal QQuickColorInputs::hsvSaturation() const
+{
+ return m_hsva.s;
+}
+
+qreal QQuickColorInputs::value() const
+{
+ return m_hsva.v;
+}
+
+qreal QQuickColorInputs::lightness() const
+{
+ return getSaturationAndLightness(m_hsva.s, m_hsva.v).second;
+}
+
+bool QQuickColorInputs::showAlpha() const
+{
+ return m_showAlpha;
+}
+
+void QQuickColorInputs::setShowAlpha(bool showAlpha)
+{
+ if (m_showAlpha == showAlpha)
+ return;
+
+ m_showAlpha = showAlpha;
+ emit showAlphaChanged(m_showAlpha);
+}
+
+QQuickTextInput *QQuickColorInputs::hexInput() const
+{
+ return m_hexInput;
+}
+
+void QQuickColorInputs::setHexInput(QQuickTextInput *hexInput)
+{
+ if (m_hexInput == hexInput)
+ return;
+
+ if (m_hexInput)
+ disconnect(m_hexInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHexChanged);
+
+ m_hexInput = hexInput;
+
+ if (m_hexInput)
+ connect(m_hexInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHexChanged);
+
+ emit hexInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::redInput() const
+{
+ return m_redInput;
+}
+
+void QQuickColorInputs::setRedInput(QQuickTextInput *redInput)
+{
+ if (m_redInput == redInput)
+ return;
+
+ if (m_redInput)
+ disconnect(m_redInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleRedChanged);
+
+ m_redInput = redInput;
+
+ if (m_redInput)
+ connect(m_redInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleRedChanged);
+
+ emit redInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::greenInput() const
+{
+ return m_greenInput;
+}
+
+void QQuickColorInputs::setGreenInput(QQuickTextInput *greenInput)
+{
+ if (m_greenInput == greenInput)
+ return;
+
+ if (m_greenInput)
+ disconnect(m_greenInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleGreenChanged);
+
+ m_greenInput = greenInput;
+
+ if (m_greenInput)
+ connect(m_greenInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleGreenChanged);
+
+ emit greenInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::blueInput() const
+{
+ return m_blueInput;
+}
+
+void QQuickColorInputs::setBlueInput(QQuickTextInput *blueInput)
+{
+ if (m_blueInput == blueInput)
+ return;
+
+ if (m_blueInput)
+ disconnect(m_blueInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleBlueChanged);
+
+ m_blueInput = blueInput;
+
+ if (m_blueInput)
+ connect(m_blueInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleBlueChanged);
+
+ emit blueInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::hsvHueInput() const
+{
+ return m_hsvHueInput;
+}
+
+void QQuickColorInputs::setHsvHueInput(QQuickTextInput *hsvHueInput)
+{
+ if (m_hsvHueInput == hsvHueInput)
+ return;
+
+ if (m_hsvHueInput)
+ disconnect(m_hsvHueInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHsvHueChanged);
+
+ m_hsvHueInput = hsvHueInput;
+
+ if (m_hsvHueInput)
+ connect(m_hsvHueInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHsvHueChanged);
+
+ emit hsvHueInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::hslHueInput() const
+{
+ return m_hslHueInput;
+}
+
+void QQuickColorInputs::setHslHueInput(QQuickTextInput *hslHueInput)
+{
+ if (m_hslHueInput == hslHueInput)
+ return;
+
+ if (m_hslHueInput)
+ disconnect(m_hslHueInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHslHueChanged);
+
+ m_hslHueInput = hslHueInput;
+
+ if (m_hslHueInput)
+ connect(m_hslHueInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHslHueChanged);
+
+ emit hslHueInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::hsvSaturationInput() const
+{
+ return m_hsvSaturationInput;
+}
+
+void QQuickColorInputs::setHsvSaturationInput(QQuickTextInput *hsvSaturationInput)
+{
+ if (m_hsvSaturationInput == hsvSaturationInput)
+ return;
+
+ if (m_hsvSaturationInput)
+ disconnect(m_hsvSaturationInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHsvSaturationChanged);
+
+ m_hsvSaturationInput = hsvSaturationInput;
+
+ if (m_hsvSaturationInput)
+ connect(m_hsvSaturationInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHsvSaturationChanged);
+
+ emit hsvSaturationInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::hslSaturationInput() const
+{
+ return m_hslSaturationInput;
+}
+
+void QQuickColorInputs::setHslSaturationInput(QQuickTextInput *hslSaturationInput)
+{
+ if (m_hslSaturationInput == hslSaturationInput)
+ return;
+
+ if (m_hslSaturationInput)
+ disconnect(m_hslSaturationInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHslSaturationChanged);
+
+ m_hslSaturationInput = hslSaturationInput;
+
+ if (m_hslSaturationInput)
+ connect(m_hslSaturationInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHslSaturationChanged);
+
+ emit hslSaturationInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::valueInput() const
+{
+ return m_valueInput;
+}
+
+void QQuickColorInputs::setValueInput(QQuickTextInput *valueInput)
+{
+ if (m_valueInput == valueInput)
+ return;
+
+ if (m_valueInput)
+ disconnect(m_valueInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleValueChanged);
+
+ m_valueInput = valueInput;
+
+ if (m_valueInput)
+ connect(m_valueInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleValueChanged);
+
+ emit valueInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::lightnessInput() const
+{
+ return m_lightnessInput;
+}
+
+void QQuickColorInputs::setLightnessInput(QQuickTextInput *lightnessInput)
+{
+ if (m_lightnessInput == lightnessInput)
+ return;
+
+ if (m_lightnessInput)
+ disconnect(m_lightnessInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleLightnessChanged);
+
+ m_lightnessInput = lightnessInput;
+
+ if (m_lightnessInput)
+ connect(m_lightnessInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleLightnessChanged);
+
+ emit lightnessInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::rgbAlphaInput() const
+{
+ return m_rgbAlphaInput;
+}
+
+void QQuickColorInputs::setRgbAlphaInput(QQuickTextInput *alphaInput)
+{
+ if (alphaInput == m_rgbAlphaInput)
+ return;
+
+ if (m_rgbAlphaInput) {
+ disconnect(m_rgbAlphaInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleRgbAlphaChanged);
+ disconnect(this, &QQuickColorInputs::showAlphaChanged, m_rgbAlphaInput, &QQuickTextInput::setVisible);
+ }
+
+ m_rgbAlphaInput = alphaInput;
+
+ if (m_rgbAlphaInput) {
+ connect(m_rgbAlphaInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleRgbAlphaChanged);
+ connect(this, &QQuickColorInputs::showAlphaChanged, m_rgbAlphaInput, &QQuickTextInput::setVisible);
+ m_rgbAlphaInput->setVisible(showAlpha());
+ }
+
+ emit rgbAlphaInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::hsvAlphaInput() const
+{
+ return m_hsvAlphaInput;
+}
+
+void QQuickColorInputs::setHsvAlphaInput(QQuickTextInput *alphaInput)
+{
+ if (alphaInput == m_hsvAlphaInput)
+ return;
+
+ if (m_hsvAlphaInput) {
+ disconnect(m_hsvAlphaInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHsvAlphaChanged);
+ disconnect(this, &QQuickColorInputs::showAlphaChanged, m_hsvAlphaInput, &QQuickTextInput::setVisible);
+ }
+
+ m_hsvAlphaInput = alphaInput;
+
+ if (m_hsvAlphaInput) {
+ connect(m_hsvAlphaInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHsvAlphaChanged);
+ connect(this, &QQuickColorInputs::showAlphaChanged, m_hsvAlphaInput, &QQuickTextInput::setVisible);
+ m_hsvAlphaInput->setVisible(showAlpha());
+ }
+
+ emit hsvAlphaInputChanged();
+}
+
+QQuickTextInput *QQuickColorInputs::hslAlphaInput() const
+{
+ return m_hslAlphaInput;
+}
+
+void QQuickColorInputs::setHslAlphaInput(QQuickTextInput *alphaInput)
+{
+ if (alphaInput == m_hslAlphaInput)
+ return;
+
+ if (m_hslAlphaInput) {
+ disconnect(m_hslAlphaInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHslAlphaChanged);
+ disconnect(this, &QQuickColorInputs::showAlphaChanged, m_hslAlphaInput, &QQuickTextInput::setVisible);
+ }
+
+ m_hslAlphaInput = alphaInput;
+
+ if (m_hslAlphaInput) {
+ connect(m_hslAlphaInput, &QQuickTextInput::editingFinished, this, &QQuickColorInputs::handleHslAlphaChanged);
+ connect(this, &QQuickColorInputs::showAlphaChanged, m_hslAlphaInput, &QQuickTextInput::setVisible);
+ m_hslAlphaInput->setVisible(showAlpha());
+ }
+
+ emit hslAlphaInputChanged();
+}
+
+void QQuickColorInputs::handleHexChanged()
+{
+ emit colorModified(QColor::fromString(m_hexInput->text()));
+}
+
+void QQuickColorInputs::handleRedChanged()
+{
+ QColor c = color();
+ c.setRed(qBound(0, m_redInput->text().toInt(), 255));
+ emit colorModified(c);
+}
+
+void QQuickColorInputs::handleGreenChanged()
+{
+ QColor c = color();
+ c.setGreen(qBound(0, m_greenInput->text().toInt(), 255));
+ emit colorModified(c);
+}
+
+void QQuickColorInputs::handleBlueChanged()
+{
+ QColor c = color();
+ c.setBlue(qBound(0, m_blueInput->text().toInt(), 255));
+ emit colorModified(c);
+}
+
+static QString s_percentage_pattern = QString::fromUtf8("^(\\d+)%?$");
+static QString s_degree_pattern = QString::fromUtf8("(\\d+)°?$");
+
+void QQuickColorInputs::handleHsvHueChanged()
+{
+ const QRegularExpression pattern(s_degree_pattern);
+ const auto match = pattern.match(m_hsvHueInput->text());
+ if (match.hasMatch()) {
+ const auto substr = match.captured(1);
+ const qreal input = static_cast<qreal>(qBound(0, substr.toInt(), 360)) / static_cast<qreal>(360);
+ emit colorModified(QColor::fromHsvF(input, hsvSaturation(), value(), alpha()));
+ }
+}
+
+void QQuickColorInputs::handleHslHueChanged()
+{
+ const QRegularExpression pattern(s_degree_pattern);
+ const auto match = pattern.match(m_hslHueInput->text());
+ if (match.hasMatch()) {
+ const auto substr = match.captured(1);
+ const qreal input = static_cast<qreal>(qBound(0, substr.toInt(), 360)) / static_cast<qreal>(360);
+ emit colorModified(QColor::fromHslF(input, hslSaturation(), lightness(), alpha()));
+ }
+}
+
+void QQuickColorInputs::handleHsvSaturationChanged()
+{
+ const QRegularExpression pattern(s_percentage_pattern);
+ const auto match = pattern.match(m_hsvSaturationInput->text());
+ if (match.hasMatch()) {
+ const auto substr = match.captured(1);
+ const qreal input = static_cast<qreal>(qBound(0, substr.toInt(), 100)) / static_cast<qreal>(100);
+ emit colorModified(QColor::fromHsvF(hue(), input, value(), alpha()));
+ }
+}
+
+void QQuickColorInputs::handleHslSaturationChanged()
+{
+ const QRegularExpression pattern(s_percentage_pattern);
+ const auto match = pattern.match(m_hslSaturationInput->text());
+ if (match.hasMatch()) {
+ const auto substr = match.captured(1);
+ const qreal input = static_cast<qreal>(qBound(0, substr.toInt(), 100)) / static_cast<qreal>(100);
+ emit colorModified(QColor::fromHslF(hue(), input, lightness(), alpha()));
+ }
+}
+
+void QQuickColorInputs::handleValueChanged()
+{
+ const QRegularExpression pattern(s_percentage_pattern);
+ const auto match = pattern.match(m_valueInput->text());
+ if (match.hasMatch()) {
+ const auto substr = match.captured(1);
+ const qreal input = static_cast<qreal>(qBound(0, substr.toInt(), 100)) / static_cast<qreal>(100);
+ emit colorModified(QColor::fromHsvF(hue(), hsvSaturation(), input, alpha()));
+ }
+}
+
+void QQuickColorInputs::handleLightnessChanged()
+{
+ const QRegularExpression pattern(s_percentage_pattern);
+ const auto match = pattern.match(m_lightnessInput->text());
+ if (match.hasMatch()) {
+ const auto substr = match.captured(1);
+ const qreal input = static_cast<qreal>(qBound(0, substr.toInt(), 100)) / static_cast<qreal>(100);
+ emit colorModified(QColor::fromHslF(hue(), hslSaturation(), input, alpha()));
+ }
+}
+
+void QQuickColorInputs::handleRgbAlphaChanged()
+{
+ handleAlphaChanged(m_rgbAlphaInput->text());
+}
+
+void QQuickColorInputs::handleHsvAlphaChanged()
+{
+ handleAlphaChanged(m_hsvAlphaInput->text());
+}
+
+void QQuickColorInputs::handleHslAlphaChanged()
+{
+ handleAlphaChanged(m_hslAlphaInput->text());
+}
+
+void QQuickColorInputs::handleAlphaChanged(const QString &input)
+{
+ const QRegularExpression pattern(s_percentage_pattern);
+ const auto match = pattern.match(input);
+ if (match.hasMatch()) {
+ QColor c = color();
+ const auto substr = match.captured(1);
+ const qreal input = static_cast<qreal>(qBound(0, substr.toInt(), 100)) / static_cast<qreal>(100);
+ c.setAlphaF(input);
+ emit colorModified(c);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickcolorinputs_p.h b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolorinputs_p.h
new file mode 100644
index 0000000000..4827627d6f
--- /dev/null
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickcolorinputs_p.h
@@ -0,0 +1,171 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QQUICKCOLORINPUTS_P_H
+#define QQUICKCOLORINPUTS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qcolor.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuickTemplates2/private/qquickcombobox_p.h>
+#include <QtQuickTemplates2/private/qquicktextfield_p.h>
+
+#include "qtquickdialogs2quickimplglobal_p.h"
+
+#include "qquickcolordialogutils_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICKDIALOGS2QUICKIMPL_PRIVATE_EXPORT QQuickColorInputs : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(int red READ red NOTIFY colorChanged)
+ Q_PROPERTY(int green READ green NOTIFY colorChanged)
+ Q_PROPERTY(int blue READ blue NOTIFY colorChanged)
+ Q_PROPERTY(qreal hue READ hue NOTIFY colorChanged)
+ Q_PROPERTY(qreal hslSaturation READ hslSaturation NOTIFY colorChanged)
+ Q_PROPERTY(qreal hsvSaturation READ hsvSaturation NOTIFY colorChanged)
+ Q_PROPERTY(qreal value READ value NOTIFY colorChanged)
+ Q_PROPERTY(qreal lightness READ lightness NOTIFY colorChanged)
+ Q_PROPERTY(qreal alpha READ alpha NOTIFY colorChanged)
+ Q_PROPERTY(bool showAlpha READ showAlpha WRITE setShowAlpha NOTIFY showAlphaChanged)
+ Q_PROPERTY(QQuickTextInput *hexInput READ hexInput WRITE setHexInput NOTIFY hexInputChanged)
+ Q_PROPERTY(QQuickTextInput *redInput READ redInput WRITE setRedInput NOTIFY redInputChanged)
+ Q_PROPERTY(QQuickTextInput *greenInput READ greenInput WRITE setGreenInput NOTIFY greenInputChanged)
+ Q_PROPERTY(QQuickTextInput *blueInput READ blueInput WRITE setBlueInput NOTIFY blueInputChanged)
+ Q_PROPERTY(QQuickTextInput *hsvHueInput READ hsvHueInput WRITE setHsvHueInput NOTIFY hsvHueInputChanged)
+ Q_PROPERTY(QQuickTextInput *hslHueInput READ hslHueInput WRITE setHslHueInput NOTIFY hslHueInputChanged)
+ Q_PROPERTY(QQuickTextInput *hsvSaturationInput READ hsvSaturationInput WRITE setHsvSaturationInput NOTIFY hsvSaturationInputChanged)
+ Q_PROPERTY(QQuickTextInput *hslSaturationInput READ hslSaturationInput WRITE setHslSaturationInput NOTIFY hslSaturationInputChanged)
+ Q_PROPERTY(QQuickTextInput *valueInput READ valueInput WRITE setValueInput NOTIFY valueInputChanged)
+ Q_PROPERTY(QQuickTextInput *lightnessInput READ lightnessInput WRITE setLightnessInput NOTIFY lightnessInputChanged)
+ Q_PROPERTY(QQuickTextInput *rgbAlphaInput READ rgbAlphaInput WRITE setRgbAlphaInput NOTIFY rgbAlphaInputChanged)
+ Q_PROPERTY(QQuickTextInput *hsvAlphaInput READ hsvAlphaInput WRITE setHsvAlphaInput NOTIFY hsvAlphaInputChanged)
+ Q_PROPERTY(QQuickTextInput *hslAlphaInput READ hslAlphaInput WRITE setHslAlphaInput NOTIFY hslAlphaInputChanged)
+ QML_NAMED_ELEMENT(ColorInputsImpl)
+
+public:
+ explicit QQuickColorInputs();
+
+ QColor color() const;
+ void setColor(const QColor &c);
+ int red() const;
+ int green() const;
+ int blue() const;
+ qreal alpha() const;
+ qreal hue() const;
+ qreal hslSaturation() const;
+ qreal hsvSaturation() const;
+ qreal value() const;
+ qreal lightness() const;
+
+ bool showAlpha() const;
+ void setShowAlpha(bool showAlpha);
+
+ QQuickTextInput *hexInput() const;
+ void setHexInput(QQuickTextInput *hexInput);
+
+ QQuickTextInput *redInput() const;
+ void setRedInput(QQuickTextInput *redInput);
+
+ QQuickTextInput *greenInput() const;
+ void setGreenInput(QQuickTextInput *greenInput);
+
+ QQuickTextInput *blueInput() const;
+ void setBlueInput(QQuickTextInput *blueInput);
+
+ QQuickTextInput *hsvHueInput() const;
+ void setHsvHueInput(QQuickTextInput *hsvHueInput);
+
+ QQuickTextInput *hslHueInput() const;
+ void setHslHueInput(QQuickTextInput *hslHueInput);
+
+ QQuickTextInput *hsvSaturationInput() const;
+ void setHsvSaturationInput(QQuickTextInput *hsvSaturationInput);
+
+ QQuickTextInput *hslSaturationInput() const;
+ void setHslSaturationInput(QQuickTextInput *hslSaturationInput);
+
+ QQuickTextInput *valueInput() const;
+ void setValueInput(QQuickTextInput *valueInput);
+
+ QQuickTextInput *lightnessInput() const;
+ void setLightnessInput(QQuickTextInput *lightnessInput);
+
+ QQuickTextInput *rgbAlphaInput() const;
+ void setRgbAlphaInput(QQuickTextInput *alphaInput);
+
+ QQuickTextInput *hsvAlphaInput() const;
+ void setHsvAlphaInput(QQuickTextInput *alphaInput);
+
+ QQuickTextInput *hslAlphaInput() const;
+ void setHslAlphaInput(QQuickTextInput *alphaInput);
+
+Q_SIGNALS:
+ void colorChanged(const QColor &c);
+ void colorModified(const QColor &c);
+ void hslChanged();
+ void showAlphaChanged(bool);
+ void hexInputChanged();
+ void redInputChanged();
+ void greenInputChanged();
+ void blueInputChanged();
+ void hsvHueInputChanged();
+ void hslHueInputChanged();
+ void hsvSaturationInputChanged();
+ void hslSaturationInputChanged();
+ void valueInputChanged();
+ void lightnessInputChanged();
+ void rgbAlphaInputChanged();
+ void hsvAlphaInputChanged();
+ void hslAlphaInputChanged();
+
+private:
+ void handleHexChanged();
+ void handleRedChanged();
+ void handleGreenChanged();
+ void handleBlueChanged();
+ void handleHsvHueChanged();
+ void handleHslHueChanged();
+ void handleHueChanged(const QString &input);
+ void handleHsvSaturationChanged();
+ void handleHslSaturationChanged();
+ void handleSaturationChanged(const QString &input);
+ void handleValueChanged();
+ void handleLightnessChanged();
+ void handleRgbAlphaChanged();
+ void handleHsvAlphaChanged();
+ void handleHslAlphaChanged();
+ void handleAlphaChanged(const QString &input);
+
+ QPointer<QQuickTextInput> m_hexInput;
+ QPointer<QQuickTextInput> m_redInput;
+ QPointer<QQuickTextInput> m_greenInput;
+ QPointer<QQuickTextInput> m_blueInput;
+ QPointer<QQuickTextInput> m_hsvHueInput;
+ QPointer<QQuickTextInput> m_hslHueInput;
+ QPointer<QQuickTextInput> m_hsvSaturationInput;
+ QPointer<QQuickTextInput> m_hslSaturationInput;
+ QPointer<QQuickTextInput> m_valueInput;
+ QPointer<QQuickTextInput> m_lightnessInput;
+ QPointer<QQuickTextInput> m_rgbAlphaInput;
+ QPointer<QQuickTextInput> m_hsvAlphaInput;
+ QPointer<QQuickTextInput> m_hslAlphaInput;
+ HSVA m_hsva;
+ bool m_showAlpha = false;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKCOLORINPUTS_P_H
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl.cpp b/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl.cpp
index 72c4ca8336..a490ba1ebc 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl.cpp
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl.cpp
@@ -366,6 +366,12 @@ void QQuickFileDialogImpl::setOptions(const QSharedPointer<QFileDialogOptions> &
if (d->options) {
d->selectedNameFilter->setOptions(options);
d->setNameFilters(options->nameFilters());
+
+ if (auto attached = d->attachedOrWarn()) {
+ const bool isSaveMode = d->options->fileMode() == QFileDialogOptions::AnyFile;
+ attached->fileNameLabel()->setVisible(isSaveMode);
+ attached->fileNameTextField()->setVisible(isSaveMode);
+ }
}
}
@@ -451,6 +457,19 @@ void QQuickFileDialogImpl::selectNameFilter(const QString &filter)
emit filterSelected(filter);
}
+QString QQuickFileDialogImpl::fileName() const
+{
+ return selectedFile().fileName();
+}
+void QQuickFileDialogImpl::setFileName(const QString &fileName)
+{
+ const QString previous = selectedFile().fileName();
+ if (previous == fileName)
+ return;
+
+ setSelectedFile(QUrl(currentFolder().path() + u'/' + fileName));
+}
+
void QQuickFileDialogImpl::componentComplete()
{
Q_D(QQuickFileDialogImpl);
@@ -554,6 +573,15 @@ void QQuickFileDialogImplAttachedPrivate::fileDialogListViewCurrentIndexChanged(
}
}
+void QQuickFileDialogImplAttachedPrivate::fileNameChangedByUser()
+{
+ auto fileDialogImpl = qobject_cast<QQuickFileDialogImpl *>(parent);
+ if (!fileDialogImpl)
+ return;
+
+ fileDialogImpl->setFileName(fileNameTextField->text());
+}
+
QQuickFileDialogImplAttached::QQuickFileDialogImplAttached(QObject *parent)
: QObject(*(new QQuickFileDialogImplAttachedPrivate), parent)
{
@@ -683,6 +711,48 @@ void QQuickFileDialogImplAttached::setBreadcrumbBar(QQuickFolderBreadcrumbBar *b
emit breadcrumbBarChanged();
}
+QQuickLabel *QQuickFileDialogImplAttached::fileNameLabel() const
+{
+ Q_D(const QQuickFileDialogImplAttached);
+ return d->fileNameLabel;
+}
+
+void QQuickFileDialogImplAttached::setFileNameLabel(QQuickLabel *fileNameLabel)
+{
+ Q_D(QQuickFileDialogImplAttached);
+ if (fileNameLabel == d->fileNameLabel)
+ return;
+
+ d->fileNameLabel = fileNameLabel;
+
+ emit fileNameLabelChanged();
+}
+
+QQuickTextField *QQuickFileDialogImplAttached::fileNameTextField() const
+{
+ Q_D(const QQuickFileDialogImplAttached);
+ return d->fileNameTextField;
+}
+
+void QQuickFileDialogImplAttached::setFileNameTextField(QQuickTextField *fileNameTextField)
+{
+ Q_D(QQuickFileDialogImplAttached);
+ if (fileNameTextField == d->fileNameTextField)
+ return;
+
+ if (d->fileNameTextField)
+ QObjectPrivate::disconnect(d->fileNameTextField, &QQuickTextField::editingFinished,
+ d, &QQuickFileDialogImplAttachedPrivate::fileNameChangedByUser);
+
+ d->fileNameTextField = fileNameTextField;
+
+ if (d->fileNameTextField)
+ QObjectPrivate::connect(d->fileNameTextField, &QQuickTextField::editingFinished,
+ d, &QQuickFileDialogImplAttachedPrivate::fileNameChangedByUser);
+
+ emit fileNameTextFieldChanged();
+}
+
QT_END_NAMESPACE
#include "moc_qquickfiledialogimpl_p.cpp"
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl_p.h b/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl_p.h
index dca4450de1..4c64c5e4dd 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl_p.h
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl_p.h
@@ -24,6 +24,8 @@ QT_BEGIN_NAMESPACE
class QQuickComboBox;
class QQuickDialogButtonBox;
+class QQuickTextField;
+class QQuickLabel;
class QQuickFileDialogImplAttached;
class QQuickFileDialogImplAttachedPrivate;
@@ -38,6 +40,7 @@ class Q_QUICKDIALOGS2QUICKIMPL_PRIVATE_EXPORT QQuickFileDialogImpl : public QQui
Q_PROPERTY(QUrl selectedFile READ selectedFile WRITE setSelectedFile NOTIFY selectedFileChanged FINAL)
Q_PROPERTY(QStringList nameFilters READ nameFilters NOTIFY nameFiltersChanged FINAL)
Q_PROPERTY(QQuickFileNameFilter *selectedNameFilter READ selectedNameFilter CONSTANT)
+ Q_PROPERTY(QString fileName READ fileName WRITE setFileName NOTIFY selectedFileChanged FINAL)
QML_NAMED_ELEMENT(FileDialogImpl)
QML_ATTACHED(QQuickFileDialogImplAttached)
QML_ADDED_IN_VERSION(6, 2)
@@ -74,6 +77,9 @@ public:
void setAcceptLabel(const QString &label);
void setRejectLabel(const QString &label);
+ QString fileName() const;
+ void setFileName(const QString &fileName);
+
public Q_SLOTS:
void selectNameFilter(const QString &filter);
@@ -99,8 +105,12 @@ class Q_QUICKDIALOGS2QUICKIMPL_PRIVATE_EXPORT QQuickFileDialogImplAttached : pub
Q_PROPERTY(QQuickComboBox *nameFiltersComboBox READ nameFiltersComboBox WRITE setNameFiltersComboBox NOTIFY nameFiltersComboBoxChanged)
Q_PROPERTY(QQuickListView *fileDialogListView READ fileDialogListView WRITE setFileDialogListView NOTIFY fileDialogListViewChanged)
Q_PROPERTY(QQuickFolderBreadcrumbBar *breadcrumbBar READ breadcrumbBar WRITE setBreadcrumbBar NOTIFY breadcrumbBarChanged)
+ Q_PROPERTY(QQuickLabel *fileNameLabel READ fileNameLabel WRITE setFileNameLabel NOTIFY fileNameLabelChanged FINAL)
+ Q_PROPERTY(QQuickTextField *fileNameTextField READ fileNameTextField WRITE setFileNameTextField NOTIFY fileNameTextFieldChanged FINAL)
Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquickdialogbuttonbox_p.h>)
Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquickcombobox_p.h>)
+ Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquicktextfield_p.h>)
+ Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquicklabel_p.h>)
public:
explicit QQuickFileDialogImplAttached(QObject *parent = nullptr);
@@ -120,11 +130,19 @@ public:
QQuickFolderBreadcrumbBar *breadcrumbBar() const;
void setBreadcrumbBar(QQuickFolderBreadcrumbBar *breadcrumbBar);
+ QQuickLabel *fileNameLabel() const;
+ void setFileNameLabel(QQuickLabel *fileNameLabel);
+
+ QQuickTextField *fileNameTextField() const;
+ void setFileNameTextField(QQuickTextField *fileNameTextField);
+
Q_SIGNALS:
void buttonBoxChanged();
void nameFiltersComboBoxChanged();
void fileDialogListViewChanged();
void breadcrumbBarChanged();
+ void fileNameLabelChanged();
+ void fileNameTextFieldChanged();
private:
Q_DISABLE_COPY(QQuickFileDialogImplAttached)
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl_p_p.h b/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl_p_p.h
index 82bef2e8ba..6f3cc55e86 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl_p_p.h
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl_p_p.h
@@ -18,6 +18,8 @@
#include <QtQuickTemplates2/private/qquickcombobox_p.h>
#include <QtQuickTemplates2/private/qquickdialog_p_p.h>
#include <QtQuickTemplates2/private/qquickdialogbuttonbox_p.h>
+#include <QtQuickTemplates2/private/qquicklabel_p.h>
+#include <QtQuickTemplates2/private/qquicktextfield_p.h>
#include "qquickfiledialogimpl_p.h"
@@ -68,6 +70,7 @@ class QQuickFileDialogImplAttachedPrivate : public QObjectPrivate
{
void nameFiltersComboBoxItemActivated(int index);
void fileDialogListViewCurrentIndexChanged();
+ void fileNameChangedByUser();
public:
Q_DECLARE_PUBLIC(QQuickFileDialogImplAttached)
@@ -76,6 +79,8 @@ public:
QPointer<QQuickComboBox> nameFiltersComboBox;
QPointer<QQuickListView> fileDialogListView;
QPointer<QQuickFolderBreadcrumbBar> breadcrumbBar;
+ QPointer<QQuickLabel> fileNameLabel;
+ QPointer<QQuickTextField> fileNameTextField;
};
QT_END_NAMESPACE
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickfolderbreadcrumbbar.cpp b/src/quickdialogs2/quickdialogs2quickimpl/qquickfolderbreadcrumbbar.cpp
index 8fb117b167..a78833f470 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qquickfolderbreadcrumbbar.cpp
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickfolderbreadcrumbbar.cpp
@@ -35,13 +35,19 @@ QQuickItem *QQuickFolderBreadcrumbBarPrivate::createDelegateItem(QQmlComponent *
Q_Q(QQuickFolderBreadcrumbBar);
// If we don't use the correct context, it won't be possible to refer to
// the control's id from within the delegates.
- QQmlContext *creationContext = component->creationContext();
+ QQmlContext *context = component->creationContext();
// The component might not have been created in QML, in which case
// the creation context will be null and we have to create it ourselves.
- if (!creationContext)
- creationContext = qmlContext(q);
- QQmlContext *context = new QQmlContext(creationContext, q);
- context->setContextObject(q);
+ if (!context)
+ context = qmlContext(q);
+
+ // If we have initial properties we assume that all necessary information is passed via
+ // initial properties.
+ if (!component->isBound() && initialProperties.isEmpty()) {
+ context = new QQmlContext(context, q);
+ context->setContextObject(q);
+ }
+
QQuickItem *item = qobject_cast<QQuickItem*>(component->createWithInitialProperties(initialProperties, context));
if (item)
QQml_setParent_noEvent(item, q);
diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickfontdialogimpl.cpp b/src/quickdialogs2/quickdialogs2quickimpl/qquickfontdialogimpl.cpp
index 1f5f060620..5dcde5a81e 100644
--- a/src/quickdialogs2/quickdialogs2quickimpl/qquickfontdialogimpl.cpp
+++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickfontdialogimpl.cpp
@@ -532,7 +532,7 @@ static int findStyleInModel(const QString &selectedStyle, const QStringList &mod
auto styleClass = classifyStyleFallback(selectedStyle);
if (styleClass != StyleClass::Unknown)
- for (int i = 0; i < model.count(); ++i)
+ for (int i = 0; i < model.size(); ++i)
if (classifyStyleFallback(model.at(i)) == styleClass)
return i;
}
@@ -707,7 +707,7 @@ void QQuickFontDialogImplAttached::searchListView(const QString &s, QQuickListVi
do {
m_search.append(s);
- for (int i = 0; i < model.count(); ++i) {
+ for (int i = 0; i < model.size(); ++i) {
if (model.at(i).startsWith(m_search, Qt::CaseInsensitive)) {
listView->setCurrentIndex(i);
return;
@@ -774,7 +774,7 @@ void QQuickFontDialogImplAttached::_q_sizeEdited()
auto model = sizeListView()->model().toStringList();
int i;
- for (i = 0; i < model.count() - 1; ++i) {
+ for (i = 0; i < model.size() - 1; ++i) {
if (model.at(i).toInt() >= size)
break;
}
diff --git a/src/quicklayouts/qquickgridlayoutengine.cpp b/src/quicklayouts/qquickgridlayoutengine.cpp
index 9b4d877127..daec5151dc 100644
--- a/src/quicklayouts/qquickgridlayoutengine.cpp
+++ b/src/quicklayouts/qquickgridlayoutengine.cpp
@@ -15,11 +15,4 @@ void QQuickGridLayoutEngine::setAlignment(QQuickItem *quickItem, Qt::Alignment a
}
}
-Qt::Alignment QQuickGridLayoutEngine::alignment(QQuickItem *quickItem) const
-{
- if (QGridLayoutItem *item = findLayoutItem(quickItem))
- return item->alignment();
- return {};
-}
-
QT_END_NAMESPACE
diff --git a/src/quicklayouts/qquickgridlayoutengine_p.h b/src/quicklayouts/qquickgridlayoutengine_p.h
index 0fb503d5cc..412e56b29a 100644
--- a/src/quicklayouts/qquickgridlayoutengine_p.h
+++ b/src/quicklayouts/qquickgridlayoutengine_p.h
@@ -109,7 +109,7 @@ public:
QQuickGridLayoutItem *findLayoutItem(QQuickItem *layoutItem) const
{
- for (int i = q_items.count() - 1; i >= 0; --i) {
+ for (int i = q_items.size() - 1; i >= 0; --i) {
QQuickGridLayoutItem *item = static_cast<QQuickGridLayoutItem*>(q_items.at(i));
if (item->layoutItem() == layoutItem)
return item;
@@ -118,7 +118,6 @@ public:
}
void setAlignment(QQuickItem *quickItem, Qt::Alignment alignment);
- Qt::Alignment alignment(QQuickItem *quickItem) const;
};
diff --git a/src/quicklayouts/qquicklayout.cpp b/src/quicklayouts/qquicklayout.cpp
index 7d99c0c37e..74167db3e7 100644
--- a/src/quicklayouts/qquicklayout.cpp
+++ b/src/quicklayouts/qquicklayout.cpp
@@ -730,6 +730,18 @@ void QQuickLayout::componentComplete()
d->m_isReady = true;
}
+void QQuickLayout::maybeSubscribeToBaseLineOffsetChanges(QQuickItem *item)
+{
+ QQuickLayoutAttached *info = attachedLayoutObject(item, false);
+ if (info) {
+ if (info->alignment() == Qt::AlignBaseline && static_cast<QQuickLayout*>(item->parentItem()) == this) {
+ qmlobject_connect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem()));
+ } else {
+ qmlobject_disconnect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem()));
+ }
+ }
+}
+
void QQuickLayout::invalidate(QQuickItem * /*childItem*/)
{
Q_D(QQuickLayout);
@@ -811,7 +823,7 @@ void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value)
if (change == ItemChildAddedChange) {
Q_D(QQuickLayout);
QQuickItem *item = value.item;
- qmlobject_connect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem()));
+ maybeSubscribeToBaseLineOffsetChanges(item);
QQuickItemPrivate::get(item)->addItemChangeListener(this, changeTypes);
d->m_hasItemChangeListeners = true;
qCDebug(lcQuickLayouts) << "ChildAdded" << item;
@@ -819,7 +831,7 @@ void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value)
invalidate();
} else if (change == ItemChildRemovedChange) {
QQuickItem *item = value.item;
- qmlobject_disconnect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem()));
+ maybeSubscribeToBaseLineOffsetChanges(item);
QQuickItemPrivate::get(item)->removeItemChangeListener(this, changeTypes);
qCDebug(lcQuickLayouts) << "ChildRemoved" << item;
if (isReady())
diff --git a/src/quicklayouts/qquicklayout_p.h b/src/quicklayouts/qquicklayout_p.h
index 6c72e31216..40ee74614a 100644
--- a/src/quicklayouts/qquicklayout_p.h
+++ b/src/quicklayouts/qquicklayout_p.h
@@ -95,6 +95,8 @@ public:
void itemDestroyed(QQuickItem *item) override;
void itemVisibilityChanged(QQuickItem *item) override;
+ void maybeSubscribeToBaseLineOffsetChanges(QQuickItem *item);
+
Q_INVOKABLE void _q_dumpLayoutTree() const;
void dumpLayoutTreeRecursive(int level, QString &buf) const;
@@ -149,7 +151,6 @@ protected:
unsigned m_isReady : 1;
unsigned m_disableRearrange : 1;
unsigned m_hasItemChangeListeners : 1; // if false, we don't need to remove its item change listeners...
- mutable QSet<QQuickItem *> m_ignoredItems;
};
diff --git a/src/quicklayouts/qquicklinearlayout.cpp b/src/quicklayouts/qquicklinearlayout.cpp
index 1ca3499bd9..8cb3ecfcf1 100644
--- a/src/quicklayouts/qquicklinearlayout.cpp
+++ b/src/quicklayouts/qquicklinearlayout.cpp
@@ -281,6 +281,7 @@ void QQuickGridLayoutBase::setAlignment(QQuickItem *item, Qt::Alignment alignmen
{
Q_D(QQuickGridLayoutBase);
d->engine.setAlignment(item, alignment);
+ maybeSubscribeToBaseLineOffsetChanges(item);
}
QQuickGridLayoutBase::~QQuickGridLayoutBase()
@@ -470,7 +471,7 @@ void QQuickGridLayoutBase::rearrange(const QSizeF &size)
d->engine.setGeometries(QRectF(QPointF(0,0), size), d->styleInfo);
d->m_rearranging = false;
- for (QQuickItem *invalid : qAsConst(d->m_invalidateAfterRearrange))
+ for (QQuickItem *invalid : std::as_const(d->m_invalidateAfterRearrange))
invalidate(invalid);
d->m_invalidateAfterRearrange.clear();
}
diff --git a/src/quicklayouts/qquicklinearlayout_p.h b/src/quicklayouts/qquicklinearlayout_p.h
index 26810d5684..15ce953ead 100644
--- a/src/quicklayouts/qquicklinearlayout_p.h
+++ b/src/quicklayouts/qquicklinearlayout_p.h
@@ -169,7 +169,7 @@ public:
**
**/
class QQuickLinearLayoutPrivate;
-class QQuickLinearLayout : public QQuickGridLayoutBase
+class Q_QUICKLAYOUTS_PRIVATE_EXPORT QQuickLinearLayout : public QQuickGridLayoutBase
{
Q_OBJECT
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
diff --git a/src/quicklayouts/qquickstacklayout.cpp b/src/quicklayouts/qquickstacklayout.cpp
index 1e6ba4d27d..2b06473154 100644
--- a/src/quicklayouts/qquickstacklayout.cpp
+++ b/src/quicklayouts/qquickstacklayout.cpp
@@ -168,6 +168,7 @@ void QQuickStackLayout::itemChange(QQuickItem::ItemChange change, const QQuickIt
stackLayoutAttached->setIndex(-1);
stackLayoutAttached->setIsCurrentItem(false);
}
+ m_cachedItemSizeHints.remove(item);
childItemsChanged();
invalidate();
} else if (change == ItemChildAddedChange) {
@@ -190,10 +191,8 @@ QSizeF QQuickStackLayout::sizeHint(Qt::SizeHint whichSizeHint) const
maxS = QSizeF(std::numeric_limits<qreal>::infinity(), std::numeric_limits<qreal>::infinity());
const int count = itemCount();
- m_cachedItemSizeHints.resize(count);
for (int i = 0; i < count; ++i) {
- SizeHints &hints = m_cachedItemSizeHints[i];
- QQuickStackLayout::collectItemSizeHints(itemAt(i), hints.array);
+ SizeHints &hints = cachedItemSizeHints(i);
minS = minS.expandedTo(hints.min());
prefS = prefS.expandedTo(hints.pref());
//maxS = maxS.boundedTo(hints.max()); // Can be resized to be larger than any of its items.
@@ -258,11 +257,11 @@ void QQuickStackLayout::setAlignment(QQuickItem * /*item*/, Qt::Alignment /*alig
void QQuickStackLayout::invalidate(QQuickItem *childItem)
{
- const int indexOfChild = indexOf(childItem);
- if (indexOfChild >= 0 && indexOfChild < m_cachedItemSizeHints.count()) {
- m_cachedItemSizeHints[indexOfChild].min() = QSizeF();
- m_cachedItemSizeHints[indexOfChild].pref() = QSizeF();
- m_cachedItemSizeHints[indexOfChild].max() = QSizeF();
+ if (childItem) {
+ SizeHints &hints = m_cachedItemSizeHints[childItem];
+ hints.min() = QSizeF();
+ hints.pref() = QSizeF();
+ hints.max() = QSizeF();
}
for (int i = 0; i < Qt::NSizeHints; ++i)
@@ -276,7 +275,6 @@ void QQuickStackLayout::invalidate(QQuickItem *childItem)
void QQuickStackLayout::childItemsChanged()
{
Q_D(QQuickStackLayout);
- d->m_ignoredItems.clear();
const int count = itemCount();
const int oldIndex = d->currentIndex;
if (!d->explicitCurrentIndex)
@@ -303,6 +301,17 @@ void QQuickStackLayout::childItemsChanged()
}
}
+QQuickStackLayout::SizeHints &QQuickStackLayout::cachedItemSizeHints(int index) const
+{
+ QQuickItem *item = itemAt(index);
+ Q_ASSERT(item);
+ SizeHints &hints = m_cachedItemSizeHints[item]; // will create an entry if it doesn't exist
+ if (!hints.min().isValid())
+ QQuickStackLayout::collectItemSizeHints(item, hints.array);
+ return hints;
+}
+
+
void QQuickStackLayout::rearrange(const QSizeF &newSize)
{
Q_D(QQuickStackLayout);
@@ -311,9 +320,9 @@ void QQuickStackLayout::rearrange(const QSizeF &newSize)
qCDebug(lcQuickLayouts) << "QQuickStackLayout::rearrange";
- if (d->currentIndex == -1 || d->currentIndex >= m_cachedItemSizeHints.count())
+ if (d->currentIndex == -1 || d->currentIndex >= m_cachedItemSizeHints.size())
return;
- QQuickStackLayout::SizeHints &hints = m_cachedItemSizeHints[d->currentIndex];
+ QQuickStackLayout::SizeHints &hints = cachedItemSizeHints(d->currentIndex);
QQuickItem *item = itemAt(d->currentIndex);
Q_ASSERT(item);
item->setPosition(QPointF(0,0)); // ### respect alignment?
@@ -346,10 +355,7 @@ void QQuickStackLayout::collectItemSizeHints(QQuickItem *item, QSizeF *sizeHints
bool QQuickStackLayout::shouldIgnoreItem(QQuickItem *item) const
{
- const bool ignored = QQuickItemPrivate::get(item)->isTransparentForPositioner();
- if (ignored)
- d_func()->m_ignoredItems << item;
- return ignored;
+ return QQuickItemPrivate::get(item)->isTransparentForPositioner();
}
QQuickStackLayoutAttached::QQuickStackLayoutAttached(QObject *object)
@@ -377,6 +383,11 @@ QQuickStackLayoutAttached::QQuickStackLayoutAttached(QObject *object)
setLayout(stackLayout);
setIndex(index);
setIsCurrentItem(stackLayout->currentIndex() == index);
+
+ // In case of lazy loading in loader, attachedProperties are created and updated for the
+ // object after adding the child object to the stack layout, which leads to entries with
+ // same index. Triggering childItemsChanged() resets to right index in the stack layout.
+ stackLayout->childItemsChanged();
}
/*!
diff --git a/src/quicklayouts/qquickstacklayout_p.h b/src/quicklayouts/qquickstacklayout_p.h
index c7c174450e..a27f7f6f7a 100644
--- a/src/quicklayouts/qquickstacklayout_p.h
+++ b/src/quicklayouts/qquickstacklayout_p.h
@@ -74,8 +74,9 @@ private:
QSizeF array[Qt::NSizeHints];
};
- mutable QVector<SizeHints> m_cachedItemSizeHints;
+ mutable QHash<QQuickItem*, SizeHints> m_cachedItemSizeHints;
mutable QSizeF m_cachedSizeHints[Qt::NSizeHints];
+ SizeHints &cachedItemSizeHints(int index) const;
};
class QQuickStackLayoutPrivate : public QQuickLayoutPrivate
diff --git a/src/quicknativestyle/controls/DefaultTreeViewDelegate.qml b/src/quicknativestyle/controls/DefaultTreeViewDelegate.qml
index a55e56d911..57e51d9639 100644
--- a/src/quicknativestyle/controls/DefaultTreeViewDelegate.qml
+++ b/src/quicknativestyle/controls/DefaultTreeViewDelegate.qml
@@ -1,4 +1,4 @@
-// Copyright (C) 2021 The Qt Company Lt.
+// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import QtQuick
diff --git a/src/quicknativestyle/qstyle/mac/qquickmacstyle_mac.mm b/src/quicknativestyle/qstyle/mac/qquickmacstyle_mac.mm
index 43983b9fd9..eb777ea9f2 100644
--- a/src/quicknativestyle/qstyle/mac/qquickmacstyle_mac.mm
+++ b/src/quicknativestyle/qstyle/mac/qquickmacstyle_mac.mm
@@ -361,7 +361,11 @@ static bool setupSlider(NSSlider *slider, const QStyleOptionSlider *sl)
if (sl->minimum >= sl->maximum)
return false;
- slider.frame = sl->rect.toCGRect();
+ // NSSlider seems to cache values based on tracking and the last layout of the
+ // NSView, resulting in incorrect knob rects that break the interaction with
+ // multiple sliders. So completely reinitialize the slider.
+ [slider initWithFrame:sl->rect.toCGRect()];
+
slider.minValue = sl->minimum;
slider.maxValue = sl->maximum;
slider.intValue = sl->sliderPosition;
@@ -391,6 +395,14 @@ static bool setupSlider(NSSlider *slider, const QStyleOptionSlider *sl)
// the cell for its metrics and to draw itself.
[slider layoutSubtreeIfNeeded];
+ if (sl->state & QStyle::State_Sunken) {
+ const CGRect knobRect = [slider.cell knobRectFlipped:slider.isFlipped];
+ CGPoint pressPoint;
+ pressPoint.x = CGRectGetMidX(knobRect);
+ pressPoint.y = CGRectGetMidY(knobRect);
+ [slider.cell startTrackingAt:pressPoint inView:slider];
+ }
+
return true;
}
@@ -2759,7 +2771,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
[triangleCell setState:(opt->state & State_Open) ? NSControlStateValueOn : NSControlStateValueOff];
// bool viewHasFocus = (w && w->hasFocus()) || (opt->state & State_HasFocus);
bool viewHasFocus = false;
- [triangleCell setBackgroundStyle:((opt->state & State_Selected) && viewHasFocus) ? NSBackgroundStyleDark : NSBackgroundStyleLight];
+ [triangleCell setBackgroundStyle:((opt->state & State_Selected) && viewHasFocus) ? NSBackgroundStyleEmphasized : NSBackgroundStyleNormal];
d->setupNSGraphicsContext(cg, NO);
diff --git a/src/quicknativestyle/qstyle/qquickcommonstyle.cpp b/src/quicknativestyle/qstyle/qquickcommonstyle.cpp
index 5c54a3bc1e..d8cac57486 100644
--- a/src/quicknativestyle/qstyle/qquickcommonstyle.cpp
+++ b/src/quicknativestyle/qstyle/qquickcommonstyle.cpp
@@ -4475,12 +4475,13 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt) const
QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &csz) const
{
Q_D(const QCommonStyle);
- QSize sz(csz);
+ QSize sz(!csz.isEmpty() ? csz : QSize(0,0));
+
switch (ct) {
case CT_PushButton:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- int w = csz.width(),
- h = csz.height(),
+ int w = sz.width(),
+ h = sz.height(),
bm = proxy()->pixelMetric(PM_ButtonMargin, btn),
fw = proxy()->pixelMetric(PM_DefaultFrameWidth, btn) * 2;
w += bm + fw;
diff --git a/src/quickshapes/qquickshape.cpp b/src/quickshapes/qquickshape.cpp
index f19c4e637b..6ec5c566d0 100644
--- a/src/quickshapes/qquickshape.cpp
+++ b/src/quickshapes/qquickshape.cpp
@@ -903,7 +903,7 @@ void QQuickShape::itemChange(ItemChange change, const ItemChangeData &data)
if (change == ItemVisibleHasChanged && data.boolValue)
d->_q_shapePathChanged();
else if (change == QQuickItem::ItemSceneChange) {
- for (int i = 0; i < d->sp.count(); ++i)
+ for (int i = 0; i < d->sp.size(); ++i)
QQuickShapePathPrivate::get(d->sp[i])->dirty = QQuickShapePathPrivate::DirtyAll;
d->_q_shapePathChanged();
}
@@ -1002,7 +1002,7 @@ void QQuickShapePrivate::sync()
renderer->setAsyncCallback(asyncShapeReady, this);
}
- const int count = sp.count();
+ const int count = sp.size();
bool countChanged = false;
renderer->beginSync(count, &countChanged);
@@ -1440,6 +1440,7 @@ static void generateGradientColorTable(const QQuickShapeGradientCacheKey &gradie
{
int pos = 0;
const QGradientStops &s = gradient.stops;
+ Q_ASSERT(!s.isEmpty());
const bool colorInterpolation = true;
uint alpha = qRound(opacity * 256);
@@ -1477,8 +1478,6 @@ static void generateGradientColorTable(const QQuickShapeGradientCacheKey &gradie
current_color = next_color;
}
- Q_ASSERT(s.size() > 0);
-
uint last_color = ARGB2RGBA(qPremultiply(ARGB_COMBINE_ALPHA(s[sLast].second.rgba(), alpha)));
for ( ; pos < size; ++pos)
colorTable[pos] = last_color;
@@ -1513,7 +1512,10 @@ QSGTexture *QQuickShapeGradientCache::get(const QQuickShapeGradientCacheKey &gra
if (!tx) {
static const int W = 1024; // texture size is 1024x1
QImage gradTab(W, 1, QImage::Format_RGBA8888_Premultiplied);
- generateGradientColorTable(grad, reinterpret_cast<uint *>(gradTab.bits()), W, 1.0f);
+ if (!grad.stops.isEmpty())
+ generateGradientColorTable(grad, reinterpret_cast<uint *>(gradTab.bits()), W, 1.0f);
+ else
+ gradTab.fill(Qt::black);
tx = new QSGPlainTexture;
tx->setImage(gradTab);
switch (grad.spread) {
diff --git a/src/quickshapes/qquickshape_p_p.h b/src/quickshapes/qquickshape_p_p.h
index 593a5d8d73..20bc07da0f 100644
--- a/src/quickshapes/qquickshape_p_p.h
+++ b/src/quickshapes/qquickshape_p_p.h
@@ -167,7 +167,7 @@ struct QQuickShapeGradientCacheKey
inline size_t qHash(const QQuickShapeGradientCacheKey &v, size_t seed = 0)
{
size_t h = seed + v.spread;
- for (int i = 0; i < 3 && i < v.stops.count(); ++i)
+ for (int i = 0; i < 3 && i < v.stops.size(); ++i)
h += v.stops[i].second.rgba();
return h;
}
diff --git a/src/quickshapes/qquickshapegenericrenderer.cpp b/src/quickshapes/qquickshapegenericrenderer.cpp
index 470e5e9641..4fabcd1056 100644
--- a/src/quickshapes/qquickshapegenericrenderer.cpp
+++ b/src/quickshapes/qquickshapegenericrenderer.cpp
@@ -90,7 +90,7 @@ QQuickShapeGenericRenderer::~QQuickShapeGenericRenderer()
void QQuickShapeGenericRenderer::beginSync(int totalCount, bool *countChanged)
{
- if (m_sp.count() != totalCount) {
+ if (m_sp.size() != totalCount) {
m_sp.resize(totalCount);
m_accDirty |= DirtyList;
*countChanged = true;
@@ -111,8 +111,12 @@ void QQuickShapeGenericRenderer::setPath(int index, const QQuickPath *path)
void QQuickShapeGenericRenderer::setStrokeColor(int index, const QColor &color)
{
ShapePathData &d(m_sp[index]);
+ const bool wasTransparent = d.strokeColor.a == 0;
d.strokeColor = colorToColor4ub(color);
+ const bool isTransparent = d.strokeColor.a == 0;
d.syncDirty |= DirtyColor;
+ if (wasTransparent && !isTransparent)
+ d.syncDirty |= DirtyStrokeGeom;
}
void QQuickShapeGenericRenderer::setStrokeWidth(int index, qreal w)
@@ -236,7 +240,7 @@ void QQuickShapeGenericRenderer::endSync(bool async)
bool didKickOffAsync = false;
- for (int i = 0; i < m_sp.count(); ++i) {
+ for (int i = 0; i < m_sp.size(); ++i) {
ShapePathData &d(m_sp[i]);
if (!d.syncDirty)
continue;
@@ -291,7 +295,7 @@ void QQuickShapeGenericRenderer::endSync(bool async)
QObject::connect(r, &QQuickShapeFillRunnable::done, qApp, [this, i](QQuickShapeFillRunnable *r) {
// Bail out when orphaned (meaning either another run was
// started after this one, or the renderer got destroyed).
- if (!r->orphaned && i < m_sp.count()) {
+ if (!r->orphaned && i < m_sp.size()) {
ShapePathData &d(m_sp[i]);
d.fillVertices = r->fillVertices;
d.fillIndices = r->fillIndices;
@@ -326,7 +330,7 @@ void QQuickShapeGenericRenderer::endSync(bool async)
r->strokeColor = d.strokeColor;
r->clipSize = QSize(m_item->width(), m_item->height());
QObject::connect(r, &QQuickShapeStrokeRunnable::done, qApp, [this, i](QQuickShapeStrokeRunnable *r) {
- if (!r->orphaned && i < m_sp.count()) {
+ if (!r->orphaned && i < m_sp.size()) {
ShapePathData &d(m_sp[i]);
d.strokeVertices = r->strokeVertices;
d.pendingStroke = nullptr;
@@ -355,7 +359,7 @@ void QQuickShapeGenericRenderer::endSync(bool async)
void QQuickShapeGenericRenderer::maybeUpdateAsyncItem()
{
- for (const ShapePathData &d : qAsConst(m_sp)) {
+ for (const ShapePathData &d : std::as_const(m_sp)) {
if (d.pendingFill || d.pendingStroke)
return;
}
@@ -377,7 +381,7 @@ void QQuickShapeGenericRenderer::triangulateFill(const QPainterPath &path,
const QVectorPath &vp = qtVectorPathForPath(path);
QTriangleSet ts = qTriangulate(vp, QTransform::fromScale(TRI_SCALE, TRI_SCALE), 1, supportsElementIndexUint);
- const int vertexCount = ts.vertices.count() / 2; // just a qreal vector with x,y hence the / 2
+ const int vertexCount = ts.vertices.size() / 2; // just a qreal vector with x,y hence the / 2
fillVertices->resize(vertexCount);
ColoredVertex *vdst = reinterpret_cast<ColoredVertex *>(fillVertices->data());
const qreal *vsrc = ts.vertices.constData();
@@ -588,13 +592,13 @@ void QQuickShapeGenericRenderer::updateFillNode(ShapePathData *d, QQuickShapeGen
}
const int indexCount = d->indexType == QSGGeometry::UnsignedShortType
- ? d->fillIndices.count() * 2 : d->fillIndices.count();
+ ? d->fillIndices.size() * 2 : d->fillIndices.size();
if (g->indexType() != d->indexType) {
g = new QSGGeometry(QSGGeometry::defaultAttributes_ColoredPoint2D(),
- d->fillVertices.count(), indexCount, d->indexType);
+ d->fillVertices.size(), indexCount, d->indexType);
n->setGeometry(g);
} else {
- g->allocate(d->fillVertices.count(), indexCount);
+ g->allocate(d->fillVertices.size(), indexCount);
}
g->setDrawingMode(QSGGeometry::DrawTriangles);
memcpy(g->vertexData(), d->fillVertices.constData(), g->vertexCount() * g->sizeOfVertex());
@@ -635,7 +639,7 @@ void QQuickShapeGenericRenderer::updateStrokeNode(ShapePathData *d, QQuickShapeG
return;
}
- g->allocate(d->strokeVertices.count(), 0);
+ g->allocate(d->strokeVertices.size(), 0);
g->setDrawingMode(QSGGeometry::DrawTriangleStrip);
memcpy(g->vertexData(), d->strokeVertices.constData(), g->vertexCount() * g->sizeOfVertex());
}
@@ -778,10 +782,10 @@ int QQuickShapeLinearGradientMaterial::compare(const QSGMaterial *other) const
if (int d = ga->b.y() - gb->b.y())
return d;
- if (int d = ga->stops.count() - gb->stops.count())
+ if (int d = ga->stops.size() - gb->stops.size())
return d;
- for (int i = 0; i < ga->stops.count(); ++i) {
+ for (int i = 0; i < ga->stops.size(); ++i) {
if (int d = ga->stops[i].first - gb->stops[i].first)
return d;
if (int d = ga->stops[i].second.rgba() - gb->stops[i].second.rgba())
@@ -807,7 +811,7 @@ bool QQuickShapeRadialGradientRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
Q_ASSERT(oldMaterial == nullptr || newMaterial->type() == oldMaterial->type());
- QQuickShapeLinearGradientMaterial *m = static_cast<QQuickShapeLinearGradientMaterial *>(newMaterial);
+ QQuickShapeRadialGradientMaterial *m = static_cast<QQuickShapeRadialGradientMaterial *>(newMaterial);
bool changed = false;
QByteArray *buf = state.uniformData();
Q_ASSERT(buf->size() >= 92);
@@ -867,7 +871,7 @@ void QQuickShapeRadialGradientRhiShader::updateSampledImage(RenderState &state,
if (binding != 1)
return;
- QQuickShapeLinearGradientMaterial *m = static_cast<QQuickShapeLinearGradientMaterial *>(newMaterial);
+ QQuickShapeRadialGradientMaterial *m = static_cast<QQuickShapeRadialGradientMaterial *>(newMaterial);
QQuickShapeGenericStrokeFillNode *node = m->node();
const QQuickShapeGradientCacheKey cacheKey(node->m_fillGradient.stops, node->m_fillGradient.spread);
QSGTexture *t = QQuickShapeGradientCache::cacheForRhi(state.rhi())->get(cacheKey);
@@ -912,10 +916,10 @@ int QQuickShapeRadialGradientMaterial::compare(const QSGMaterial *other) const
if (int d = ga->v1 - gb->v1)
return d;
- if (int d = ga->stops.count() - gb->stops.count())
+ if (int d = ga->stops.size() - gb->stops.size())
return d;
- for (int i = 0; i < ga->stops.count(); ++i) {
+ for (int i = 0; i < ga->stops.size(); ++i) {
if (int d = ga->stops[i].first - gb->stops[i].first)
return d;
if (int d = ga->stops[i].second.rgba() - gb->stops[i].second.rgba())
@@ -941,7 +945,7 @@ bool QQuickShapeConicalGradientRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
Q_ASSERT(oldMaterial == nullptr || newMaterial->type() == oldMaterial->type());
- QQuickShapeLinearGradientMaterial *m = static_cast<QQuickShapeLinearGradientMaterial *>(newMaterial);
+ QQuickShapeConicalGradientMaterial *m = static_cast<QQuickShapeConicalGradientMaterial *>(newMaterial);
bool changed = false;
QByteArray *buf = state.uniformData();
Q_ASSERT(buf->size() >= 80);
@@ -985,7 +989,7 @@ void QQuickShapeConicalGradientRhiShader::updateSampledImage(RenderState &state,
if (binding != 1)
return;
- QQuickShapeLinearGradientMaterial *m = static_cast<QQuickShapeLinearGradientMaterial *>(newMaterial);
+ QQuickShapeConicalGradientMaterial *m = static_cast<QQuickShapeConicalGradientMaterial *>(newMaterial);
QQuickShapeGenericStrokeFillNode *node = m->node();
const QQuickShapeGradientCacheKey cacheKey(node->m_fillGradient.stops, node->m_fillGradient.spread);
QSGTexture *t = QQuickShapeGradientCache::cacheForRhi(state.rhi())->get(cacheKey);
@@ -1021,10 +1025,10 @@ int QQuickShapeConicalGradientMaterial::compare(const QSGMaterial *other) const
if (int d = ga->v0 - gb->v0)
return d;
- if (int d = ga->stops.count() - gb->stops.count())
+ if (int d = ga->stops.size() - gb->stops.size())
return d;
- for (int i = 0; i < ga->stops.count(); ++i) {
+ for (int i = 0; i < ga->stops.size(); ++i) {
if (int d = ga->stops[i].first - gb->stops[i].first)
return d;
if (int d = ga->stops[i].second.rgba() - gb->stops[i].second.rgba())
diff --git a/src/quickshapes/qquickshapesoftwarerenderer.cpp b/src/quickshapes/qquickshapesoftwarerenderer.cpp
index 21327d12e0..60efcf1db9 100644
--- a/src/quickshapes/qquickshapesoftwarerenderer.cpp
+++ b/src/quickshapes/qquickshapesoftwarerenderer.cpp
@@ -8,7 +8,7 @@ QT_BEGIN_NAMESPACE
void QQuickShapeSoftwareRenderer::beginSync(int totalCount, bool *countChanged)
{
- if (m_sp.count() != totalCount) {
+ if (m_sp.size() != totalCount) {
m_sp.resize(totalCount);
m_accDirty |= DirtyList;
*countChanged = true;
@@ -144,10 +144,8 @@ void QQuickShapeSoftwareRenderer::endSync(bool)
void QQuickShapeSoftwareRenderer::setNode(QQuickShapeSoftwareRenderNode *node)
{
- if (m_node != node) {
- m_node = node;
- m_accDirty |= DirtyList;
- }
+ m_node = node;
+ m_accDirty |= DirtyList;
}
void QQuickShapeSoftwareRenderer::updateNode()
@@ -155,7 +153,7 @@ void QQuickShapeSoftwareRenderer::updateNode()
if (!m_accDirty)
return;
- const int count = m_sp.count();
+ const int count = m_sp.size();
const bool listChanged = m_accDirty & DirtyList;
if (listChanged)
m_node->m_sp.resize(count);
@@ -224,7 +222,7 @@ void QQuickShapeSoftwareRenderNode::render(const RenderState *state)
p->setTransform(matrix()->toTransform());
p->setOpacity(inheritedOpacity());
- for (const ShapePathRenderData &d : qAsConst(m_sp)) {
+ for (const ShapePathRenderData &d : std::as_const(m_sp)) {
p->setPen(d.strokeWidth >= 0.0f && d.pen.color() != Qt::transparent ? d.pen : Qt::NoPen);
p->setBrush(d.brush.color() != Qt::transparent ? d.brush : Qt::NoBrush);
p->drawPath(d.path);
diff --git a/src/quicktemplates2/accessible/qaccessiblequickpage.cpp b/src/quicktemplates2/accessible/qaccessiblequickpage.cpp
index d291648bab..6a15f3a3b3 100644
--- a/src/quicktemplates2/accessible/qaccessiblequickpage.cpp
+++ b/src/quicktemplates2/accessible/qaccessiblequickpage.cpp
@@ -35,7 +35,7 @@ QList<QQuickItem *> QAccessibleQuickPage::orderedChildItems() const
kids.move(hidx, 0);
const qsizetype fidx = kids.indexOf(p->footer());
if (fidx != -1)
- kids.move(fidx, kids.count() - 1);
+ kids.move(fidx, kids.size() - 1);
return kids;
}
diff --git a/src/quicktemplates2/qquickaction.cpp b/src/quicktemplates2/qquickaction.cpp
index 2cf1006845..2ff5fd4a48 100644
--- a/src/quicktemplates2/qquickaction.cpp
+++ b/src/quicktemplates2/qquickaction.cpp
@@ -151,14 +151,14 @@ void QQuickActionPrivate::setShortcut(const QVariant &var)
return;
defaultShortcutEntry->ungrab();
- for (QQuickActionPrivate::ShortcutEntry *entry : qAsConst(shortcutEntries))
+ for (QQuickActionPrivate::ShortcutEntry *entry : std::as_const(shortcutEntries))
entry->ungrab();
vshortcut = var;
keySequence = variantToKeySequence(var);
defaultShortcutEntry->grab(keySequence, enabled);
- for (QQuickActionPrivate::ShortcutEntry *entry : qAsConst(shortcutEntries))
+ for (QQuickActionPrivate::ShortcutEntry *entry : std::as_const(shortcutEntries))
entry->grab(keySequence, enabled);
emit q->shortcutChanged(keySequence);
@@ -175,7 +175,7 @@ void QQuickActionPrivate::setEnabled(bool enable)
#if QT_CONFIG(shortcut)
defaultShortcutEntry->setEnabled(enable);
- for (QQuickActionPrivate::ShortcutEntry *entry : qAsConst(shortcutEntries))
+ for (QQuickActionPrivate::ShortcutEntry *entry : std::as_const(shortcutEntries))
entry->setEnabled(enable);
#endif
@@ -288,7 +288,7 @@ QQuickActionPrivate::ShortcutEntry *QQuickActionPrivate::findShortcutEntry(QObje
void QQuickActionPrivate::updateDefaultShortcutEntry()
{
bool hasActiveShortcutEntries = false;
- for (QQuickActionPrivate::ShortcutEntry *entry : qAsConst(shortcutEntries)) {
+ for (QQuickActionPrivate::ShortcutEntry *entry : std::as_const(shortcutEntries)) {
if (entry->shortcutId()) {
hasActiveShortcutEntries = true;
break;
@@ -318,7 +318,7 @@ QQuickAction::~QQuickAction()
d->group->removeAction(this);
#if QT_CONFIG(shortcut)
- for (QQuickActionPrivate::ShortcutEntry *entry : qAsConst(d->shortcutEntries))
+ for (QQuickActionPrivate::ShortcutEntry *entry : std::as_const(d->shortcutEntries))
d->unwatchItem(qobject_cast<QQuickItem *>(entry->target()));
qDeleteAll(d->shortcutEntries);
diff --git a/src/quicktemplates2/qquickactiongroup.cpp b/src/quicktemplates2/qquickactiongroup.cpp
index 9caf5f67f8..5e088f3924 100644
--- a/src/quicktemplates2/qquickactiongroup.cpp
+++ b/src/quicktemplates2/qquickactiongroup.cpp
@@ -128,7 +128,7 @@ public:
void QQuickActionGroupPrivate::clear()
{
- for (QQuickAction *action : qAsConst(actions)) {
+ for (QQuickAction *action : std::as_const(actions)) {
QQuickActionPrivate::get(action)->group = nullptr;
QObjectPrivate::disconnect(action, &QQuickAction::triggered, this, &QQuickActionGroupPrivate::actionTriggered);
QObjectPrivate::disconnect(action, &QQuickAction::checkedChanged, this, &QQuickActionGroupPrivate::_q_updateCurrent);
@@ -170,7 +170,7 @@ void QQuickActionGroupPrivate::actions_append(QQmlListProperty<QQuickAction> *pr
qsizetype QQuickActionGroupPrivate::actions_count(QQmlListProperty<QQuickAction> *prop)
{
QQuickActionGroupPrivate *p = static_cast<QQuickActionGroupPrivate *>(prop->data);
- return p->actions.count();
+ return p->actions.size();
}
QQuickAction *QQuickActionGroupPrivate::actions_at(QQmlListProperty<QQuickAction> *prop, qsizetype index)
@@ -307,7 +307,7 @@ void QQuickActionGroup::setEnabled(bool enabled)
if (d->enabled == enabled)
return;
- for (QQuickAction *action : qAsConst(d->actions)) {
+ for (QQuickAction *action : std::as_const(d->actions)) {
if (d->changeEnabled(action, enabled))
emit action->enabledChanged(enabled);
}
diff --git a/src/quicktemplates2/qquickbuttongroup.cpp b/src/quicktemplates2/qquickbuttongroup.cpp
index b5a7ea00aa..89a64720dc 100644
--- a/src/quicktemplates2/qquickbuttongroup.cpp
+++ b/src/quicktemplates2/qquickbuttongroup.cpp
@@ -142,7 +142,7 @@ public:
void QQuickButtonGroupPrivate::clear()
{
- for (QQuickAbstractButton *button : qAsConst(buttons)) {
+ for (QQuickAbstractButton *button : std::as_const(buttons)) {
QQuickAbstractButtonPrivate::get(button)->group = nullptr;
QObjectPrivate::disconnect(button, &QQuickAbstractButton::clicked, this, &QQuickButtonGroupPrivate::buttonClicked);
QObjectPrivate::disconnect(button, &QQuickAbstractButton::checkedChanged, this, &QQuickButtonGroupPrivate::_q_updateCurrent);
@@ -178,7 +178,7 @@ void QQuickButtonGroupPrivate::updateCheckState()
bool anyChecked = false;
bool allChecked = !buttons.isEmpty();
- for (QQuickAbstractButton *button : qAsConst(buttons)) {
+ for (QQuickAbstractButton *button : std::as_const(buttons)) {
const bool isChecked = button->isChecked();
anyChecked |= isChecked;
allChecked &= isChecked;
@@ -205,7 +205,7 @@ void QQuickButtonGroupPrivate::buttons_append(QQmlListProperty<QQuickAbstractBut
qsizetype QQuickButtonGroupPrivate::buttons_count(QQmlListProperty<QQuickAbstractButton> *prop)
{
QQuickButtonGroupPrivate *p = static_cast<QQuickButtonGroupPrivate *>(prop->data);
- return p->buttons.count();
+ return p->buttons.size();
}
QQuickAbstractButton *QQuickButtonGroupPrivate::buttons_at(QQmlListProperty<QQuickAbstractButton> *prop, qsizetype index)
@@ -376,7 +376,7 @@ void QQuickButtonGroup::setCheckState(Qt::CheckState state)
if (d->checkedButton && state == Qt::Unchecked)
setCheckedButton(nullptr);
} else {
- for (QQuickAbstractButton *button : qAsConst(d->buttons))
+ for (QQuickAbstractButton *button : std::as_const(d->buttons))
button->setChecked(state == Qt::Checked);
}
d->settingCheckState = false;
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 6311981645..f90cf0254f 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -190,7 +190,7 @@ QVariant QQuickComboBoxDelegateModel::variantValue(int index, const QString &rol
const QVariant object = model.toList().value(index);
if (object.metaType() == QMetaType::fromType<QVariantMap>()) {
const QVariantMap data = object.toMap();
- if (data.count() == 1)
+ if (data.size() == 1)
return data.first();
}
}
@@ -441,10 +441,10 @@ void QQuickComboBoxPrivate::updateEditText()
if (extra.isAllocated() && extra->allowComplete && !text.isEmpty()) {
const QString completed = tryComplete(text);
- if (completed.length() > text.length()) {
+ if (completed.size() > text.size()) {
input->setText(completed);
// This will select the text backwards.
- input->select(completed.length(), text.length());
+ input->select(completed.size(), text.size());
return;
}
}
@@ -548,14 +548,14 @@ QString QQuickComboBoxPrivate::tryComplete(const QString &input)
continue;
// either the first or the shortest match
- if (match.isEmpty() || text.length() < match.length())
+ if (match.isEmpty() || text.size() < match.size())
match = text;
}
if (match.isEmpty())
return input;
- return input + match.mid(input.length());
+ return input + match.mid(input.size());
}
void QQuickComboBoxPrivate::setCurrentIndex(int index, Activation activate)
diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
index 85a1308604..45bdfcc5b3 100644
--- a/src/quicktemplates2/qquickcontainer.cpp
+++ b/src/quicktemplates2/qquickcontainer.cpp
@@ -296,7 +296,7 @@ void QQuickContainerPrivate::reorderItems()
QList<QQuickItem *> siblings = effectiveContentItem(contentItem)->childItems();
int to = 0;
- for (int i = 0; i < siblings.count(); ++i) {
+ for (int i = 0; i < siblings.size(); ++i) {
QQuickItem* sibling = siblings.at(i);
if (QQuickItemPrivate::get(sibling)->isTransparentForPositioner())
continue;
@@ -362,7 +362,7 @@ void QQuickContainerPrivate::contentData_append(QQmlListProperty<QObject> *prop,
qsizetype QQuickContainerPrivate::contentData_count(QQmlListProperty<QObject> *prop)
{
QQuickContainer *q = static_cast<QQuickContainer *>(prop->object);
- return QQuickContainerPrivate::get(q)->contentData.count();
+ return QQuickContainerPrivate::get(q)->contentData.size();
}
QObject *QQuickContainerPrivate::contentData_at(QQmlListProperty<QObject> *prop, qsizetype index)
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index e0d2740519..0f6d02ccbd 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -735,6 +735,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
quickCompleteDeferred(q, backgroundName(), background);
}
+/*
+ \internal
+
+ Hides an item that was replaced by a newer one, rather than
+ deleting it, as the item is typically created in QML and hence
+ we don't own it.
+*/
void QQuickControlPrivate::hideOldItem(QQuickItem *item)
{
if (!item)
@@ -753,6 +760,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
#endif
}
+/*
+ \internal
+
+ Named "unhide" because it's used for cases where an item
+ that was previously hidden by \l hideOldItem() wants to be
+ shown by a control again, such as a ScrollBar in ScrollView.
+*/
+void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
+{
+ Q_ASSERT(item);
+ qCDebug(lcItemManagement) << "unhiding old item" << item;
+
+ item->setVisible(true);
+ item->setParentItem(control);
+
+#if QT_CONFIG(accessibility)
+ // Add the item back in to the accessibility tree.
+ QQuickAccessibleAttached *accessible = accessibleAttached(item);
+ if (accessible)
+ accessible->setIgnored(false);
+#endif
+}
+
void QQuickControlPrivate::updateBaselineOffset()
{
Q_Q(QQuickControl);
diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h
index 736841ecbc..1832427a67 100644
--- a/src/quicktemplates2/qquickcontrol_p_p.h
+++ b/src/quicktemplates2/qquickcontrol_p_p.h
@@ -129,6 +129,7 @@ public:
virtual void executeBackground(bool complete = false);
static void hideOldItem(QQuickItem *item);
+ static void unhideOldItem(QQuickControl *control, QQuickItem *item);
void updateBaselineOffset();
diff --git a/src/quicktemplates2/qquickdialog.cpp b/src/quicktemplates2/qquickdialog.cpp
index 7ed05e2516..94e35d2fb1 100644
--- a/src/quicktemplates2/qquickdialog.cpp
+++ b/src/quicktemplates2/qquickdialog.cpp
@@ -25,7 +25,7 @@ QT_BEGIN_NAMESPACE
\image qtquickcontrols2-page-wireframe.png
- By default, Dialogs have \l focus.
+ By default, Dialogs have \l {QQuickItem::}{focus}.
\section1 Dialog Title and Buttons
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp
index f06bb147c9..abcd56c98a 100644
--- a/src/quicktemplates2/qquickdialogbuttonbox.cpp
+++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp
@@ -282,7 +282,7 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
std::stable_sort(buttons.begin(), buttons.end(), ButtonLayout(static_cast<QPlatformDialogHelper::ButtonLayout>(buttonLayout)));
- for (int i = 0; i < buttons.count() - 1; ++i)
+ for (int i = 0; i < buttons.size() - 1; ++i)
q->insertItem(i, buttons.at(i));
}
@@ -383,10 +383,8 @@ QQuickAbstractButton *QQuickDialogButtonBoxPrivate::createStandardButton(QPlatfo
QQmlContext *creationContext = delegate->creationContext();
if (!creationContext)
creationContext = qmlContext(q);
- QQmlContext *context = new QQmlContext(creationContext, q);
- context->setContextObject(q);
- QObject *object = delegate->beginCreate(context);
+ QObject *object = delegate->beginCreate(creationContext);
QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton*>(object);
if (button) {
QQuickDialogButtonBoxAttached *attached = qobject_cast<QQuickDialogButtonBoxAttached *>(qmlAttachedPropertiesObject<QQuickDialogButtonBox>(button, true));
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index caef208545..fca910138a 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -473,6 +473,12 @@ bool QQuickDrawerPrivate::handleMove(QQuickItem *item, const QPointF &point, ulo
bool QQuickDrawerPrivate::handleRelease(QQuickItem *item, const QPointF &point, ulong timestamp)
{
+ auto cleanup = qScopeGuard([this] {
+ popupItem->setKeepMouseGrab(false);
+ popupItem->setKeepTouchGrab(false);
+ pressPoint = QPointF();
+ touchId = -1;
+ });
if (pressPoint.isNull())
return false;
if (!popupItem->keepMouseGrab() && !popupItem->keepTouchGrab()) {
@@ -532,14 +538,8 @@ bool QQuickDrawerPrivate::handleRelease(QQuickItem *item, const QPointF &point,
}
}
- bool wasGrabbed = popupItem->keepMouseGrab() || popupItem->keepTouchGrab();
- popupItem->setKeepMouseGrab(false);
- popupItem->setKeepTouchGrab(false);
-
- pressPoint = QPointF();
- touchId = -1;
-
- return wasGrabbed;
+ // the cleanup() lambda will run before return
+ return popupItem->keepMouseGrab() || popupItem->keepTouchGrab();
}
void QQuickDrawerPrivate::handleUngrab()
diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp
index 20280824c0..f5c59ed4e0 100644
--- a/src/quicktemplates2/qquickmenu.cpp
+++ b/src/quicktemplates2/qquickmenu.cpp
@@ -254,11 +254,9 @@ QQuickItem *QQuickMenuPrivate::beginCreateItem()
if (!delegate)
return nullptr;
- QQmlContext *creationContext = delegate->creationContext();
- if (!creationContext)
- creationContext = qmlContext(q);
- QQmlContext *context = new QQmlContext(creationContext, q);
- context->setContextObject(q);
+ QQmlContext *context = delegate->creationContext();
+ if (!context)
+ context = qmlContext(q);
QObject *object = delegate->beginCreate(context);
QQuickItem *item = qobject_cast<QQuickItem *>(object);
diff --git a/src/quicktemplates2/qquickmenubar.cpp b/src/quicktemplates2/qquickmenubar.cpp
index f638320286..3f7fd853d4 100644
--- a/src/quicktemplates2/qquickmenubar.cpp
+++ b/src/quicktemplates2/qquickmenubar.cpp
@@ -49,17 +49,14 @@ QQuickItem *QQuickMenuBarPrivate::beginCreateItem(QQuickMenu *menu)
if (!delegate)
return nullptr;
- QQmlContext *creationContext = delegate->creationContext();
- if (!creationContext)
- creationContext = qmlContext(q);
- QQmlContext *context = new QQmlContext(creationContext, q);
- context->setContextObject(q);
+ QQmlContext *context = delegate->creationContext();
+ if (!context)
+ context = qmlContext(q);
QObject *object = delegate->beginCreate(context);
QQuickItem *item = qobject_cast<QQuickItem *>(object);
if (!item) {
delete object;
- delete context;
return nullptr;
}
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index 8cf6e40f66..cdb40e2e8b 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -41,7 +41,7 @@ QList<QQuickPopup *> QQuickOverlayPrivate::stackingOrderPopups() const
const QList<QQuickItem *> children = paintOrderChildItems();
QList<QQuickPopup *> popups;
- popups.reserve(children.count());
+ popups.reserve(children.size());
for (auto it = children.crbegin(), end = children.crend(); it != end; ++it) {
QQuickPopup *popup = qobject_cast<QQuickPopup *>((*it)->parent());
@@ -52,10 +52,10 @@ QList<QQuickPopup *> QQuickOverlayPrivate::stackingOrderPopups() const
return popups;
}
-QList<QQuickDrawer *> QQuickOverlayPrivate::stackingOrderDrawers() const
+QList<QQuickPopup *> QQuickOverlayPrivate::stackingOrderDrawers() const
{
- QList<QQuickDrawer *> sorted(allDrawers);
- std::sort(sorted.begin(), sorted.end(), [](const QQuickDrawer *one, const QQuickDrawer *another) {
+ QList<QQuickPopup *> sorted(allDrawers);
+ std::sort(sorted.begin(), sorted.end(), [](const QQuickPopup *one, const QQuickPopup *another) {
return one->z() > another->z();
});
return sorted;
@@ -83,8 +83,10 @@ bool QQuickOverlayPrivate::startDrag(QEvent *event, const QPointF &pos)
}
}
- const QList<QQuickDrawer *> drawers = stackingOrderDrawers();
- for (QQuickDrawer *drawer : drawers) {
+ const QList<QQuickPopup *> drawers = stackingOrderDrawers();
+ for (QQuickPopup *popup : drawers) {
+ QQuickDrawer *drawer = qobject_cast<QQuickDrawer *>(popup);
+ Q_ASSERT(drawer);
QQuickDrawerPrivate *p = QQuickDrawerPrivate::get(drawer);
if (p->startDrag(event)) {
setMouseGrabberPopup(drawer);
@@ -240,7 +242,7 @@ void QQuickOverlayPrivate::removePopup(QQuickPopup *popup)
{
Q_Q(QQuickOverlay);
allPopups.removeOne(popup);
- if (allDrawers.removeOne(qobject_cast<QQuickDrawer *>(popup)))
+ if (allDrawers.removeOne(popup))
q->setVisible(!allDrawers.isEmpty() || !q->childItems().isEmpty());
}
@@ -389,7 +391,7 @@ void QQuickOverlay::geometryChange(const QRectF &newGeometry, const QRectF &oldG
{
Q_D(QQuickOverlay);
QQuickItem::geometryChange(newGeometry, oldGeometry);
- for (QQuickPopup *popup : qAsConst(d->allPopups))
+ for (QQuickPopup *popup : std::as_const(d->allPopups))
QQuickPopupPrivate::get(popup)->resizeOverlay();
}
@@ -554,6 +556,34 @@ bool QQuickOverlay::eventFilter(QObject *object, QEvent *event)
d->handleRelease(d->window->contentItem(), event, nullptr);
break;
+ case QEvent::Wheel: {
+ // If the top item in the drawing-order is blocked by a modal popup, then
+ // eat the event. There is no scenario where the top most item is blocked
+ // by a popup, but an item further down in the drawing order is not.
+ QWheelEvent *we = static_cast<QWheelEvent *>(event);
+ const QVector<QQuickItem *> targetItems = d->deliveryAgentPrivate()->pointerTargets(
+ d->window->contentItem(), we, we->point(0), false, false);
+ if (targetItems.isEmpty())
+ break;
+
+ QQuickItem * const topItem = targetItems.first();
+ const auto popups = d->stackingOrderPopups();
+ // Eat the event if receiver topItem is not a child of a popup before
+ // the first modal popup.
+ for (const auto &popup : popups) {
+ const QQuickItem *popupItem = popup->popupItem();
+ if (!popupItem)
+ continue;
+ // if we reach a popup that contains the item, deliver the event
+ if (popupItem->isAncestorOf(topItem))
+ break;
+ // if the popup doesn't contain the item but is modal, eat the event
+ if (popup->overlayEvent(topItem, we))
+ return true;
+ }
+ break;
+ }
+
default:
break;
}
diff --git a/src/quicktemplates2/qquickoverlay_p_p.h b/src/quicktemplates2/qquickoverlay_p_p.h
index ba2ea3cdbb..38c214804f 100644
--- a/src/quicktemplates2/qquickoverlay_p_p.h
+++ b/src/quicktemplates2/qquickoverlay_p_p.h
@@ -23,9 +23,9 @@
QT_BEGIN_NAMESPACE
class QQuickPopup;
-class QQuickDrawer;
-class QQuickOverlayPrivate : public QQuickItemPrivate, public QQuickItemChangeListener
+class Q_AUTOTEST_EXPORT QQuickOverlayPrivate : public QQuickItemPrivate,
+ public QQuickItemChangeListener
{
public:
Q_DECLARE_PUBLIC(QQuickOverlay)
@@ -51,7 +51,7 @@ public:
void setMouseGrabberPopup(QQuickPopup *popup);
QList<QQuickPopup *> stackingOrderPopups() const;
- QList<QQuickDrawer *> stackingOrderDrawers() const;
+ QList<QQuickPopup *> stackingOrderDrawers() const;
void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
@@ -60,7 +60,9 @@ public:
QQmlComponent *modal = nullptr;
QQmlComponent *modeless = nullptr;
QList<QQuickPopup *> allPopups;
- QList<QQuickDrawer *> allDrawers;
+ // Store drawers as QQuickPopup instead of QQuickDrawer because they're no longer
+ // QQuickDrawer by the time removePopup is called.
+ QList<QQuickPopup *> allDrawers;
QPointer<QQuickPopup> mouseGrabberPopup;
};
diff --git a/src/quicktemplates2/qquickpane.cpp b/src/quicktemplates2/qquickpane.cpp
index 46d943c2bb..05e5c90883 100644
--- a/src/quicktemplates2/qquickpane.cpp
+++ b/src/quicktemplates2/qquickpane.cpp
@@ -165,7 +165,7 @@ qreal QQuickPanePrivate::getContentWidth() const
return cw;
const auto contentChildren = contentChildItems();
- if (contentChildren.count() == 1)
+ if (contentChildren.size() == 1)
return contentChildren.first()->implicitWidth();
return 0;
@@ -181,7 +181,7 @@ qreal QQuickPanePrivate::getContentHeight() const
return ch;
const auto contentChildren = contentChildItems();
- if (contentChildren.count() == 1)
+ if (contentChildren.size() == 1)
return contentChildren.first()->implicitHeight();
return 0;
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 05ce9175a4..f523d22d8f 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -283,6 +283,7 @@ void QQuickPopupPrivate::closeOrReject()
dialog->reject();
else
q->close();
+ touchId = -1;
}
bool QQuickPopupPrivate::tryClose(const QPointF &pos, QQuickPopup::ClosePolicy flags)
@@ -329,6 +330,12 @@ bool QQuickPopupPrivate::acceptTouch(const QTouchEvent::TouchPoint &point)
bool QQuickPopupPrivate::blockInput(QQuickItem *item, const QPointF &point) const
{
+ // don't propagate events within the popup beyond the overlay
+ if (popupItem->contains(popupItem->mapFromScene(point))
+ && item == QQuickOverlay::overlay(window)) {
+ return true;
+ }
+
// don't block presses and releases
// a) outside a non-modal popup,
// b) to popup children/content, or
@@ -413,7 +420,7 @@ bool QQuickPopupPrivate::handleTouchEvent(QQuickItem *item, QTouchEvent *event)
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
for (const QTouchEvent::TouchPoint &point : event->points()) {
- if (!acceptTouch(point))
+ if (event->type() != QEvent::TouchEnd && !acceptTouch(point))
return blockInput(item, point.position());
switch (point.state()) {
@@ -715,11 +722,9 @@ static QQuickItem *createDimmer(QQmlComponent *component, QQuickPopup *popup, QQ
{
QQuickItem *item = nullptr;
if (component) {
- QQmlContext *creationContext = component->creationContext();
- if (!creationContext)
- creationContext = qmlContext(popup);
- QQmlContext *context = new QQmlContext(creationContext, popup);
- context->setContextObject(popup);
+ QQmlContext *context = component->creationContext();
+ if (!context)
+ context = qmlContext(popup);
item = qobject_cast<QQuickItem*>(component->beginCreate(context));
}
@@ -2495,7 +2500,12 @@ void QQuickPopup::keyPressEvent(QKeyEvent *event)
return;
#if QT_CONFIG(shortcut)
- if (d->closePolicy.testFlag(QQuickPopup::CloseOnEscape) && event->matches(QKeySequence::Cancel)) {
+ if (d->closePolicy.testFlag(QQuickPopup::CloseOnEscape)
+ && (event->matches(QKeySequence::Cancel)
+#if defined(Q_OS_ANDROID)
+ || event->key() == Qt::Key_Back
+#endif
+ )) {
event->accept();
if (d->interactive)
d->closeOrReject();
diff --git a/src/quicktemplates2/qquickpopuppositioner.cpp b/src/quicktemplates2/qquickpopuppositioner.cpp
index 0e05e189c9..aecbc7373c 100644
--- a/src/quicktemplates2/qquickpopuppositioner.cpp
+++ b/src/quicktemplates2/qquickpopuppositioner.cpp
@@ -129,14 +129,18 @@ void QQuickPopupPositioner::reposition()
// if the popup doesn't fit horizontally inside the window, try flipping it around (left <-> right)
if (p->allowHorizontalFlip && (rect.left() < bounds.left() || rect.right() > bounds.right())) {
- const QRectF flipped(m_parentItem->mapToScene(QPointF(m_parentItem->width() - p->x - rect.width(), p->y)), rect.size());
+ const QPointF newTopLeft(m_parentItem->width() - p->x - rect.width(), p->y);
+ const QRectF flipped(m_parentItem->mapToItem(popupItem->parentItem(), newTopLeft),
+ rect.size());
if (flipped.intersected(bounds).width() > rect.intersected(bounds).width())
rect.moveLeft(flipped.left());
}
// if the popup doesn't fit vertically inside the window, try flipping it around (above <-> below)
if (p->allowVerticalFlip && (rect.top() < bounds.top() || rect.bottom() > bounds.bottom())) {
- const QRectF flipped(m_parentItem->mapToScene(QPointF(p->x, m_parentItem->height() - p->y - rect.height())), rect.size());
+ const QPointF newTopLeft(p->x, m_parentItem->height() - p->y - rect.height());
+ const QRectF flipped(m_parentItem->mapToItem(popupItem->parentItem(), newTopLeft),
+ rect.size());
if (flipped.intersected(bounds).height() > rect.intersected(bounds).height())
rect.moveTop(flipped.top());
}
diff --git a/src/quicktemplates2/qquickpresshandler.cpp b/src/quicktemplates2/qquickpresshandler.cpp
index b1c2208e99..d752bb36f1 100644
--- a/src/quicktemplates2/qquickpresshandler.cpp
+++ b/src/quicktemplates2/qquickpresshandler.cpp
@@ -20,7 +20,7 @@ void QQuickPressHandler::mousePressEvent(QMouseEvent *event)
if (Qt::LeftButton == (event->buttons() & Qt::LeftButton)) {
timer.start(QGuiApplication::styleHints()->mousePressAndHoldInterval(), control);
delayedMousePressEvent = new QMouseEvent(event->type(), event->position().toPoint(), event->globalPosition().toPoint(),
- event->button(), event->buttons(), event->modifiers());
+ event->button(), event->buttons(), event->modifiers(), event->pointingDevice());
} else {
timer.stop();
}
diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp
index 4b4660b0a5..c17f3e773e 100644
--- a/src/quicktemplates2/qquickscrollbar.cpp
+++ b/src/quicktemplates2/qquickscrollbar.cpp
@@ -903,6 +903,7 @@ void QQuickScrollBarAttachedPrivate::setFlickable(QQuickFlickable *item)
// The latter doesn't remove the listener but only resets its types. Thus, it leaves behind a dangling
// pointer on destruction.
QQuickItemPrivate::get(flickable)->removeItemChangeListener(this, QQuickItemPrivate::Geometry);
+ QQuickItemPrivate::get(flickable)->removeItemChangeListener(this, QQuickItemPrivate::Destroyed);
if (horizontal)
cleanupHorizontal();
if (vertical)
@@ -912,7 +913,10 @@ void QQuickScrollBarAttachedPrivate::setFlickable(QQuickFlickable *item)
flickable = item;
if (item) {
+ // Don't know how to combine these calls into one, and as long as they're separate calls,
+ // the remove* calls above need to be separate too, otherwise they will have no effect.
QQuickItemPrivate::get(item)->updateOrAddGeometryChangeListener(this, QQuickGeometryChange::Size);
+ QQuickItemPrivate::get(item)->updateOrAddItemChangeListener(this, QQuickItemPrivate::Destroyed);
if (horizontal)
initHorizontal();
if (vertical)
@@ -936,6 +940,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
if (parent && parent == flickable->parentItem())
horizontal->stackAfter(flickable);
+ // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
+ // on a ScrollView), we need to make sure that we un-hide it.
+ // We don't bother checking if the item is actually the old one, because
+ // if it's not, all of the things the function does (setting parent, visibility, etc.)
+ // should be no-ops anyway.
+ if (auto control = qobject_cast<QQuickControl*>(q_func()->parent()))
+ QQuickControlPrivate::unhideOldItem(control, horizontal);
+
layoutHorizontal();
horizontal->setSize(area->property("widthRatio").toReal());
horizontal->setPosition(area->property("xPosition").toReal());
@@ -957,6 +969,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
if (parent && parent == flickable->parentItem())
vertical->stackAfter(flickable);
+ if (auto control = qobject_cast<QQuickControl*>(q_func()->parent()))
+ QQuickControlPrivate::unhideOldItem(control, vertical);
+
layoutVertical();
vertical->setSize(area->property("heightRatio").toReal());
vertical->setPosition(area->property("yPosition").toReal());
@@ -1115,6 +1130,8 @@ void QQuickScrollBarAttachedPrivate::itemImplicitHeightChanged(QQuickItem *item)
void QQuickScrollBarAttachedPrivate::itemDestroyed(QQuickItem *item)
{
+ if (item == flickable)
+ flickable = nullptr;
if (item == horizontal)
horizontal = nullptr;
if (item == vertical)
diff --git a/src/quicktemplates2/qquickshortcutcontext.cpp b/src/quicktemplates2/qquickshortcutcontext.cpp
index 6905f39e01..2d07eb44f9 100644
--- a/src/quicktemplates2/qquickshortcutcontext.cpp
+++ b/src/quicktemplates2/qquickshortcutcontext.cpp
@@ -8,11 +8,14 @@
#include "qquickmenu_p_p.h"
#include "qquickpopup_p.h"
+#include <QtCore/qloggingcategory.h>
#include <QtGui/qguiapplication.h>
#include <QtQuick/qquickrendercontrol.h>
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcContextMatcher, "qt.quick.controls.shortcutcontext.matcher")
+
static bool isBlockedByPopup(QQuickItem *item)
{
if (!item || !item->window())
@@ -64,6 +67,8 @@ bool QQuickShortcutContext::matcher(QObject *obj, Qt::ShortcutContext context)
}
if (QWindow *renderWindow = QQuickRenderControl::renderWindowFor(qobject_cast<QQuickWindow *>(obj)))
obj = renderWindow;
+ qCDebug(lcContextMatcher) << "obj" << obj << "focusWindow" << QGuiApplication::focusWindow()
+ << "!isBlockedByPopup(item)" << !isBlockedByPopup(item);
return obj && obj == QGuiApplication::focusWindow() && !isBlockedByPopup(item);
default:
return false;
diff --git a/src/quicktemplates2/qquicksplitview.cpp b/src/quicktemplates2/qquicksplitview.cpp
index c0f894ffa5..af405c8564 100644
--- a/src/quicktemplates2/qquicksplitview.cpp
+++ b/src/quicktemplates2/qquicksplitview.cpp
@@ -222,7 +222,7 @@ QT_BEGIN_NAMESPACE
*/
Q_LOGGING_CATEGORY(qlcQQuickSplitView, "qt.quick.controls.splitview")
-Q_LOGGING_CATEGORY(qlcQQuickSplitViewMouse, "qt.quick.controls.splitview.mouse")
+Q_LOGGING_CATEGORY(qlcQQuickSplitViewPointer, "qt.quick.controls.splitview.pointer")
Q_LOGGING_CATEGORY(qlcQQuickSplitViewState, "qt.quick.controls.splitview.state")
void QQuickSplitViewPrivate::updateFillIndex()
@@ -700,13 +700,11 @@ void QQuickSplitViewPrivate::createHandleItem(int index)
// If we don't use the correct context, it won't be possible to refer to
// the control's id from within the delegate.
- QQmlContext *creationContext = m_handle->creationContext();
+ QQmlContext *context = m_handle->creationContext();
// The component might not have been created in QML, in which case
// the creation context will be null and we have to create it ourselves.
- if (!creationContext)
- creationContext = qmlContext(q);
- QQmlContext *context = new QQmlContext(creationContext, q);
- context->setContextObject(q);
+ if (!context)
+ context = qmlContext(q);
QQuickItem *handleItem = qobject_cast<QQuickItem*>(m_handle->beginCreate(context));
if (handleItem) {
handleItem->setParent(q);
@@ -898,7 +896,7 @@ void QQuickSplitViewPrivate::updateHandleVisibilities()
void QQuickSplitViewPrivate::updateHoveredHandle(QQuickItem *hoveredItem)
{
- qCDebug(qlcQQuickSplitViewMouse) << "updating hovered handle after" << hoveredItem << "was hovered";
+ qCDebug(qlcQQuickSplitViewPointer) << "updating hovered handle after" << hoveredItem << "was hovered";
const int oldHoveredHandleIndex = m_hoveredHandleIndex;
m_hoveredHandleIndex = m_handleItems.indexOf(hoveredItem);
@@ -911,16 +909,16 @@ void QQuickSplitViewPrivate::updateHoveredHandle(QQuickItem *hoveredItem)
QQuickSplitHandleAttached *oldHoveredHandleAttached = qobject_cast<QQuickSplitHandleAttached*>(
qmlAttachedPropertiesObject<QQuickSplitHandleAttached>(oldHoveredHandle, true));
QQuickSplitHandleAttachedPrivate::get(oldHoveredHandleAttached)->setHovered(false);
- qCDebug(qlcQQuickSplitViewMouse) << "handle item at index" << oldHoveredHandleIndex << "is no longer hovered";
+ qCDebug(qlcQQuickSplitViewPointer) << "handle item at index" << oldHoveredHandleIndex << "is no longer hovered";
}
if (m_hoveredHandleIndex != -1) {
QQuickSplitHandleAttached *handleAttached = qobject_cast<QQuickSplitHandleAttached*>(
qmlAttachedPropertiesObject<QQuickSplitHandleAttached>(hoveredItem, true));
QQuickSplitHandleAttachedPrivate::get(handleAttached)->setHovered(true);
- qCDebug(qlcQQuickSplitViewMouse) << "handle item at index" << m_hoveredHandleIndex << "is now hovered";
+ qCDebug(qlcQQuickSplitViewPointer) << "handle item at index" << m_hoveredHandleIndex << "is now hovered";
} else {
- qCDebug(qlcQQuickSplitViewMouse) << "either there is no hovered item or" << hoveredItem << "is not a handle";
+ qCDebug(qlcQQuickSplitViewPointer) << "either there is no hovered item or" << hoveredItem << "is not a handle";
}
}
@@ -989,7 +987,7 @@ bool QQuickSplitViewPrivate::handlePress(const QPointF &point, ulong timestamp)
setResizing(true);
- qCDebug(qlcQQuickSplitViewMouse).nospace() << "handled press -"
+ qCDebug(qlcQQuickSplitViewPointer).nospace() << "handled press -"
<< " left/top index=" << m_pressedHandleIndex << ","
<< " size before press=" << m_leftOrTopItemSizeBeforePress << ","
<< " item=" << leftOrTopItem
@@ -1382,27 +1380,51 @@ void QQuickSplitView::hoverLeaveEvent(QHoverEvent *event)
bool QQuickSplitView::childMouseEventFilter(QQuickItem *item, QEvent *event)
{
Q_D(QQuickSplitView);
- qCDebug(qlcQQuickSplitViewMouse) << "childMouseEventFilter called with" << item << event;
-
- if (event->type() == QEvent::MouseButtonPress) {
- QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
- const QPointF point = mapFromItem(item, mouseEvent->position());
- d->handlePress(point, mouseEvent->timestamp());
-
- // Keep the mouse grab if this item belongs to the handle,
- // otherwise this event can be stolen e.g. Flickable if we're inside it.
- if (d->m_pressedHandleIndex != -1)
- item->setKeepMouseGrab(true);
- }
- else if (event->type() == QEvent::MouseButtonRelease) {
- QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
- const QPointF point = mapFromItem(item, mouseEvent->position());
- d->handleRelease(point, mouseEvent->timestamp());
- }
- else if (event->type() == QEvent::MouseMove) {
- QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
- const QPointF point = mapFromItem(item, mouseEvent->position());
- d->handleMove(point, mouseEvent->timestamp());
+ qCDebug(qlcQQuickSplitViewPointer) << "childMouseEventFilter called with" << item << event;
+
+ if (Q_LIKELY(event->isPointerEvent())) {
+ auto *pointerEvent = static_cast<QPointerEvent *>(event);
+ const auto &eventPoint = pointerEvent->points().first();
+ const QPointF point = mapFromItem(item, eventPoint.position());
+ const auto timestamp = pointerEvent->timestamp();
+
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ d->handlePress(point, timestamp);
+ // Keep the mouse grab if this item belongs to the handle,
+ // otherwise this event can be stolen e.g. Flickable if we're inside it.
+ if (d->m_pressedHandleIndex != -1)
+ item->setKeepMouseGrab(true);
+ break;
+ case QEvent::MouseButtonRelease:
+ d->handleRelease(point, timestamp);
+ break;
+ case QEvent::MouseMove:
+ d->handleMove(point, timestamp);
+ break;
+ case QEvent::TouchBegin:
+ if (pointerEvent->pointCount() == 1) {
+ d->handlePress(point, timestamp);
+ // We filter the event on behalf of item, but we want the item
+ // to be the exclusive grabber so that we can continue to filter
+ // touch events for it.
+ if (d->m_pressedHandleIndex != -1) {
+ item->setKeepTouchGrab(true);
+ pointerEvent->setExclusiveGrabber(eventPoint, item);
+ }
+ }
+ break;
+ case QEvent::TouchEnd:
+ if (pointerEvent->pointCount() == 1)
+ d->handleRelease(point, timestamp);
+ break;
+ case QEvent::TouchUpdate:
+ if (pointerEvent->pointCount() == 1)
+ d->handleMove(point, timestamp);
+ break;
+ default:
+ break;
+ }
}
// If this event belongs to the handle, filter it. (d->m_pressedHandleIndex != -1) means that
diff --git a/src/quicktemplates2/qquickstackelement.cpp b/src/quicktemplates2/qquickstackelement.cpp
index 09790d4f93..e165a780bb 100644
--- a/src/quicktemplates2/qquickstackelement.cpp
+++ b/src/quicktemplates2/qquickstackelement.cpp
@@ -79,8 +79,6 @@ QQuickStackElement::~QQuickStackElement()
if (attached)
emit attached->removed();
-
- delete context;
}
QQuickStackElement *QQuickStackElement::fromString(const QString &str, QQuickStackView *view, QString *error)
@@ -134,11 +132,9 @@ bool QQuickStackElement::load(QQuickStackView *parent)
return true;
}
- QQmlContext *creationContext = component->creationContext();
- if (!creationContext)
- creationContext = qmlContext(parent);
- context = new QQmlContext(creationContext, parent);
- context->setContextObject(parent);
+ QQmlContext *context = component->creationContext();
+ if (!context)
+ context = qmlContext(parent);
QQuickStackIncubator incubator(this);
component->create(incubator, context);
diff --git a/src/quicktemplates2/qquickstackelement_p_p.h b/src/quicktemplates2/qquickstackelement_p_p.h
index 2e38e42c47..f591e8fd5d 100644
--- a/src/quicktemplates2/qquickstackelement_p_p.h
+++ b/src/quicktemplates2/qquickstackelement_p_p.h
@@ -61,7 +61,6 @@ public:
bool ownComponent = false;
bool widthValid = false;
bool heightValid = false;
- QQmlContext *context = nullptr;
QQmlComponent *component = nullptr;
QQuickStackView *view = nullptr;
QPointer<QQuickItem> originalParent;
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp
index e65a2f18ad..1b16c6e581 100644
--- a/src/quicktemplates2/qquickstackview.cpp
+++ b/src/quicktemplates2/qquickstackview.cpp
@@ -387,7 +387,7 @@ bool QQuickStackView::isBusy() const
int QQuickStackView::depth() const
{
Q_D(const QQuickStackView);
- return d->elements.count();
+ return d->elements.size();
}
/*!
@@ -448,7 +448,7 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio
if (!engine || !func.isCallable()) // TODO: warning?
return nullptr;
- for (int i = d->elements.count() - 1; i >= 0; --i) {
+ for (int i = d->elements.size() - 1; i >= 0; --i) {
QQuickStackElement *element = d->elements.at(i);
if (behavior == ForceLoad)
element->load(this);
@@ -561,7 +561,7 @@ void QQuickStackView::push(QQmlV4Function *args)
if (!errors.isEmpty() || elements.isEmpty()) {
if (!errors.isEmpty()) {
- for (const QString &error : qAsConst(errors))
+ for (const QString &error : std::as_const(errors))
d->warn(error);
} else {
d->warn(QStringLiteral("nothing to push"));
@@ -574,9 +574,9 @@ void QQuickStackView::push(QQmlV4Function *args)
if (!d->elements.isEmpty())
exit = d->elements.top();
- int oldDepth = d->elements.count();
+ int oldDepth = d->elements.size();
if (d->pushElements(elements)) {
- d->depthChange(d->elements.count(), oldDepth);
+ d->depthChange(d->elements.size(), oldDepth);
QQuickStackElement *enter = d->elements.top();
d->startTransition(QQuickStackTransition::pushEnter(operation, enter, this),
QQuickStackTransition::pushExit(operation, exit, this),
@@ -640,14 +640,14 @@ void QQuickStackView::pop(QQmlV4Function *args)
QScopedValueRollback<bool> modifyingElements(d->modifyingElements, true);
QScopedValueRollback<QString> operationNameRollback(d->operation, operationName);
int argc = args->length();
- if (d->elements.count() <= 1 || argc > 2) {
+ if (d->elements.size() <= 1 || argc > 2) {
if (argc > 2)
d->warn(QStringLiteral("too many arguments"));
args->setReturnValue(QV4::Encode::null());
return;
}
- int oldDepth = d->elements.count();
+ int oldDepth = d->elements.size();
QQuickStackElement *exit = d->elements.pop();
QQuickStackElement *enter = d->elements.top();
@@ -686,7 +686,7 @@ void QQuickStackView::pop(QQmlV4Function *args)
d->removing.insert(exit);
previousItem = exit->item;
}
- d->depthChange(d->elements.count(), oldDepth);
+ d->depthChange(d->elements.size(), oldDepth);
d->startTransition(QQuickStackTransition::popExit(operation, exit, this),
QQuickStackTransition::popEnter(operation, enter, this),
operation == Immediate);
@@ -828,7 +828,7 @@ void QQuickStackView::replace(QQmlV4Function *args)
QList<QQuickStackElement *> elements = d->parseElements(target ? 1 : 0, args, &errors);
if (!errors.isEmpty() || elements.isEmpty()) {
if (!errors.isEmpty()) {
- for (const QString &error : qAsConst(errors))
+ for (const QString &error : std::as_const(errors))
d->warn(error);
} else {
d->warn(QStringLiteral("nothing to push"));
@@ -837,13 +837,13 @@ void QQuickStackView::replace(QQmlV4Function *args)
return;
}
- int oldDepth = d->elements.count();
+ int oldDepth = d->elements.size();
QQuickStackElement* exit = nullptr;
if (!d->elements.isEmpty())
exit = d->elements.pop();
if (exit != target ? d->replaceElements(target, elements) : d->pushElements(elements)) {
- d->depthChange(d->elements.count(), oldDepth);
+ d->depthChange(d->elements.size(), oldDepth);
if (exit) {
exit->removal = true;
d->removing.insert(exit);
@@ -914,7 +914,7 @@ void QQuickStackView::clear(Operation operation)
QQuickStackTransition::popEnter(operation, nullptr, this), false);
}
- int oldDepth = d->elements.count();
+ int oldDepth = d->elements.size();
d->setCurrentItem(nullptr);
qDeleteAll(d->elements);
d->elements.clear();
@@ -1115,7 +1115,7 @@ void QQuickStackView::componentComplete()
QScopedValueRollback<QString> operationNameRollback(d->operation, QStringLiteral("initialItem"));
QQuickStackElement *element = nullptr;
QString error;
- int oldDepth = d->elements.count();
+ int oldDepth = d->elements.size();
if (QObject *o = d->initialItem.toQObject())
element = QQuickStackElement::fromObject(o, this, &error);
else if (d->initialItem.isString())
@@ -1124,7 +1124,7 @@ void QQuickStackView::componentComplete()
d->warn(error);
delete element;
} else if (d->pushElement(element)) {
- d->depthChange(d->elements.count(), oldDepth);
+ d->depthChange(d->elements.size(), oldDepth);
d->setCurrentItem(element);
element->setStatus(QQuickStackView::Active);
}
@@ -1135,7 +1135,7 @@ void QQuickStackView::geometryChange(const QRectF &newGeometry, const QRectF &ol
QQuickControl::geometryChange(newGeometry, oldGeometry);
Q_D(QQuickStackView);
- for (QQuickStackElement *element : qAsConst(d->elements)) {
+ for (QQuickStackElement *element : std::as_const(d->elements)) {
if (element->item) {
if (!element->widthValid)
element->item->setWidth(newGeometry.width());
diff --git a/src/quicktemplates2/qquickstackview_p.cpp b/src/quicktemplates2/qquickstackview_p.cpp
index 23cdf0c41e..c867c55dcc 100644
--- a/src/quicktemplates2/qquickstackview_p.cpp
+++ b/src/quicktemplates2/qquickstackview_p.cpp
@@ -109,7 +109,7 @@ QList<QQuickStackElement *> QQuickStackViewPrivate::parseElements(int from, QQml
QQuickStackElement *QQuickStackViewPrivate::findElement(QQuickItem *item) const
{
if (item) {
- for (QQuickStackElement *e : qAsConst(elements)) {
+ for (QQuickStackElement *e : std::as_const(elements)) {
if (e->item == item)
return e;
}
@@ -165,7 +165,7 @@ bool QQuickStackViewPrivate::pushElements(const QList<QQuickStackElement *> &ele
Q_Q(QQuickStackView);
if (!elems.isEmpty()) {
for (QQuickStackElement *e : elems) {
- e->setIndex(elements.count());
+ e->setIndex(elements.size());
elements += e;
}
return elements.top()->load(q);
@@ -183,7 +183,7 @@ bool QQuickStackViewPrivate::pushElement(QQuickStackElement *element)
bool QQuickStackViewPrivate::popElements(QQuickStackElement *element)
{
Q_Q(QQuickStackView);
- while (elements.count() > 1 && elements.top() != element) {
+ while (elements.size() > 1 && elements.top() != element) {
delete elements.pop();
if (!element)
break;
@@ -287,7 +287,7 @@ void QQuickStackViewPrivate::viewItemTransitionFinished(QQuickItemViewTransition
QList<QQuickStackElement*> removedElements = removed;
removed.clear();
- for (QQuickStackElement *removedElement : qAsConst(removedElements)) {
+ for (QQuickStackElement *removedElement : std::as_const(removedElements)) {
// If an element with the same item is found in the active stack list,
// forget about the item so that we don't hide it.
if (removedElement->item && findElement(removedElement->item)) {
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index f3c57fe8fa..42343d1072 100644
--- a/src/quicktemplates2/qquickswipedelegate.cpp
+++ b/src/quicktemplates2/qquickswipedelegate.cpp
@@ -185,13 +185,11 @@ QQuickItem *QQuickSwipePrivate::createDelegateItem(QQmlComponent *component)
{
// If we don't use the correct context, it won't be possible to refer to
// the control's id from within the delegates.
- QQmlContext *creationContext = component->creationContext();
+ QQmlContext *context = component->creationContext();
// The component might not have been created in QML, in which case
// the creation context will be null and we have to create it ourselves.
- if (!creationContext)
- creationContext = qmlContext(control);
- QQmlContext *context = new QQmlContext(creationContext, control);
- context->setContextObject(control);
+ if (!context)
+ context = qmlContext(control);
QQuickItem *item = qobject_cast<QQuickItem*>(component->beginCreate(context));
if (item) {
item->setParentItem(control);
@@ -943,7 +941,7 @@ bool QQuickSwipeDelegatePrivate::attachedObjectsSetPressed(QQuickItem *item, QPo
bool found = false;
QVarLengthArray<QQuickItem *, 16> itemAndChildren;
itemAndChildren.append(item);
- for (int i = 0; i < itemAndChildren.count(); ++i) {
+ for (int i = 0; i < itemAndChildren.size(); ++i) {
auto item = itemAndChildren.at(i);
auto posInItem = item->mapFromScene(scenePos);
if (item->contains(posInItem)) {
diff --git a/src/quicktemplates2/qquicktabbar.cpp b/src/quicktemplates2/qquicktabbar.cpp
index 1421f0155d..a1dfc9068c 100644
--- a/src/quicktemplates2/qquicktabbar.cpp
+++ b/src/quicktemplates2/qquicktabbar.cpp
@@ -147,7 +147,7 @@ void QQuickTabBarPrivate::updateLayout()
const qreal itemWidth = (contentItem->width() - reservedWidth - totalSpacing) / qMax(1, resizableCount);
updatingLayout = true;
- for (QQuickItem *item : qAsConst(allItems)) {
+ for (QQuickItem *item : std::as_const(allItems)) {
QQuickItemPrivate *p = QQuickItemPrivate::get(item);
if (!p->widthValid()) {
item->setWidth(itemWidth);
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index 48bdcddb64..0572746d14 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -19,6 +19,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\qmltype TextArea
\inherits TextEdit
@@ -509,6 +511,10 @@ QQuickTextArea::QQuickTextArea(QQuickItem *parent)
QObjectPrivate::connect(this, &QQuickTextEdit::readOnlyChanged,
d, &QQuickTextAreaPrivate::readOnlyChanged);
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ if (qEnvironmentVariable("QT_QUICK_CONTROLS_TEXT_SELECTION_BEHAVIOR") == u"old"_s)
+ QQuickTextEdit::setOldSelectionDefault();
+#endif
}
QQuickTextArea::~QQuickTextArea()
diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
index 99f9b757c1..3e6d2a48a7 100644
--- a/src/quicktemplates2/qquicktextfield.cpp
+++ b/src/quicktemplates2/qquicktextfield.cpp
@@ -17,6 +17,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\qmltype TextField
\inherits TextInput
@@ -377,6 +379,10 @@ QQuickTextField::QQuickTextField(QQuickItem *parent)
#endif
QObjectPrivate::connect(this, &QQuickTextInput::readOnlyChanged, d, &QQuickTextFieldPrivate::readOnlyChanged);
QObjectPrivate::connect(this, &QQuickTextInput::echoModeChanged, d, &QQuickTextFieldPrivate::echoModeChanged);
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ if (qEnvironmentVariable("QT_QUICK_CONTROLS_TEXT_SELECTION_BEHAVIOR") == u"old"_s)
+ QQuickTextInput::setOldSelectionDefault();
+#endif
}
QQuickTextField::~QQuickTextField()
@@ -880,9 +886,12 @@ void QQuickTextField::mouseMoveEvent(QMouseEvent *event)
QQuickTextInput::mousePressEvent(d->pressHandler.delayedMousePressEvent);
d->pressHandler.clearDelayedMouseEvent();
}
- const auto devType = event->device()->type();
- if (event->buttons() != Qt::RightButton &&
- (devType == QInputDevice::DeviceType::Mouse || devType == QInputDevice::DeviceType::TouchPad))
+ const bool isMouse = QQuickDeliveryAgentPrivate::isEventFromMouseOrTouchpad(event)
+ #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ || d->selectByTouchDrag
+ #endif
+ ;
+ if (event->buttons() != Qt::RightButton && isMouse)
QQuickTextInput::mouseMoveEvent(event);
}
}
diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp
index 5ec4e00964..7703d57b53 100644
--- a/src/quicktemplates2/qquicktooltip.cpp
+++ b/src/quicktemplates2/qquicktooltip.cpp
@@ -47,6 +47,8 @@ QT_BEGIN_NAMESPACE
shown for the last item that made it visible. The position of the shared tool
tip is determined by the framework.
+ \include qquicktooltip.qdocinc customize-note
+
\section2 Delay and Timeout
Tool tips are typically transient in a sense that they are shown as a
diff --git a/src/quicktemplates2/qquicktreeviewdelegate.cpp b/src/quicktemplates2/qquicktreeviewdelegate.cpp
index 022d1ebf5c..f21b215dfe 100644
--- a/src/quicktemplates2/qquicktreeviewdelegate.cpp
+++ b/src/quicktemplates2/qquicktreeviewdelegate.cpp
@@ -68,34 +68,39 @@ QT_BEGIN_NAMESPACE
such as \l {AbstractButton::clicked()}{clicked} when the user clicks on the delegate.
If needed, you could connect to that signal to implement application specific
functionality, in addition to the default expand/collapse behavior (and even set \l
- {QQuickTableView::pointerNavigationEnabled}{pointerNavigationEnabled} to \c false, to
+ {TableView::pointerNavigationEnabled}{pointerNavigationEnabled} to \c false, to
disable the default behavior as well).
But the ItemDelegate API does not give you information about the position of the
click, or which modifiers are being held. If this is needed, a better approach would
- be to use pointer handlers. To ensure that they don't interfere with the
- existing logic in TreeViewDelegate, install them on a child item, e.g:
+ be to use pointer handlers, for example:
\code
TreeView {
id: treeView
delegate: TreeViewDelegate {
- Item {
- anchors.fill: parent
- TapHandler {
- acceptedModifiers: Qt.ControlModifier
- onTapped: {
- if (treeView.isExpanded(row))
- treeView.collapseRecursively(row)
- else
- treeView.expandRecursively(row)
- }
+ TapHandler {
+ acceptedButtons: Qt.RightButton
+ onTapped: someContextMenu.open()
+ }
+
+ TapHandler {
+ acceptedModifiers: Qt.ControlModifier
+ onTapped: {
+ if (treeView.isExpanded(row))
+ treeView.collapseRecursively(row)
+ else
+ treeView.expandRecursively(row)
}
}
}
}
\endcode
+ \note If you want to disable the default behavior that occurs when the
+ user clicks on the delegate (like changing the current index), you can set
+ {QQuickTableView::pointerNavigationEnabled}{pointerNavigationEnabled} to \c false.
+
\sa TreeView
*/
@@ -145,7 +150,7 @@ QT_BEGIN_NAMESPACE
This property holds if the delegate represent the
\l {QItemSelectionModel::currentIndex()}{current index}
- in the \l {QQuickTableView::selectionModel()}{selection model}.
+ in the \l {TableView::selectionModel}{selection model}.
*/
/*!
@@ -153,7 +158,7 @@ QT_BEGIN_NAMESPACE
This property holds if the delegate represent a
\l {QItemSelectionModel::selection()}{selected index}
- in the \l {QQuickTableView::selectionModel()}{selection model}.
+ in the \l {TableView::selectionModel}{selection model}.
*/
/*!
@@ -183,19 +188,21 @@ QT_BEGIN_NAMESPACE
\sa leftMargin, indentation, {QQuickControl::}{spacing}
*/
+using namespace Qt::Literals::StringLiterals;
+
class QQuickTreeViewDelegatePrivate : public QQuickItemDelegatePrivate
{
public:
Q_DECLARE_PUBLIC(QQuickTreeViewDelegate)
void updateIndicatorVisibility();
+ void updateIndicatorPointerHandlers();
+ void toggleExpanded();
QPalette defaultPalette() const override;
- bool posOnTopOfIndicator(const QPointF &pos);
- void handleClickOnIndicator(QMouseEvent *event, bool isPress);
- void setCurrentIndex(const QPointF pos);
public:
QPointer<QQuickTreeView> m_treeView;
+ QPointer<QQuickTapHandler> m_tapHandlerOnIndicator;
qreal m_indentation = 18;
qreal m_leftMargin = 0;
qreal m_rightMargin = 0;
@@ -208,86 +215,86 @@ public:
int m_depth = 0;
};
-void QQuickTreeViewDelegatePrivate::updateIndicatorVisibility()
-{
- Q_Q(QQuickTreeViewDelegate);
-
- if (auto indicator = q_func()->indicator()) {
- const bool insideDelegateBounds = indicator->x() + indicator->width() < q->width();
- indicator->setVisible(m_isTreeNode && m_hasChildren && insideDelegateBounds);
- }
-}
-
-bool QQuickTreeViewDelegatePrivate::posOnTopOfIndicator(const QPointF &pos)
-{
- Q_Q(QQuickTreeViewDelegate);
-
- const auto indicator = q->indicator();
- if (!indicator || !indicator->isVisible())
- return false;
-
- const auto posInIndicator = q->mapToItem(indicator, pos);
- if (!indicator->contains(posInIndicator))
- return false;
-
- return true;
-}
-
-void QQuickTreeViewDelegatePrivate::handleClickOnIndicator(QMouseEvent *event, bool isPress)
+void QQuickTreeViewDelegatePrivate::toggleExpanded()
{
Q_Q(QQuickTreeViewDelegate);
- event->accept();
-
- // To not interfere with flicking, we only toggle expanded on press
- // if the flickable is not interactive. Otherwise we do it on release.
- const bool interactOnRelease = q->treeView()->isInteractive();
- if (isPress == interactOnRelease)
- return;
-
auto view = q->treeView();
if (!view)
return;
+ if (!view->pointerNavigationEnabled())
+ return;
- const int row = qmlContext(q)->contextProperty(QStringLiteral("row")).toInt();
+ const int row = qmlContext(q)->contextProperty(u"row"_s).toInt();
view->toggleExpanded(row);
}
-void QQuickTreeViewDelegatePrivate::setCurrentIndex(const QPointF pos)
+void QQuickTreeViewDelegatePrivate::updateIndicatorPointerHandlers()
{
Q_Q(QQuickTreeViewDelegate);
- auto view = q->treeView();
- if (!view)
- return;
+ // Remove the tap handler that was installed
+ // on the previous indicator
+ delete m_tapHandlerOnIndicator.data();
- if (!view->pointerNavigationEnabled())
+ auto indicator = q->indicator();
+ if (!indicator)
return;
- const auto posOnContentItem = q->mapToItem(view->contentItem(), pos);
- const QPoint cell = view->cellAtPosition(posOnContentItem);
- if (cell.x() == -1 && cell.y() == -1)
- return;
+ m_tapHandlerOnIndicator = new QQuickTapHandler(indicator);
+ m_tapHandlerOnIndicator->setAcceptedModifiers(Qt::NoModifier);
+ // Work-around to block taps from passing through to TreeView.
+ m_tapHandlerOnIndicator->setGesturePolicy(QQuickTapHandler::ReleaseWithinBounds);
+ connect(m_tapHandlerOnIndicator, &QQuickTapHandler::tapped, this, &QQuickTreeViewDelegatePrivate::toggleExpanded);
+}
- QItemSelectionModel *model = view->selectionModel();
- if (!model)
- return;
+void QQuickTreeViewDelegatePrivate::updateIndicatorVisibility()
+{
+ Q_Q(QQuickTreeViewDelegate);
- model->setCurrentIndex(view->modelIndex(cell), QItemSelectionModel::NoUpdate);
- view->positionViewAtCell(cell, QQuickTableView::Contain);
- view->forceActiveFocus();
+ if (auto indicator = q_func()->indicator()) {
+ const bool insideDelegateBounds = indicator->x() + indicator->width() < q->width();
+ indicator->setVisible(m_isTreeNode && m_hasChildren && insideDelegateBounds);
+ }
}
QQuickTreeViewDelegate::QQuickTreeViewDelegate(QQuickItem *parent)
: QQuickItemDelegate(*(new QQuickTreeViewDelegatePrivate), parent)
{
+ Q_D(QQuickTreeViewDelegate);
+
+ auto tapHandler = new QQuickTapHandler(this);
+ tapHandler->setAcceptedModifiers(Qt::NoModifier);
+ QObjectPrivate::connect(tapHandler, &QQuickTapHandler::doubleTapped, d_func(), &QQuickTreeViewDelegatePrivate::toggleExpanded);
+ QObjectPrivate::connect(this, &QQuickAbstractButton::indicatorChanged, d, &QQuickTreeViewDelegatePrivate::updateIndicatorPointerHandlers);
+
+ // Since we override mousePressEvent to avoid QQuickAbstractButton from blocking
+ // pointer handlers, we inform the button about its pressed state from the tap
+ // handler instead. This will ensure that we emit button signals like
+ // pressed, clicked, and doubleClicked.
+ connect(tapHandler, &QQuickTapHandler::pressedChanged, [this, d, tapHandler] {
+ auto view = treeView();
+ if (view && !view->pointerNavigationEnabled())
+ return;
+
+ const QQuickHandlerPoint p = tapHandler->point();
+ if (tapHandler->isPressed())
+ d->handlePress(p.position(), 0);
+ else if (tapHandler->tapCount() > 0)
+ d->handleRelease(p.position(), 0);
+ else
+ d->handleUngrab();
+
+ if (tapHandler->tapCount() > 1 && !tapHandler->isPressed())
+ emit doubleClicked();
+ });
}
void QQuickTreeViewDelegate::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
{
Q_D(QQuickTreeViewDelegate);
- QQuickAbstractButton::geometryChange(newGeometry, oldGeometry);
+ QQuickItemDelegate::geometryChange(newGeometry, oldGeometry);
d->updateIndicatorVisibility();
}
@@ -295,67 +302,17 @@ void QQuickTreeViewDelegate::mousePressEvent(QMouseEvent *event)
{
Q_D(QQuickTreeViewDelegate);
- if (d->m_treeView && !d->m_treeView->pointerNavigationEnabled()) {
- QQuickAbstractButton::mousePressEvent(event);
- return;
- }
-
- d->m_pressOnTopOfIndicator = d->posOnTopOfIndicator(event->position());
- if (d->m_pressOnTopOfIndicator) {
- d->handleClickOnIndicator(event, true);
- return;
- }
-
- const bool interactOnPress = !treeView()->isInteractive();
- if (interactOnPress && contains(event->position())) {
- d->setCurrentIndex(event->position());
- if (d->m_treeView && d->m_treeView->selectionModel())
- d->m_treeView->selectionModel()->clearSelection();
- }
-
- QQuickAbstractButton::mousePressEvent(event);
-}
-
-void QQuickTreeViewDelegate::mouseReleaseEvent(QMouseEvent *event)
-{
- Q_D(QQuickTreeViewDelegate);
-
- if (d->m_pressOnTopOfIndicator) {
- if (d->posOnTopOfIndicator(event->position()))
- d->handleClickOnIndicator(event, false);
- return;
- }
-
- const bool interactOnRelease = treeView()->isInteractive();
- if (interactOnRelease && contains(event->position())) {
- d->setCurrentIndex(event->position());
- if (d->m_treeView && d->m_treeView->selectionModel())
- d->m_treeView->selectionModel()->clearSelection();
- }
-
- QQuickAbstractButton::mouseReleaseEvent(event);
-}
-
-void QQuickTreeViewDelegate::mouseDoubleClickEvent(QMouseEvent *event)
-{
- Q_D(QQuickTreeViewDelegate);
-
- if (d->m_treeView && !d->m_treeView->pointerNavigationEnabled()) {
- QQuickAbstractButton::mouseDoubleClickEvent(event);
+ const auto view = d->m_treeView;
+ if (view && view->pointerNavigationEnabled()) {
+ // Ignore mouse events so that we don't block our own pointer handlers, or
+ // pointer handlers in e.g TreeView, TableView, or SelectionRectangle. Instead
+ // we call out to the needed mouse handling functions in QAbstractButton directly
+ // from our pointer handlers, to ensure that continue to work as a button.
+ event->ignore();
return;
}
- event->accept();
-
- if (d->posOnTopOfIndicator(event->position()))
- return;
-
- if (auto view = treeView()) {
- const int row = qmlContext(this)->contextProperty(QStringLiteral("row")).toInt();
- view->toggleExpanded(row);
- }
-
- QQuickAbstractButton::mouseDoubleClickEvent(event);
+ QQuickItemDelegate::mousePressEvent(event);
}
QPalette QQuickTreeViewDelegatePrivate::defaultPalette() const
@@ -492,8 +449,10 @@ void QQuickTreeViewDelegate::setTreeView(QQuickTreeView *treeView)
void QQuickTreeViewDelegate::componentComplete()
{
- QQuickAbstractButton::componentComplete();
- d_func()->updateIndicatorVisibility();
+ Q_D(QQuickTreeViewDelegate);
+ QQuickItemDelegate::componentComplete();
+ d->updateIndicatorVisibility();
+ d->updateIndicatorPointerHandlers();
}
qreal QQuickTreeViewDelegate::leftMargin() const
diff --git a/src/quicktemplates2/qquicktreeviewdelegate_p.h b/src/quicktemplates2/qquicktreeviewdelegate_p.h
index 60acb7f221..de85f7c2cd 100644
--- a/src/quicktemplates2/qquicktreeviewdelegate_p.h
+++ b/src/quicktemplates2/qquicktreeviewdelegate_p.h
@@ -94,8 +94,6 @@ protected:
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
void componentComplete() override;
void mousePressEvent(QMouseEvent *event) override;
- void mouseReleaseEvent(QMouseEvent *event) override;
- void mouseDoubleClickEvent(QMouseEvent *event) override;
private:
Q_DISABLE_COPY(QQuickTreeViewDelegate)
diff --git a/src/quicktestutils/qml/testhttpserver.cpp b/src/quicktestutils/qml/testhttpserver.cpp
index 5a9cb6a1cd..9873cd1827 100644
--- a/src/quicktestutils/qml/testhttpserver.cpp
+++ b/src/quicktestutils/qml/testhttpserver.cpp
@@ -165,7 +165,7 @@ bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &bod
if (headers_done) {
m_waitData.body.append(line);
} else if (line.endsWith("{{Ignore}}\n")) {
- m_waitData.headerPrefixes.append(line.left(line.length() - strlen("{{Ignore}}\n")));
+ m_waitData.headerPrefixes.append(line.left(line.size() - strlen("{{Ignore}}\n")));
} else {
line.replace("{{ServerHostUrl}}", serverHostUrl);
m_waitData.headerExactMatches.append(line);
@@ -177,7 +177,7 @@ bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &bod
if (!m_replyData.endsWith('\n'))
m_replyData.append('\n');
m_replyData.append("Content-length: ");
- m_replyData.append(QByteArray::number(m_bodyData.length()));
+ m_replyData.append(QByteArray::number(m_bodyData.size()));
m_replyData.append("\n\n");
for (int ii = 0; ii < m_replyData.size(); ++ii) {
@@ -216,7 +216,7 @@ void TestHTTPServer::disconnected()
return;
m_dataCache.remove(socket);
- for (int ii = 0; ii < m_toSend.count(); ++ii) {
+ for (int ii = 0; ii < m_toSend.size(); ++ii) {
if (m_toSend.at(ii).first == socket) {
m_toSend.removeAt(ii);
--ii;
@@ -237,7 +237,7 @@ void TestHTTPServer::readyRead()
return;
}
- if (m_state == Failed || (m_waitData.body.isEmpty() && m_waitData.headerExactMatches.count() == 0)) {
+ if (m_state == Failed || (m_waitData.body.isEmpty() && m_waitData.headerExactMatches.size() == 0)) {
qWarning() << "TestHTTPServer: Unexpected data" << socket->readAll();
return;
}
@@ -301,7 +301,7 @@ bool TestHTTPServer::reply(QTcpSocket *socket, const QByteArray &fileNameIn)
return true;
}
- for (int ii = 0; ii < m_directories.count(); ++ii) {
+ for (int ii = 0; ii < m_directories.size(); ++ii) {
const QString &dir = m_directories.at(ii).first;
const Mode mode = m_directories.at(ii).second;
diff --git a/src/quicktestutils/quick/viewtestutils.cpp b/src/quicktestutils/quick/viewtestutils.cpp
index 9249f4bfad..19e29928bb 100644
--- a/src/quicktestutils/quick/viewtestutils.cpp
+++ b/src/quicktestutils/quick/viewtestutils.cpp
@@ -7,6 +7,7 @@
#include <QtQuick/QQuickView>
#include <QtQuick/QQuickView>
#include <QtGui/QScreen>
+#include <QtGui/qpa/qwindowsysteminterface.h>
#include <QtTest/QTest>
@@ -78,7 +79,7 @@ void QQuickViewTestUtils::flick(QQuickView *window, const QPoint &from, const QP
QList<int> QQuickViewTestUtils::adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count)
{
QList<int> result;
- for (int i=0; i<indexes.count(); i++) {
+ for (int i=0; i<indexes.size(); i++) {
int num = indexes[i];
if (num >= index) {
num += count;
@@ -91,7 +92,7 @@ QList<int> QQuickViewTestUtils::adjustIndexesForAddDisplaced(const QList<int> &i
QList<int> QQuickViewTestUtils::adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count)
{
QList<int> result;
- for (int i=0; i<indexes.count(); i++) {
+ for (int i=0; i<indexes.size(); i++) {
int num = indexes[i];
if (from < to) {
if (num >= from && num < from + count)
@@ -112,7 +113,7 @@ QList<int> QQuickViewTestUtils::adjustIndexesForMove(const QList<int> &indexes,
QList<int> QQuickViewTestUtils::adjustIndexesForRemoveDisplaced(const QList<int> &indexes, int index, int count)
{
QList<int> result;
- for (int i=0; i<indexes.count(); i++) {
+ for (int i=0; i<indexes.size(); i++) {
int num = indexes[i];
if (num >= index)
num -= count;
@@ -129,7 +130,7 @@ QQuickViewTestUtils::QaimModel::QaimModel(QObject *parent)
int QQuickViewTestUtils::QaimModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
- return list.count();
+ return list.size();
}
int QQuickViewTestUtils::QaimModel::columnCount(const QModelIndex &parent) const
@@ -174,15 +175,15 @@ QString QQuickViewTestUtils::QaimModel::number(int index) const
void QQuickViewTestUtils::QaimModel::addItem(const QString &name, const QString &number)
{
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ emit beginInsertRows(QModelIndex(), list.size(), list.size());
list.append(QPair<QString,QString>(name, number));
emit endInsertRows();
}
void QQuickViewTestUtils::QaimModel::addItems(const QList<QPair<QString, QString> > &items)
{
- emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1);
- for (int i=0; i<items.count(); i++)
+ emit beginInsertRows(QModelIndex(), list.size(), list.size()+items.size()-1);
+ for (int i=0; i<items.size(); i++)
list.append(QPair<QString,QString>(items[i].first, items[i].second));
emit endInsertRows();
}
@@ -196,8 +197,8 @@ void QQuickViewTestUtils::QaimModel::insertItem(int index, const QString &name,
void QQuickViewTestUtils::QaimModel::insertItems(int index, const QList<QPair<QString, QString> > &items)
{
- emit beginInsertRows(QModelIndex(), index, index+items.count()-1);
- for (int i=0; i<items.count(); i++)
+ emit beginInsertRows(QModelIndex(), index, index+items.size()-1);
+ for (int i=0; i<items.size(); i++)
list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second));
emit endInsertRows();
}
@@ -239,7 +240,7 @@ void QQuickViewTestUtils::QaimModel::modifyItem(int idx, const QString &name, co
void QQuickViewTestUtils::QaimModel::clear()
{
- int count = list.count();
+ int count = list.size();
if (count > 0) {
beginRemoveRows(QModelIndex(), 0, count-1);
list.clear();
@@ -275,11 +276,11 @@ private:
};
void QQuickViewTestUtils::QaimModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) {
- for (int i=0; i<other.count(); i++) {
+ for (int i=0; i<other.size(); i++) {
QVERIFY2(list.contains(other[i]),
ScopedPrintable(other[i].first + QLatin1Char(' ') + other[i].second + QLatin1Char(' ') + error1));
}
- for (int i=0; i<list.count(); i++) {
+ for (int i=0; i<list.size(); i++) {
QVERIFY2(other.contains(list[i]),
ScopedPrintable(list[i].first + QLatin1Char(' ') + list[i].second + QLatin1Char(' ') + error2));
}
@@ -336,7 +337,7 @@ bool QQuickViewTestUtils::ListRange::isValid() const
int QQuickViewTestUtils::ListRange::count() const
{
- return indexes.count();
+ return indexes.size();
}
QList<QPair<QString,QString> > QQuickViewTestUtils::ListRange::getModelDataValues(const QaimModel &model)
@@ -344,7 +345,7 @@ QList<QPair<QString,QString> > QQuickViewTestUtils::ListRange::getModelDataValue
QList<QPair<QString,QString> > data;
if (!valid)
return data;
- for (int i=0; i<indexes.count(); i++)
+ for (int i=0; i<indexes.size(); i++)
data.append(qMakePair(model.name(indexes[i]), model.number(indexes[i])));
return data;
}
@@ -395,7 +396,7 @@ bool QQuickViewTestUtils::testVisibleItems(const QQuickItemViewPrivate *priv, bo
QHash<QQuickItem*, int> uniqueItems;
int skip = 0;
- for (int i = 0; i < priv->visibleItems.count(); ++i) {
+ for (int i = 0; i < priv->visibleItems.size(); ++i) {
FxViewItem *item = priv->visibleItems.at(i);
if (!item) {
*failItem = nullptr;
@@ -446,6 +447,10 @@ namespace QQuickTouchUtils {
}
+namespace QTest {
+ int Q_TESTLIB_EXPORT defaultMouseDelay();
+}
+
namespace QQuickTest {
/*! \internal
@@ -503,6 +508,88 @@ namespace QQuickTest {
return false;
return true;
}
+
+ // TODO maybe move the generic pointerPress/Move/Release functions to QTestLib later on
+
+ static Qt::MouseButton pressedTabletButton = Qt::NoButton;
+ static Qt::KeyboardModifiers pressedTabletModifiers = Qt::NoModifier;
+
+ void pointerPress(const QPointingDevice *dev, QQuickWindow *window, int pointId, const QPoint &p,
+ Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
+ {
+ switch (dev->type()) {
+ case QPointingDevice::DeviceType::Mouse:
+ case QPointingDevice::DeviceType::TouchPad:
+ QTest::mousePress(window, button, modifiers, p);
+ break;
+ case QPointingDevice::DeviceType::TouchScreen:
+ QTest::touchEvent(window, const_cast<QPointingDevice *>(dev)).press(pointId, p, window);
+ QQuickTouchUtils::flush(window);
+ break;
+ case QPointingDevice::DeviceType::Puck:
+ case QPointingDevice::DeviceType::Stylus:
+ case QPointingDevice::DeviceType::Airbrush:
+ QTest::lastMouseTimestamp += QTest::defaultMouseDelay();
+ pressedTabletButton = button;
+ pressedTabletModifiers = modifiers;
+ QWindowSystemInterface::handleTabletEvent(window, QTest::lastMouseTimestamp, dev, p, window->mapToGlobal(p),
+ button, 0.8, 0, 0, 0, 0, 0, modifiers);
+ break;
+ default:
+ qWarning() << "can't send a press event from" << dev;
+ break;
+ }
+ }
+
+ void pointerMove(const QPointingDevice *dev, QQuickWindow *window, int pointId, const QPoint &p)
+ {
+ switch (dev->type()) {
+ case QPointingDevice::DeviceType::Mouse:
+ case QPointingDevice::DeviceType::TouchPad:
+ QTest::mouseMove(window, p);
+ break;
+ case QPointingDevice::DeviceType::TouchScreen:
+ QTest::touchEvent(window, const_cast<QPointingDevice *>(dev)).move(pointId, p, window);
+ QQuickTouchUtils::flush(window);
+ break;
+ case QPointingDevice::DeviceType::Puck:
+ case QPointingDevice::DeviceType::Stylus:
+ case QPointingDevice::DeviceType::Airbrush:
+ QTest::lastMouseTimestamp += QTest::defaultMouseDelay();
+ QWindowSystemInterface::handleTabletEvent(window, QTest::lastMouseTimestamp, dev, p, window->mapToGlobal(p),
+ pressedTabletButton, 0, 0, 0, 0, 0, 0, pressedTabletModifiers);
+ break;
+ default:
+ qWarning() << "can't send a move event from" << dev;
+ break;
+ }
+ }
+
+ void pointerRelease(const QPointingDevice *dev, QQuickWindow *window, int pointId, const QPoint &p,
+ Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
+ {
+ switch (dev->type()) {
+ case QPointingDevice::DeviceType::Mouse:
+ case QPointingDevice::DeviceType::TouchPad:
+ QTest::mouseRelease(window, button, modifiers, p);
+ break;
+ case QPointingDevice::DeviceType::TouchScreen:
+ QTest::touchEvent(window, const_cast<QPointingDevice *>(dev)).release(pointId, p, window);
+ QQuickTouchUtils::flush(window);
+ break;
+ case QPointingDevice::DeviceType::Puck:
+ case QPointingDevice::DeviceType::Stylus:
+ case QPointingDevice::DeviceType::Airbrush:
+ QTest::lastMouseTimestamp += QTest::defaultMouseDelay();
+ QWindowSystemInterface::handleTabletEvent(window, QTest::lastMouseTimestamp, dev, p, window->mapToGlobal(p),
+ Qt::NoButton, 0, 0, 0, 0, 0, 0, modifiers);
+ break;
+ default:
+ qWarning() << "can't send a press event from" << dev;
+ break;
+ }
+ }
+
}
QT_END_NAMESPACE
diff --git a/src/quicktestutils/quick/viewtestutils_p.h b/src/quicktestutils/quick/viewtestutils_p.h
index b729fcf3fa..ff8905afa6 100644
--- a/src/quicktestutils/quick/viewtestutils_p.h
+++ b/src/quicktestutils/quick/viewtestutils_p.h
@@ -179,6 +179,17 @@ namespace QQuickTest {
[[nodiscard]] bool initView(QQuickView &v, const QUrl &url,
bool moveMouseOut = true, QByteArray *errorMessage = nullptr);
[[nodiscard]] bool showView(QQuickView &v, const QUrl &url);
+
+ void pointerPress(const QPointingDevice *dev, QQuickWindow *window,
+ int pointId, const QPoint &p, Qt::MouseButton button = Qt::LeftButton,
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+
+ void pointerMove(const QPointingDevice *dev, QQuickWindow *window, int pointId,
+ const QPoint &p);
+
+ void pointerRelease(const QPointingDevice *dev, QQuickWindow *window, int pointId,
+ const QPoint &p, Qt::MouseButton button = Qt::LeftButton,
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier);
}
QT_END_NAMESPACE
diff --git a/src/quicktestutils/quick/visualtestutils.cpp b/src/quicktestutils/quick/visualtestutils.cpp
index b7bd561028..ddbf8ca9f6 100644
--- a/src/quicktestutils/quick/visualtestutils.cpp
+++ b/src/quicktestutils/quick/visualtestutils.cpp
@@ -15,7 +15,7 @@ QQuickItem *QQuickVisualTestUtils::findVisibleChild(QQuickItem *parent, const QS
{
QQuickItem *item = nullptr;
QList<QQuickItem*> items = parent->findChildren<QQuickItem*>(objectName);
- for (int i = 0; i < items.count(); ++i) {
+ for (int i = 0; i < items.size(); ++i) {
if (items.at(i)->isVisible() && !QQuickItemPrivate::get(items.at(i))->culled) {
item = items.at(i);
break;
@@ -27,7 +27,7 @@ QQuickItem *QQuickVisualTestUtils::findVisibleChild(QQuickItem *parent, const QS
void QQuickVisualTestUtils::dumpTree(QQuickItem *parent, int depth)
{
static QString padding = QStringLiteral(" ");
- for (int i = 0; i < parent->childItems().count(); ++i) {
+ for (int i = 0; i < parent->childItems().size(); ++i) {
QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
if (!item)
continue;
diff --git a/src/quicktestutils/quick/visualtestutils_p.h b/src/quicktestutils/quick/visualtestutils_p.h
index 953d374327..ae618a04e0 100644
--- a/src/quicktestutils/quick/visualtestutils_p.h
+++ b/src/quicktestutils/quick/visualtestutils_p.h
@@ -46,7 +46,7 @@ namespace QQuickVisualTestUtils
using namespace Qt::StringLiterals;
const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->childItems().count(); ++i) {
+ for (int i = 0; i < parent->childItems().size(); ++i) {
QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
if (!item)
continue;
@@ -75,7 +75,7 @@ namespace QQuickVisualTestUtils
{
QList<T*> items;
const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->childItems().count(); ++i) {
+ for (int i = 0; i < parent->childItems().size(); ++i) {
QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
if (!item || (visibleOnly && (!item->isVisible() || QQuickItemPrivate::get(item)->culled)))
continue;
@@ -91,7 +91,7 @@ namespace QQuickVisualTestUtils
QList<T*> findItems(QQuickItem *parent, const QString &objectName, const QList<int> &indexes)
{
QList<T*> items;
- for (int i=0; i<indexes.count(); i++)
+ for (int i=0; i<indexes.size(); i++)
items << qobject_cast<QQuickItem*>(findItem<T>(parent, objectName, indexes[i]));
return items;
}
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index c4c313172e..b8bd2aca2f 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -249,7 +249,10 @@ void QQuickWidgetPrivate::handleWindowChange()
QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
- execute();
+ if (!source.isEmpty())
+ execute();
+ else if (QQuickItem *sgItem = qobject_cast<QQuickItem *>(root))
+ sgItem->setParentItem(offscreenWindow->contentItem());
}
QQuickWidgetPrivate::QQuickWidgetPrivate()
@@ -610,6 +613,7 @@ QQuickWidget::QQuickWidget(QWidget *parent)
{
setMouseTracking(true);
setFocusPolicy(Qt::StrongFocus);
+ setAttribute(Qt::WA_AcceptTouchEvents);
d_func()->init();
}
@@ -1620,9 +1624,23 @@ bool QQuickWidget::event(QEvent *e)
case QEvent::TouchBegin:
case QEvent::TouchEnd:
case QEvent::TouchUpdate:
- case QEvent::TouchCancel:
+ case QEvent::TouchCancel: {
// Touch events only have local and global positions, no need to map.
- return QCoreApplication::sendEvent(d->offscreenWindow, e);
+ bool res = QCoreApplication::sendEvent(d->offscreenWindow, e);
+ if (e->isAccepted() && e->type() == QEvent::TouchBegin) {
+ // If the TouchBegin got accepted, then make sure all points that have
+ // an exclusive grabber are also accepted so that the widget code for
+ // delivering touch events make this widget an implicit grabber of those
+ // points.
+ QPointerEvent *pointerEvent = static_cast<QPointerEvent *>(e);
+ auto deliveredPoints = pointerEvent->points();
+ for (auto &point : deliveredPoints) {
+ if (pointerEvent->exclusiveGrabber(point))
+ point.setAccepted(true);
+ }
+ }
+ return res;
+ }
case QEvent::FocusAboutToChange:
return QCoreApplication::sendEvent(d->offscreenWindow, e);
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 1dc26bbde9..6fb4b6cb2a 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -68,6 +68,7 @@ if(TARGET Qt::Qml)
If(NOT ANDROID) # QML only project cannot run on Android with C++ enty point
_qt_internal_test_expect_pass(qmlquery)
endif()
+ _qt_internal_test_expect_fail(test_internal_singleton)
endif()
if(TARGET Qt::Quick)
diff --git a/tests/auto/cmake/test_internal_singleton/CMakeLists.txt b/tests/auto/cmake/test_internal_singleton/CMakeLists.txt
new file mode 100644
index 0000000000..f1db46a0f9
--- /dev/null
+++ b/tests/auto/cmake/test_internal_singleton/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+
+cmake_minimum_required(VERSION 3.19)
+
+project(test_internal_singleton)
+
+find_package(Qt6 REQUIRED COMPONENTS Qml)
+
+qt_standard_project_setup()
+
+set_source_files_properties(Test.qml PROPERTIES
+ QT_QML_SINGLETON_TYPE TRUE
+ QT_QML_INTERNAL_TYPE TRUE
+)
+
+qt_add_qml_module(test_internal_singleton
+ URI Controls
+ VERSION 1.0
+ QML_FILES
+ Test.qml
+)
diff --git a/tests/auto/cmake/test_internal_singleton/Test.qml b/tests/auto/cmake/test_internal_singleton/Test.qml
new file mode 100644
index 0000000000..a2eb03bd4e
--- /dev/null
+++ b/tests/auto/cmake/test_internal_singleton/Test.qml
@@ -0,0 +1,4 @@
+pragma singleton
+import QtQml
+
+QtObject {}
diff --git a/tests/auto/particles/qquickage/tst_qquickage.cpp b/tests/auto/particles/qquickage/tst_qquickage.cpp
index b0a41afb45..21b79d8921 100644
--- a/tests/auto/particles/qquickage/tst_qquickage.cpp
+++ b/tests/auto/particles/qquickage/tst_qquickage.cpp
@@ -35,7 +35,7 @@ void tst_qquickage::test_kill()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -60,7 +60,7 @@ void tst_qquickage::test_jump()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -86,7 +86,7 @@ void tst_qquickage::test_onceOff()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -112,7 +112,7 @@ void tst_qquickage::test_sustained()
//TODO: Ensure some particles have lived to 0.4s point despite unified timer
//Can't verify size, because particles never die. It will constantly grow.
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickangleddirection/tst_qquickangleddirection.cpp b/tests/auto/particles/qquickangleddirection/tst_qquickangleddirection.cpp
index 63f77f3b30..8b2cb417cb 100644
--- a/tests/auto/particles/qquickangleddirection/tst_qquickangleddirection.cpp
+++ b/tests/auto/particles/qquickangleddirection/tst_qquickangleddirection.cpp
@@ -32,7 +32,7 @@ void tst_qquickangleddirection::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickcumulativedirection/tst_qquickcumulativedirection.cpp b/tests/auto/particles/qquickcumulativedirection/tst_qquickcumulativedirection.cpp
index 9e1a95863d..df427600c5 100644
--- a/tests/auto/particles/qquickcumulativedirection/tst_qquickcumulativedirection.cpp
+++ b/tests/auto/particles/qquickcumulativedirection/tst_qquickcumulativedirection.cpp
@@ -31,7 +31,7 @@ void tst_qquickcumulativedirection::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp b/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp
index c38bc1cdd8..e10885cf84 100644
--- a/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp
+++ b/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp
@@ -33,7 +33,7 @@ void tst_qquickcustomaffector::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
//in CI the whole simulation often happens at once, so dead particles end up missing out
@@ -66,7 +66,7 @@ void tst_qquickcustomaffector::test_move()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
if (!d->stillAlive(system))
diff --git a/tests/auto/particles/qquickellipseextruder/tst_qquickellipseextruder.cpp b/tests/auto/particles/qquickellipseextruder/tst_qquickellipseextruder.cpp
index 9912e54eec..98139e8271 100644
--- a/tests/auto/particles/qquickellipseextruder/tst_qquickellipseextruder.cpp
+++ b/tests/auto/particles/qquickellipseextruder/tst_qquickellipseextruder.cpp
@@ -48,7 +48,7 @@ void tst_qquickellipseextruder::test_basic()
//Filled
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -65,7 +65,7 @@ void tst_qquickellipseextruder::test_basic()
//Just border
QCOMPARE(system->groupData[1]->size(), 500);
- for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickfriction/tst_qquickfriction.cpp b/tests/auto/particles/qquickfriction/tst_qquickfriction.cpp
index 94e2b67ac2..edc3770f85 100644
--- a/tests/auto/particles/qquickfriction/tst_qquickfriction.cpp
+++ b/tests/auto/particles/qquickfriction/tst_qquickfriction.cpp
@@ -33,7 +33,7 @@ void tst_qquickfriction::test_basic()
//Default is just slowed a little
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -50,7 +50,7 @@ void tst_qquickfriction::test_basic()
//Nondefault comes to a complete stop within the first half of its life
QCOMPARE(system->groupData[1]->size(), 500);
- for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -77,7 +77,7 @@ void tst_qquickfriction::test_threshold()
//Velocity capped at 50, but it might take a frame or two to get there
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1.0f)
continue; //Particle data unused
if (myFuzzyGEQ(d->t, ((qreal)system->timeInt/1000.0) - 0.1))
diff --git a/tests/auto/particles/qquickgravity/tst_qquickgravity.cpp b/tests/auto/particles/qquickgravity/tst_qquickgravity.cpp
index 772eabba55..d95bb19827 100644
--- a/tests/auto/particles/qquickgravity/tst_qquickgravity.cpp
+++ b/tests/auto/particles/qquickgravity/tst_qquickgravity.cpp
@@ -32,7 +32,7 @@ void tst_qquickgravity::test_basic()
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
float mag = 707.10678f;
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1 || !d->stillAlive(system))
continue; //Particle data unused or dead
diff --git a/tests/auto/particles/qquickgroupgoal/tst_qquickgroupgoal.cpp b/tests/auto/particles/qquickgroupgoal/tst_qquickgroupgoal.cpp
index 6d91ed149c..87a0c9f21e 100644
--- a/tests/auto/particles/qquickgroupgoal/tst_qquickgroupgoal.cpp
+++ b/tests/auto/particles/qquickgroupgoal/tst_qquickgroupgoal.cpp
@@ -32,7 +32,7 @@ void tst_qquickgroupgoal::test_instantTransition()
ensureAnimTime(600, system->m_animation);
QVERIFY(system->groupData[0]->size() <= 500 && system->groupData[0]->size() >= 450);
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickimageparticle/tst_qquickimageparticle.cpp b/tests/auto/particles/qquickimageparticle/tst_qquickimageparticle.cpp
index 87335172ce..f4b6794cc2 100644
--- a/tests/auto/particles/qquickimageparticle/tst_qquickimageparticle.cpp
+++ b/tests/auto/particles/qquickimageparticle/tst_qquickimageparticle.cpp
@@ -45,7 +45,7 @@ void tst_qquickimageparticle::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -89,7 +89,7 @@ void tst_qquickimageparticle::test_colored()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -133,7 +133,7 @@ void tst_qquickimageparticle::test_colorVariance()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -178,7 +178,7 @@ void tst_qquickimageparticle::test_deformed()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -217,46 +217,50 @@ void tst_qquickimageparticle::test_deformed()
void tst_qquickimageparticle::test_tabled()
{
- QQuickView* view = createView(testFileUrl("tabled.qml"), 600);
- QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
- ensureAnimTime(600, system->m_animation);
+ #if defined(Q_OS_LINUX)
+ QSKIP("Crashing on Ubuntu 22.04: QTBUG-107707");
+ #else
+ QQuickView* view = createView(testFileUrl("tabled.qml"), 600);
+ QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
+ ensureAnimTime(600, system->m_animation);
- QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
- if (d->t == -1)
- continue; //Particle data unused
+ QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
+ if (d->t == -1)
+ continue; //Particle data unused
- QCOMPARE(d->x, 0.f);
- QCOMPARE(d->y, 0.f);
- QCOMPARE(d->vx, 0.f);
- QCOMPARE(d->vy, 0.f);
- QCOMPARE(d->ax, 0.f);
- QCOMPARE(d->ay, 0.f);
- QCOMPARE(d->lifeSpan, 0.5f);
- QCOMPARE(d->size, 32.f);
- QCOMPARE(d->endSize, 32.f);
- QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
- QCOMPARE(d->color.r, (uchar)255);
- QCOMPARE(d->color.g, (uchar)255);
- QCOMPARE(d->color.b, (uchar)255);
- QCOMPARE(d->color.a, (uchar)255);
- QCOMPARE(d->xx, 1.0f);
- QCOMPARE(d->xy, 0.0f);
- QCOMPARE(d->yy, 1.0f);
- QCOMPARE(d->yx, 0.0f);
- QCOMPARE(d->rotation, 0.0f);
- QCOMPARE(d->rotationVelocity, 0.0f);
- QCOMPARE(d->autoRotate, (uchar)0);
- QCOMPARE(d->animX, 0.0f);
- QCOMPARE(d->animY, 0.0f);
- QCOMPARE(d->animWidth, 1.0f);
- QCOMPARE(d->animHeight, 1.0f);
- QCOMPARE(d->frameDuration, 1.0f);
- QCOMPARE(d->frameCount, 1.0f);
- QCOMPARE(d->animT, -1.0f);
- //TODO: This performance level doesn't alter particleData, but goes straight to shaders. Find something to test
- }
- delete view;
+ QCOMPARE(d->x, 0.f);
+ QCOMPARE(d->y, 0.f);
+ QCOMPARE(d->vx, 0.f);
+ QCOMPARE(d->vy, 0.f);
+ QCOMPARE(d->ax, 0.f);
+ QCOMPARE(d->ay, 0.f);
+ QCOMPARE(d->lifeSpan, 0.5f);
+ QCOMPARE(d->size, 32.f);
+ QCOMPARE(d->endSize, 32.f);
+ QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
+ QCOMPARE(d->color.r, (uchar)255);
+ QCOMPARE(d->color.g, (uchar)255);
+ QCOMPARE(d->color.b, (uchar)255);
+ QCOMPARE(d->color.a, (uchar)255);
+ QCOMPARE(d->xx, 1.0f);
+ QCOMPARE(d->xy, 0.0f);
+ QCOMPARE(d->yy, 1.0f);
+ QCOMPARE(d->yx, 0.0f);
+ QCOMPARE(d->rotation, 0.0f);
+ QCOMPARE(d->rotationVelocity, 0.0f);
+ QCOMPARE(d->autoRotate, (uchar)0);
+ QCOMPARE(d->animX, 0.0f);
+ QCOMPARE(d->animY, 0.0f);
+ QCOMPARE(d->animWidth, 1.0f);
+ QCOMPARE(d->animHeight, 1.0f);
+ QCOMPARE(d->frameDuration, 1.0f);
+ QCOMPARE(d->frameCount, 1.0f);
+ QCOMPARE(d->animT, -1.0f);
+ //TODO: This performance level doesn't alter particleData, but goes straight to shaders. Find something to test
+ }
+ delete view;
+ #endif
}
@@ -267,7 +271,7 @@ void tst_qquickimageparticle::test_sprite()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp b/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp
index 24b87bad41..8e82f91a92 100644
--- a/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp
+++ b/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp
@@ -38,7 +38,7 @@ void tst_qquickitemparticle::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -119,7 +119,7 @@ void tst_qquickitemparticle::test_noLeakWhenDeleted()
QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
ensureAnimTime(100, system->m_animation);
- auto particles = qAsConst(system->groupData[0]->data);
+ auto particles = std::as_const(system->groupData[0]->data);
QVERIFY(!particles.isEmpty());
QQuickParticleData* firstParticleData = particles.first();
diff --git a/tests/auto/particles/qquicklineextruder/tst_qquicklineextruder.cpp b/tests/auto/particles/qquicklineextruder/tst_qquicklineextruder.cpp
index 81c7462f54..98e300d90a 100644
--- a/tests/auto/particles/qquicklineextruder/tst_qquicklineextruder.cpp
+++ b/tests/auto/particles/qquicklineextruder/tst_qquicklineextruder.cpp
@@ -31,7 +31,7 @@ void tst_qquicklineextruder::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -47,7 +47,7 @@ void tst_qquicklineextruder::test_basic()
}
QCOMPARE(system->groupData[1]->size(), 500);
- for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickmaskextruder/tst_qquickmaskextruder.cpp b/tests/auto/particles/qquickmaskextruder/tst_qquickmaskextruder.cpp
index faa3d0732a..6c4bb44a07 100644
--- a/tests/auto/particles/qquickmaskextruder/tst_qquickmaskextruder.cpp
+++ b/tests/auto/particles/qquickmaskextruder/tst_qquickmaskextruder.cpp
@@ -31,7 +31,7 @@ void tst_qquickmaskextruder::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickparticlegroup/tst_qquickparticlegroup.cpp b/tests/auto/particles/qquickparticlegroup/tst_qquickparticlegroup.cpp
index 0a6ba45be7..75c2e72c34 100644
--- a/tests/auto/particles/qquickparticlegroup/tst_qquickparticlegroup.cpp
+++ b/tests/auto/particles/qquickparticlegroup/tst_qquickparticlegroup.cpp
@@ -32,7 +32,7 @@ void tst_qquickparticlegroup::test_instantTransition()
//A frame or two worth of particles will be missed, the transition doesn't take effect on the frame it's spawned (QTBUG-21781)
QVERIFY(system->groupData[0]->size() <= 500 && system->groupData[0]->size() >= 450);
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp b/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp
index 0a22f86fc3..cadeac66f5 100644
--- a/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp
+++ b/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp
@@ -33,7 +33,7 @@ void tst_qquickparticlesystem::test_basic()
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
int stillAlive = 0;
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickpointattractor/tst_qquickpointattractor.cpp b/tests/auto/particles/qquickpointattractor/tst_qquickpointattractor.cpp
index 04bd52bee0..e5822c1b88 100644
--- a/tests/auto/particles/qquickpointattractor/tst_qquickpointattractor.cpp
+++ b/tests/auto/particles/qquickpointattractor/tst_qquickpointattractor.cpp
@@ -31,7 +31,7 @@ void tst_qquickpointattractor::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickpointdirection/tst_qquickpointdirection.cpp b/tests/auto/particles/qquickpointdirection/tst_qquickpointdirection.cpp
index 441e2663b1..8c39bad812 100644
--- a/tests/auto/particles/qquickpointdirection/tst_qquickpointdirection.cpp
+++ b/tests/auto/particles/qquickpointdirection/tst_qquickpointdirection.cpp
@@ -31,7 +31,7 @@ void tst_qquickpointdirection::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickrectangleextruder/tst_qquickrectangleextruder.cpp b/tests/auto/particles/qquickrectangleextruder/tst_qquickrectangleextruder.cpp
index c40d57704d..99cbeba35a 100644
--- a/tests/auto/particles/qquickrectangleextruder/tst_qquickrectangleextruder.cpp
+++ b/tests/auto/particles/qquickrectangleextruder/tst_qquickrectangleextruder.cpp
@@ -31,7 +31,7 @@ void tst_qquickrectangleextruder::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -50,7 +50,7 @@ void tst_qquickrectangleextruder::test_basic()
}
QCOMPARE(system->groupData[1]->size(), 500);
- for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickspritegoal/tst_qquickspritegoal.cpp b/tests/auto/particles/qquickspritegoal/tst_qquickspritegoal.cpp
index c349456790..4dd965aff7 100644
--- a/tests/auto/particles/qquickspritegoal/tst_qquickspritegoal.cpp
+++ b/tests/auto/particles/qquickspritegoal/tst_qquickspritegoal.cpp
@@ -31,7 +31,7 @@ void tst_qquickspritegoal::test_instantTransition()
ensureAnimTime(600, system->m_animation);
QVERIFY(system->groupData[0]->size() <= 500 && system->groupData[0]->size() >= 450);
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquicktargetdirection/tst_qquicktargetdirection.cpp b/tests/auto/particles/qquicktargetdirection/tst_qquicktargetdirection.cpp
index 013612d277..6e695440a0 100644
--- a/tests/auto/particles/qquicktargetdirection/tst_qquicktargetdirection.cpp
+++ b/tests/auto/particles/qquicktargetdirection/tst_qquicktargetdirection.cpp
@@ -31,7 +31,7 @@ void tst_qquicktargetdirection::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquicktrailemitter/tst_qquicktrailemitter.cpp b/tests/auto/particles/qquicktrailemitter/tst_qquicktrailemitter.cpp
index ef5a513b2f..230c666c8d 100644
--- a/tests/auto/particles/qquicktrailemitter/tst_qquicktrailemitter.cpp
+++ b/tests/auto/particles/qquicktrailemitter/tst_qquicktrailemitter.cpp
@@ -31,7 +31,7 @@ void tst_qquicktrailemitter::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -48,7 +48,7 @@ void tst_qquicktrailemitter::test_basic()
}
QVERIFY(extremelyFuzzyCompare(system->groupData[1]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickturbulence/tst_qquickturbulence.cpp b/tests/auto/particles/qquickturbulence/tst_qquickturbulence.cpp
index 246dba20fe..d90dd17199 100644
--- a/tests/auto/particles/qquickturbulence/tst_qquickturbulence.cpp
+++ b/tests/auto/particles/qquickturbulence/tst_qquickturbulence.cpp
@@ -33,7 +33,7 @@ void tst_qquickturbulence::test_basic()
//Note that the noise image built-in provides the 'randomness', so this test should be stable so long as it and the size
//of the Turbulence item remain the same
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickwander/tst_qquickwander.cpp b/tests/auto/particles/qquickwander/tst_qquickwander.cpp
index 6f056f5760..71a8ee1f97 100644
--- a/tests/auto/particles/qquickwander/tst_qquickwander.cpp
+++ b/tests/auto/particles/qquickwander/tst_qquickwander.cpp
@@ -35,7 +35,7 @@ void tst_qquickwander::test_basic()
//the 500 was randomly changed from 0.0 in velocity
bool vxChanged = false;
bool vyChanged = false;
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/qml/CMakeLists.txt b/tests/auto/qml/CMakeLists.txt
index 29a1a2b011..a2a90a413a 100644
--- a/tests/auto/qml/CMakeLists.txt
+++ b/tests/auto/qml/CMakeLists.txt
@@ -47,7 +47,11 @@ endif()
add_subdirectory(qqmlmetatype)
if(TARGET Qt::Quick)
add_subdirectory(qmltc_manual)
- add_subdirectory(qmltc)
+ # QML Type Compiler tests cannot be run on webOS due to missing support for multiple
+ # consecutive window creation from a single QtWayland client
+ if(NOT WEBOS)
+ add_subdirectory(qmltc)
+ endif()
# This test always creates static plugins. To avoid linker command line
# ordering issues, we need at least CMake 3.21 and we cannot include the
# test if qmlimportscanner is being built as part of the main project.
diff --git a/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
index 0a17d75387..cac9581803 100644
--- a/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
+++ b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
@@ -81,7 +81,7 @@ public:
int count()
{
- return states.count();
+ return states.size();
}
QList<QAbstractAnimationJob::State> states;
diff --git a/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
index f8665eac0a..a11ae75033 100644
--- a/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
+++ b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
@@ -99,7 +99,7 @@ public:
}
void clear() { states.clear(); }
- int count() { return states.count(); }
+ int count() { return states.size(); }
QList<QAbstractAnimationJob::State> states;
};
diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
index 03d207e49b..cc67df420c 100644
--- a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
+++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
@@ -116,7 +116,7 @@ public:
}
void clear() { states.clear(); }
- int count() const { return states.count(); }
+ int count() const { return states.size(); }
QList<QAbstractAnimationJob::State> states;
bool beEvil = false;
@@ -562,8 +562,8 @@ typedef QList<QAbstractAnimationJob::State> StateList;
static bool compareStates(const StateChangeListener& spy, const StateList &expectedStates)
{
bool equals = true;
- for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
- if (i >= spy.count() || i >= expectedStates.count()) {
+ for (int i = 0; i < qMax(expectedStates.size(), spy.count()); ++i) {
+ if (i >= spy.count() || i >= expectedStates.size()) {
equals = false;
break;
}
@@ -577,8 +577,8 @@ static bool compareStates(const StateChangeListener& spy, const StateList &expec
if (!equals) {
const char *stateStrings[] = {"Stopped", "Paused", "Running"};
QString e,a;
- for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
- if (i < expectedStates.count()) {
+ for (int i = 0; i < qMax(expectedStates.size(), spy.count()); ++i) {
+ if (i < expectedStates.size()) {
int exp = int(expectedStates.at(i));
if (!e.isEmpty())
e += QLatin1String(", ");
@@ -596,7 +596,7 @@ static bool compareStates(const StateChangeListener& spy, const StateList &expec
}
}
- qDebug().noquote() << "\nexpected (count == " << expectedStates.count() << "): " << e
+ qDebug().noquote() << "\nexpected (count == " << expectedStates.size() << "): " << e
<< "\nactual (count == " << spy.count() << "): " << a << "\n";
}
return equals;
diff --git a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
index 1efc48e07d..81d8694406 100644
--- a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
+++ b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
@@ -45,8 +45,8 @@ void tst_QPacketProtocol::init()
m_client->connectToHost(m_server->serverAddress(), m_server->serverPort());
- QVERIFY(clientSpy.count() > 0 || clientSpy.wait());
- QVERIFY(serverSpy.count() > 0 || serverSpy.wait());
+ QVERIFY(clientSpy.size() > 0 || clientSpy.wait());
+ QVERIFY(serverSpy.size() > 0 || serverSpy.wait());
m_serverConn = m_server->nextPendingConnection();
}
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
index 5a8fce6424..ab599e9a23 100644
--- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
+++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
@@ -150,7 +150,7 @@ void tst_QQmlDebuggingEnabler::custom()
m_clients = QQmlDebugTest::createOtherClients(m_connection);
m_connection->connectToHost("127.0.0.1", m_process->debugPort());
QVERIFY(m_connection->waitForConnected());
- for (QQmlDebugClient *client : qAsConst(m_clients))
+ for (QQmlDebugClient *client : std::as_const(m_clients))
QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ?
QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable);
}
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
index 9f51b65c7f..ac607df0a0 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
+++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -853,15 +853,15 @@ void tst_QQmlDebugJS::evaluateInContext()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result())));
- QVERIFY(engineClient->engines().count());
+ QVERIFY(engineClient->engines().size());
engineClient->queryRootContexts(engineClient->engines()[0], &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result())));
auto contexts = engineClient->rootContext().contexts;
- QCOMPARE(contexts.count(), 1);
+ QCOMPARE(contexts.size(), 1);
auto objects = contexts[0].objects;
- QCOMPARE(objects.count(), 1);
+ QCOMPARE(objects.size(), 1);
engineClient->queryObjectRecursive(objects[0], &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result())));
@@ -874,7 +874,7 @@ void tst_QQmlDebugJS::evaluateInContext()
QTRY_COMPARE(responseBody(m_client).value("value").toInt(), 20);
auto childObjects = object.children;
- QVERIFY(childObjects.count() > 0); // QQmlComponentAttached is also in there
+ QVERIFY(childObjects.size() > 0); // QQmlComponentAttached is also in there
QCOMPARE(childObjects[0].className, QString::fromLatin1("Item"));
// "b" accessible in context of surrounding (child) object
@@ -1065,7 +1065,7 @@ void tst_QQmlDebugJS::letConstLocals()
for (const auto prop : props) {
const auto propObj = prop.toObject();
QString name = propObj.value(QStringLiteral("name")).toString();
- QVERIFY(name.length() == 1);
+ QVERIFY(name.size() == 1);
auto i = expectedMembers.indexOf(name.at(0));
QVERIFY(i != -1);
expectedMembers.remove(i, 1);
diff --git a/tests/auto/qml/debugger/qqmldebugtranslationservice/tst_qqmldebugtranslationservice.cpp b/tests/auto/qml/debugger/qqmldebugtranslationservice/tst_qqmldebugtranslationservice.cpp
index 48396aefea..0e0340b672 100644
--- a/tests/auto/qml/debugger/qqmldebugtranslationservice/tst_qqmldebugtranslationservice.cpp
+++ b/tests/auto/qml/debugger/qqmldebugtranslationservice/tst_qqmldebugtranslationservice.cpp
@@ -63,7 +63,7 @@ private slots:
changeLanguage("ru");
auto translationIssues = getTranslationIssues();
- QCOMPARE(translationIssues.length(), getTranslatableTextOccurrences().count());
+ QCOMPARE(translationIssues.size(), getTranslatableTextOccurrences().size());
QCOMPARE(translationIssues.at(0).language, "ru-Cyrl-RU ru-RU ru");
}
@@ -73,18 +73,18 @@ private slots:
auto translationIssues = getTranslationIssues();
- QCOMPARE(translationIssues.length(), 3);
+ QCOMPARE(translationIssues.size(), 3);
QCOMPARE(translationIssues.at(0).language, "fr-Latn-FR fr-FR fr");
}
void verifyCorrectNumberOfTranslatableTextOccurrences()
{
- QCOMPARE(getTranslatableTextOccurrences().length(), 5);
+ QCOMPARE(getTranslatableTextOccurrences().size(), 5);
}
void verifyCorrectNumberOfStates()
{
- QCOMPARE(getStates().length(), 2);
+ QCOMPARE(getStates().size(), 2);
}
void getElideWarnings()
@@ -128,9 +128,9 @@ private slots:
{
QVector<QmlState> stateList = getStates();
- QCOMPARE(stateList.length(), 2);
+ QCOMPARE(stateList.size(), 2);
- for (int i = 0; i < stateList.count(); i++) {
+ for (int i = 0; i < stateList.size(); i++) {
auto stateName = stateList.at(i).name;
QVersionedPacket<QQmlDebugConnector> packet;
sendMessageToService(createChangeStateRequest(packet, stateName));
diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
index 78d80405f4..890f4eeef6 100644
--- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
@@ -55,7 +55,7 @@ QQmlEngineDebugObjectReference tst_QQmlEngineDebugInspectorIntegration::findRoot
if (!QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())))
return QQmlEngineDebugObjectReference();
- int count = m_engineDebugClient->rootContext().contexts.count();
+ int count = m_engineDebugClient->rootContext().contexts.size();
m_engineDebugClient->queryObject(
m_engineDebugClient->rootContext().contexts[count - 1].objects[0], &success);
if (!QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())))
@@ -156,7 +156,7 @@ void tst_QQmlEngineDebugInspectorIntegration::createObject()
QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
- QCOMPARE(rootObject.children.length(), 2);
+ QCOMPARE(rootObject.children.size(), 2);
int requestId = m_inspectorClient->createObject(
qml, rootObject.debugId, QStringList() << QLatin1String("import QtQuick 2.0"),
@@ -166,7 +166,7 @@ void tst_QQmlEngineDebugInspectorIntegration::createObject()
rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
- QCOMPARE(rootObject.children.length(), 3);
+ QCOMPARE(rootObject.children.size(), 3);
QCOMPARE(rootObject.children[2].idString, QLatin1String("xxxyxxx"));
}
@@ -177,7 +177,7 @@ void tst_QQmlEngineDebugInspectorIntegration::moveObject()
QCOMPARE(m_inspectorClient->state(), QQmlDebugClient::Enabled);
QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
- QCOMPARE(rootObject.children.length(), 2);
+ QCOMPARE(rootObject.children.size(), 2);
int childId = rootObject.children[0].debugId;
int requestId = m_inspectorClient->moveObject(childId, rootObject.children[1].debugId);
@@ -186,12 +186,12 @@ void tst_QQmlEngineDebugInspectorIntegration::moveObject()
rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
- QCOMPARE(rootObject.children.length(), 1);
+ QCOMPARE(rootObject.children.size(), 1);
bool success = false;
m_engineDebugClient->queryObject(rootObject.children[0], &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())));
- QCOMPARE(m_engineDebugClient->object().children.length(), 1);
+ QCOMPARE(m_engineDebugClient->object().children.size(), 1);
QCOMPARE(m_engineDebugClient->object().children[0].debugId, childId);
}
@@ -202,7 +202,7 @@ void tst_QQmlEngineDebugInspectorIntegration::destroyObject()
QCOMPARE(m_inspectorClient->state(), QQmlDebugClient::Enabled);
QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
- QCOMPARE(rootObject.children.length(), 2);
+ QCOMPARE(rootObject.children.size(), 2);
int requestId = m_inspectorClient->destroyObject(rootObject.children[0].debugId);
QTRY_COMPARE(m_recipient->lastResponseId, requestId);
@@ -210,12 +210,12 @@ void tst_QQmlEngineDebugInspectorIntegration::destroyObject()
rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
- QCOMPARE(rootObject.children.length(), 1);
+ QCOMPARE(rootObject.children.size(), 1);
bool success = false;
m_engineDebugClient->queryObject(rootObject.children[0], &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())));
- QCOMPARE(m_engineDebugClient->object().children.length(), 0);
+ QCOMPARE(m_engineDebugClient->object().children.size(), 0);
}
QTEST_MAIN(tst_QQmlEngineDebugInspectorIntegration)
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/data/fetchValueType.qml b/tests/auto/qml/debugger/qqmlenginedebugservice/data/fetchValueType.qml
new file mode 100644
index 0000000000..ea0c3ff8c0
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/data/fetchValueType.qml
@@ -0,0 +1,9 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtQuick.Controls
+
+Item {
+ Button {}
+}
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
index 49fe5948d5..467ebda91b 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
@@ -21,6 +21,7 @@
#include <QtQml/qqmlexpression.h>
#include <QtQml/qqmlproperty.h>
#include <QtQml/qqmlincubator.h>
+#include <QtQml/qqmlapplicationengine.h>
#include <QtQuick/qquickitem.h>
#include <QtNetwork/qhostaddress.h>
@@ -161,6 +162,7 @@ private slots:
void asynchronousCreate();
void invalidContexts();
void createObjectOnDestruction();
+ void fetchValueType();
};
QQmlEngineDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
@@ -171,14 +173,14 @@ QQmlEngineDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
QVERIFYOBJECT(success);
QVERIFYOBJECT(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QVERIFYOBJECT(m_dbg->engines().count());
+ QVERIFYOBJECT(m_dbg->engines().size());
m_dbg->queryRootContexts(m_dbg->engines()[0], &success);
QVERIFYOBJECT(success);
QVERIFYOBJECT(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QVERIFYOBJECT(m_dbg->rootContext().contexts.count());
- QVERIFYOBJECT(m_dbg->rootContext().contexts.last().objects.count());
- int count = m_dbg->rootContext().contexts.count();
+ QVERIFYOBJECT(m_dbg->rootContext().contexts.size());
+ QVERIFYOBJECT(m_dbg->rootContext().contexts.last().objects.size());
+ int count = m_dbg->rootContext().contexts.size();
recursive ? m_dbg->queryObjectRecursive(m_dbg->rootContext().contexts[count - context - 1].objects[0],
&success) :
m_dbg->queryObject(m_dbg->rootContext().contexts[count - context - 1].objects[0], &success);
@@ -210,7 +212,7 @@ void tst_QQmlEngineDebugService::recursiveObjectTest(
qmlContext(o)));
const QObjectList &children = o->children();
- for (int i=0; i<children.count(); i++) {
+ for (int i=0; i<children.size(); i++) {
QObject *child = children[i];
if (!qmlContext(child))
continue;
@@ -235,7 +237,7 @@ void tst_QQmlEngineDebugService::recursiveObjectTest(
QCOMPARE(p.objectDebugId, QQmlDebugService::idForObject(o));
// signal properties are fake - they are generated from QQmlAbstractBoundSignal children
- if (p.name.startsWith("on") && p.name.length() > 2 && p.name[2].isUpper()) {
+ if (p.name.startsWith("on") && p.name.size() > 2 && p.name[2].isUpper()) {
QString signal = p.value.toString();
QQmlBoundSignalExpression *expr = QQmlPropertyPrivate::signalExpression(QQmlProperty(o, p.name));
QVERIFY(expr && expr->expression() == signal);
@@ -299,7 +301,7 @@ void tst_QQmlEngineDebugService::getContexts()
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QList<QQmlEngineDebugEngineReference> engines = m_dbg->engines();
- QCOMPARE(engines.count(), 1);
+ QCOMPARE(engines.size(), 1);
m_dbg->queryRootContexts(engines.first(), &success);
QVERIFY(success);
@@ -438,7 +440,7 @@ void tst_QQmlEngineDebugService::watch_property()
m_rootItem->setProperty("width", origWidth*2);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(valueChanged(QByteArray,QVariant))));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
m_dbg->removeWatch(id, &success);
QVERIFY(success);
@@ -448,7 +450,7 @@ void tst_QQmlEngineDebugService::watch_property()
// restore original value and verify spy doesn't get additional signal since watch has been removed
m_rootItem->setProperty("width", origWidth);
QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).value<QByteArray>(), prop.name.toUtf8());
QCOMPARE(spy.at(0).at(1).value<QVariant>(), QVariant::fromValue(origWidth*2));
@@ -486,11 +488,11 @@ void tst_QQmlEngineDebugService::watch_object()
m_rootItem->setProperty("height", origHeight*2);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(valueChanged(QByteArray,QVariant))));
- QVERIFY(spy.count() > 0);
+ QVERIFY(spy.size() > 0);
int newWidth = -1;
int newHeight = -1;
- for (int i=0; i<spy.count(); i++) {
+ for (int i=0; i<spy.size(); i++) {
const QVariantList &values = spy[i];
if (values[0].value<QByteArray>() == "width")
newWidth = values[1].value<QVariant>().toInt();
@@ -509,7 +511,7 @@ void tst_QQmlEngineDebugService::watch_object()
m_rootItem->setProperty("width", origWidth);
m_rootItem->setProperty("height", origHeight);
QTest::qWait(100);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(newWidth, origWidth * 2);
QCOMPARE(newHeight, origHeight * 2);
@@ -562,10 +564,10 @@ void tst_QQmlEngineDebugService::watch_expression()
// restore original value and verify spy doesn't get a signal since watch has been removed
m_rootItem->setProperty("width", origWidth);
QTest::qWait(100);
- QCOMPARE(spy.count(), incrementCount);
+ QCOMPARE(spy.size(), incrementCount);
width = origWidth + increment;
- for (int i=0; i<spy.count(); i++) {
+ for (int i=0; i<spy.size(); i++) {
width += increment;
QCOMPARE(spy.at(i).at(1).value<QVariant>().toInt(), width);
}
@@ -614,7 +616,7 @@ void tst_QQmlEngineDebugService::queryAvailableEngines()
// TODO test multiple engines
QList<QQmlEngineDebugEngineReference> engines = m_dbg->engines();
- QCOMPARE(engines.count(), 1);
+ QCOMPARE(engines.size(), 1);
foreach (const QQmlEngineDebugEngineReference &e, engines) {
QCOMPARE(e.debugId, QQmlDebugService::idForObject(m_engine));
@@ -628,7 +630,7 @@ void tst_QQmlEngineDebugService::queryRootContexts()
m_dbg->queryAvailableEngines(&success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QVERIFY(m_dbg->engines().count());
+ QVERIFY(m_dbg->engines().size());
const QQmlEngineDebugEngineReference engine = m_dbg->engines()[0];
QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(nullptr);
@@ -647,8 +649,8 @@ void tst_QQmlEngineDebugService::queryRootContexts()
// root context query sends only root object data - it doesn't fill in
// the children or property info
- QCOMPARE(context.objects.count(), 0);
- QCOMPARE(context.contexts.count(), 8);
+ QCOMPARE(context.objects.size(), 0);
+ QCOMPARE(context.contexts.size(), 8);
QVERIFY(context.contexts[0].debugId >= 0);
QCOMPARE(context.contexts[0].name, QString("tst_QQmlDebug_childContext"));
}
@@ -686,7 +688,7 @@ void tst_QQmlEngineDebugService::queryObject()
if (recursive) {
foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
- QVERIFY(child.properties.count() > 0);
+ QVERIFY(child.properties.size() > 0);
}
QQmlEngineDebugObjectReference rect;
@@ -708,7 +710,7 @@ void tst_QQmlEngineDebugService::queryObject()
} else {
foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
- QCOMPARE(child.properties.count(), 0);
+ QCOMPARE(child.properties.size(), 0);
}
}
}
@@ -749,7 +751,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QCOMPARE(m_dbg->objects().count(), 1);
+ QCOMPARE(m_dbg->objects().size(), 1);
QQmlEngineDebugObjectReference obj = m_dbg->objects().first();
QVERIFY(!obj.className.isEmpty());
@@ -765,7 +767,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation()
if (recursive) {
foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
- QVERIFY(child.properties.count() > 0);
+ QVERIFY(child.properties.size() > 0);
}
QQmlEngineDebugObjectReference rect;
@@ -789,7 +791,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation()
} else {
foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
- QCOMPARE(child.properties.count(), 0);
+ QCOMPARE(child.properties.size(), 0);
}
}
}
@@ -1134,7 +1136,7 @@ void tst_QQmlEngineDebugService::setBindingInStates()
QQmlEngineDebugObjectReference obj = findRootObject(sourceIndex);
QVERIFY(!obj.className.isEmpty());
QVERIFY(obj.debugId != -1);
- QVERIFY(obj.children.count() >= 2);
+ QVERIFY(obj.children.size() >= 2);
bool success;
// We are going to switch state a couple of times, we need to get rid of the transition before
m_dbg->queryExpressionResult(obj.debugId,QString("transitions = []"), &success);
@@ -1166,7 +1168,7 @@ void tst_QQmlEngineDebugService::setBindingInStates()
// change the binding
QQmlEngineDebugObjectReference state = obj.children[1];
QCOMPARE(state.className, QString("State"));
- QVERIFY(state.children.count() > 0);
+ QVERIFY(state.children.size() > 0);
QQmlEngineDebugObjectReference propertyChange = state.children[0];
QVERIFY(!propertyChange.className.isEmpty());
@@ -1250,12 +1252,12 @@ void tst_QQmlEngineDebugService::queryObjectTree()
QQmlEngineDebugObjectReference obj = findRootObject(sourceIndex, true);
QVERIFY(!obj.className.isEmpty());
QVERIFY(obj.debugId != -1);
- QVERIFY(obj.children.count() >= 2);
+ QVERIFY(obj.children.size() >= 2);
// check state
QQmlEngineDebugObjectReference state = obj.children[1];
QCOMPARE(state.className, QString("State"));
- QVERIFY(state.children.count() > 0);
+ QVERIFY(state.children.size() > 0);
QQmlEngineDebugObjectReference propertyChange = state.children[0];
QVERIFY(!propertyChange.className.isEmpty());
@@ -1274,7 +1276,7 @@ void tst_QQmlEngineDebugService::queryObjectTree()
QCOMPARE(transition.className, QString("Transition"));
QCOMPARE(findProperty(transition.properties,"from").value.toString(), QString("*"));
QCOMPARE(findProperty(transition.properties,"to").value, findProperty(state.properties,"name").value);
- QVERIFY(transition.children.count() > 0);
+ QVERIFY(transition.children.size() > 0);
QQmlEngineDebugObjectReference animation = transition.children[0];
QVERIFY(!animation.className.isEmpty());
@@ -1321,18 +1323,18 @@ void tst_QQmlEngineDebugService::asynchronousCreate() {
void tst_QQmlEngineDebugService::invalidContexts()
{
getContexts();
- const int base = m_dbg->rootContext().contexts.count();
+ const int base = m_dbg->rootContext().contexts.size();
QQmlContext context(m_engine);
getContexts();
- QCOMPARE(m_dbg->rootContext().contexts.count(), base + 1);
+ QCOMPARE(m_dbg->rootContext().contexts.size(), base + 1);
QQmlRefPointer<QQmlContextData> contextData = QQmlContextData::get(&context);
contextData->invalidate();
getContexts();
- QCOMPARE(m_dbg->rootContext().contexts.count(), base);
+ QCOMPARE(m_dbg->rootContext().contexts.size(), base);
QQmlRefPointer<QQmlContextData> rootData = QQmlContextData::get(m_engine->rootContext());
rootData->invalidate();
getContexts();
- QCOMPARE(m_dbg->rootContext().contexts.count(), 0);
+ QCOMPARE(m_dbg->rootContext().contexts.size(), 0);
}
void tst_QQmlEngineDebugService::createObjectOnDestruction()
@@ -1351,11 +1353,31 @@ void tst_QQmlEngineDebugService::createObjectOnDestruction()
"}", QUrl::fromLocalFile("x.qml"));
QVERIFY(component.isReady());
QVERIFY(component.create());
- QTRY_COMPARE(spy.count(), 2);
+ QTRY_COMPARE(spy.size(), 2);
}
// Doesn't crash and doesn't give us another signal for the object created on destruction.
QTest::qWait(500);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
+}
+
+void tst_QQmlEngineDebugService::fetchValueType()
+{
+ QQmlApplicationEngine engine;
+ engine.load(testFileUrl("fetchValueType.qml"));
+
+
+ bool success = false;
+ m_dbg->queryAvailableEngines(&success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QVERIFY(m_dbg->engines().size() > 1);
+
+ QQmlEngineDebugObjectReference object;
+ object.debugId = QQmlDebugService::idForObject(&engine);
+ m_dbg->queryObjectRecursive(object, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+
}
void tst_QQmlEngineDebugService::debuggerCrashOnAttach() {
diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
index f389fb8f9f..897d8c8688 100644
--- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
+++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
@@ -64,7 +64,7 @@ void tst_QQmlInspector::checkAnimationSpeed(int targetMillisPerDegree)
for (int i = 0; i < 10; ++i) {
QString output = m_process->output();
- int position = output.length();
+ int position = output.size();
do {
QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput())));
output = m_process->output();
diff --git a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp
index 90ababb67e..0c4fd568a9 100644
--- a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp
+++ b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp
@@ -266,14 +266,14 @@ void tst_QQmlPreview::error()
QCOMPARE(startQmlProcess("window.qml"), ConnectSuccess);
QVERIFY(m_client);
m_client->triggerLoad(testFileUrl("broken.qml"));
- QTRY_COMPARE_WITH_TIMEOUT(m_serviceErrors.count(), 1, 10000);
+ QTRY_COMPARE_WITH_TIMEOUT(m_serviceErrors.size(), 1, 10000);
QVERIFY(m_serviceErrors.first().contains("broken.qml:7 Expected token `}'"));
}
static float parseZoomFactor(const QString &output)
{
const QString prefix("zoom ");
- const int start = output.lastIndexOf(prefix) + prefix.length();
+ const int start = output.lastIndexOf(prefix) + prefix.size();
if (start < 0)
return -1;
const int end = output.indexOf('\n', start);
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
index ce92728ee4..53971d3e8b 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -52,20 +52,20 @@ private:
void QQmlProfilerTestClient::startTrace(qint64 timestamp, const QList<int> &engineIds)
{
types.append(QQmlProfilerEventType(Event, MaximumRangeType, StartTrace));
- asynchronousMessages.append(QQmlProfilerEvent(timestamp, types.length() - 1,
+ asynchronousMessages.append(QQmlProfilerEvent(timestamp, types.size() - 1,
engineIds.toVector()));
}
void QQmlProfilerTestClient::endTrace(qint64 timestamp, const QList<int> &engineIds)
{
types.append(QQmlProfilerEventType(Event, MaximumRangeType, EndTrace));
- asynchronousMessages.append(QQmlProfilerEvent(timestamp, types.length() - 1,
+ asynchronousMessages.append(QQmlProfilerEvent(timestamp, types.size() - 1,
engineIds.toVector()));
}
int QQmlProfilerTestClient::numLoadedEventTypes() const
{
- return types.length();
+ return types.size();
}
void QQmlProfilerTestClient::addEventType(const QQmlProfilerEventType &type)
@@ -76,7 +76,7 @@ void QQmlProfilerTestClient::addEventType(const QQmlProfilerEventType &type)
void QQmlProfilerTestClient::addEvent(const QQmlProfilerEvent &event)
{
const int typeIndex = event.typeIndex();
- QVERIFY(typeIndex < types.length());
+ QVERIFY(typeIndex < types.size());
const QQmlProfilerEventType &type = types[typeIndex];
@@ -272,14 +272,14 @@ void tst_QQmlProfilerService::checkTraceReceived()
// must end with "EndTrace"
expected = QQmlProfilerEventType(Event, MaximumRangeType, EndTrace);
- VERIFY(MessageListAsynchronous, m_client->asynchronousMessages.length() - 1, expected,
+ VERIFY(MessageListAsynchronous, m_client->asynchronousMessages.size() - 1, expected,
CheckMessageType | CheckDetailType, numbers);
}
void tst_QQmlProfilerService::checkJsHeap()
{
QVERIFY(m_client);
- QVERIFY2(m_client->jsHeapMessages.count() > 0, "no JavaScript heap messages received");
+ QVERIFY2(m_client->jsHeapMessages.size() > 0, "no JavaScript heap messages received");
bool seen_alloc = false;
bool seen_small = false;
@@ -357,9 +357,9 @@ bool tst_QQmlProfilerService::verify(tst_QQmlProfilerService::MessageListType ty
return false;
}
- if (target->length() <= expectedPosition) {
+ if (target->size() <= expectedPosition) {
qWarning() << "Not enough events. expected position:" << expectedPosition
- << "length:" << target->length();
+ << "length:" << target->size();
return false;
}
@@ -438,7 +438,7 @@ bool tst_QQmlProfilerService::verify(tst_QQmlProfilerService::MessageListType ty
}
return true;
- } while (++position < target->length() && target->at(position).timestamp() == timestamp);
+ } while (++position < target->size() && target->at(position).timestamp() == timestamp);
foreach (const QString &message, warnings)
qWarning() << message.toLocal8Bit().constData();
@@ -467,34 +467,34 @@ void tst_QQmlProfilerService::cleanup()
};
if (m_client && QTest::currentTestFailed()) {
- qDebug() << "QML Messages:" << m_client->qmlMessages.count();
+ qDebug() << "QML Messages:" << m_client->qmlMessages.size();
int i = 0;
- for (const QQmlProfilerEvent &data : qAsConst(m_client->qmlMessages))
+ for (const QQmlProfilerEvent &data : std::as_const(m_client->qmlMessages))
log(data, i++);
qDebug() << " ";
- qDebug() << "JavaScript Messages:" << m_client->javascriptMessages.count();
+ qDebug() << "JavaScript Messages:" << m_client->javascriptMessages.size();
i = 0;
- for (const QQmlProfilerEvent &data : qAsConst(m_client->javascriptMessages))
+ for (const QQmlProfilerEvent &data : std::as_const(m_client->javascriptMessages))
log(data, i++);
qDebug() << " ";
- qDebug() << "Asynchronous Messages:" << m_client->asynchronousMessages.count();
+ qDebug() << "Asynchronous Messages:" << m_client->asynchronousMessages.size();
i = 0;
- for (const QQmlProfilerEvent &data : qAsConst(m_client->asynchronousMessages))
+ for (const QQmlProfilerEvent &data : std::as_const(m_client->asynchronousMessages))
log(data, i++);
qDebug() << " ";
- qDebug() << "Pixmap Cache Messages:" << m_client->pixmapMessages.count();
+ qDebug() << "Pixmap Cache Messages:" << m_client->pixmapMessages.size();
i = 0;
- for (const QQmlProfilerEvent &data : qAsConst(m_client->pixmapMessages))
+ for (const QQmlProfilerEvent &data : std::as_const(m_client->pixmapMessages))
log(data, i++);
qDebug() << " ";
- qDebug() << "Javascript Heap Messages:" << m_client->jsHeapMessages.count();
+ qDebug() << "Javascript Heap Messages:" << m_client->jsHeapMessages.size();
i = 0;
- for (const QQmlProfilerEvent &data : qAsConst(m_client->jsHeapMessages))
+ for (const QQmlProfilerEvent &data : std::as_const(m_client->jsHeapMessages))
log(data, i++);
qDebug() << " ";
@@ -677,9 +677,9 @@ void tst_QQmlProfilerService::flushInterval()
QCOMPARE(connectTo(true, "timer.qml", true, 1), ConnectSuccess);
// Make sure we get multiple messages
- QTRY_VERIFY(m_client->qmlMessages.length() > 0);
- QVERIFY(m_client->qmlMessages.length() < 100);
- QTRY_VERIFY(m_client->qmlMessages.length() > 100);
+ QTRY_VERIFY(m_client->qmlMessages.size() > 0);
+ QVERIFY(m_client->qmlMessages.size() < 100);
+ QTRY_VERIFY(m_client->qmlMessages.size() > 100);
m_client->client->setRecording(false);
checkTraceReceived();
@@ -783,7 +783,7 @@ void tst_QQmlProfilerService::multiEngine()
QTRY_COMPARE(m_process->state(), QProcess::NotRunning);
QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QQmlProfilerService::batchOverflow()
diff --git a/tests/auto/qml/debugger/qv4debugger/CMakeLists.txt b/tests/auto/qml/debugger/qv4debugger/CMakeLists.txt
index ecefcb65bc..92565f55c1 100644
--- a/tests/auto/qml/debugger/qv4debugger/CMakeLists.txt
+++ b/tests/auto/qml/debugger/qv4debugger/CMakeLists.txt
@@ -10,6 +10,18 @@ file(GLOB_RECURSE test_data_glob
data/*)
list(APPEND test_data ${test_data_glob})
+qt_add_library(testCppTypes STATIC)
+qt_autogen_tools_initial_setup(testCppTypes)
+target_link_libraries(testCppTypes PRIVATE Qt::Qml Qt::QmlPrivate Qt::Quick)
+
+qt6_add_qml_module(testCppTypes
+ VERSION 1.0
+ URI TestTypes
+ SOURCES
+ commontypes.h
+)
+qt_autogen_tools_initial_setup(testCppTypesplugin)
+
qt_internal_add_test(tst_qv4debugger
SOURCES
../../../../../src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp ../../../../../src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h
@@ -25,6 +37,7 @@ qt_internal_add_test(tst_qv4debugger
Qt::Network
Qt::QmlPrivate
Qt::QuickTestUtilsPrivate
+ testCppTypesplugin
TESTDATA ${test_data}
)
diff --git a/tests/auto/qml/debugger/qv4debugger/commontypes.h b/tests/auto/qml/debugger/qv4debugger/commontypes.h
new file mode 100644
index 0000000000..01b2125ae3
--- /dev/null
+++ b/tests/auto/qml/debugger/qv4debugger/commontypes.h
@@ -0,0 +1,20 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef COMMONTYPES_H
+#define COMMONTYPES_H
+
+#include <QtQuick/qquickitem.h>
+#include <QtQml/qqmlregistration.h>
+#include <QtQml/private/qv4engine_p.h>
+
+class MyType : public QQuickItem
+{
+ Q_OBJECT
+ QML_ELEMENT
+public:
+ MyType(QQuickItem *parent = nullptr) : QQuickItem(parent) {}
+ Q_INVOKABLE void name(QQmlV4Function*) const {}
+};
+
+#endif // COMMONTYPES_H
diff --git a/tests/auto/qml/debugger/qv4debugger/data/qtbug_107607.qml b/tests/auto/qml/debugger/qv4debugger/data/qtbug_107607.qml
new file mode 100644
index 0000000000..a7758de8a8
--- /dev/null
+++ b/tests/auto/qml/debugger/qv4debugger/data/qtbug_107607.qml
@@ -0,0 +1,10 @@
+import QtQuick
+import TestTypes
+MyType {
+ objectName: "patron"
+ Item {
+ Component.onCompleted: {
+ console.log("Hallo Welt");
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
index d7a79f446b..6f147446f0 100644
--- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
+++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
@@ -16,10 +16,13 @@
#include <private/qv4string_p.h>
#include <private/qqmlbuiltinfunctions_p.h>
#include <private/qqmldebugservice_p.h>
+#include <QtQml/qqmlextensionplugin.h>
using namespace QV4;
using namespace QV4::Debugging;
+Q_IMPORT_QML_PLUGIN(TestTypesPlugin);
+
typedef QV4::ReturnedValue (*InjectedFunction)(const FunctionObject *b, const QV4::Value *, const QV4::Value *, int);
Q_DECLARE_METATYPE(InjectedFunction)
@@ -176,7 +179,15 @@ public slots:
ExpressionEvalJob job(debugger->engine(), request.frameNr, request.context,
request.expression, &collector);
debugger->runInEngine(&job);
- m_expressionResults << job.returnValue();
+ const QJsonObject& result = job.returnValue();
+ m_expressionResults << result;
+
+ if (request.shouldLookup) {
+ QJsonArray handles {result.value("handle").toInt()};
+ ValueLookupJob job(handles, &collector);
+ debugger->runInEngine(&job);
+ m_lookupResults << job.returnValue();
+ }
}
if (m_captureContextInfo)
@@ -249,10 +260,14 @@ public:
QString expression;
int frameNr;
int context;
+ bool shouldLookup = false;
};
+
+
QVector<ExpressionRequest> m_expressionRequests;
QV4Debugger::Speed m_resumeSpeed;
QList<QJsonObject> m_expressionResults;
+ QList<QJsonObject> m_lookupResults;
QV4Debugger *m_debugger;
// Utility methods:
@@ -306,7 +321,7 @@ private slots:
void readThis();
void signalParameters();
-
+ void debuggerNoCrash();
private:
QV4Debugger *debugger() const
{
@@ -370,7 +385,7 @@ void tst_qv4debugger::pendingBreakpoint()
debugger()->addBreakPoint("testfile", 2);
evaluateJavaScript(script, "testfile");
QVERIFY(m_debuggerAgent->m_wasPaused);
- QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 1);
+ QCOMPARE(m_debuggerAgent->m_statesWhenPaused.size(), 1);
QV4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first();
QCOMPARE(state.fileName, QString("testfile"));
QCOMPARE(state.lineNumber, 2);
@@ -386,7 +401,7 @@ void tst_qv4debugger::liveBreakPoint()
debugger()->pause();
evaluateJavaScript(script, "liveBreakPoint");
QVERIFY(m_debuggerAgent->m_wasPaused);
- QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 2);
+ QCOMPARE(m_debuggerAgent->m_statesWhenPaused.size(), 2);
QV4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.at(1);
QCOMPARE(state.fileName, QString("liveBreakPoint"));
QCOMPARE(state.lineNumber, 3);
@@ -414,7 +429,7 @@ void tst_qv4debugger::addBreakPointWhilePaused()
m_debuggerAgent->m_breakPointsToAddWhenPaused << TestAgent::TestBreakPoint("addBreakPointWhilePaused", 2);
evaluateJavaScript(script, "addBreakPointWhilePaused");
QVERIFY(m_debuggerAgent->m_wasPaused);
- QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 2);
+ QCOMPARE(m_debuggerAgent->m_statesWhenPaused.size(), 2);
QV4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.at(0);
QCOMPARE(state.fileName, QString("addBreakPointWhilePaused"));
@@ -461,7 +476,7 @@ void tst_qv4debugger::conditionalBreakPoint()
debugger()->addBreakPoint("conditionalBreakPoint", 3, QStringLiteral("i > 10"));
evaluateJavaScript(script, "conditionalBreakPoint");
QVERIFY(m_debuggerAgent->m_wasPaused);
- QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 4);
+ QCOMPARE(m_debuggerAgent->m_statesWhenPaused.size(), 4);
QV4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first();
QCOMPARE(state.fileName, QString("conditionalBreakPoint"));
QCOMPARE(state.lineNumber, 3);
@@ -495,7 +510,7 @@ void tst_qv4debugger::conditionalBreakPointInQml()
QScopedPointer<QObject> obj(component.create());
QCOMPARE(obj->property("success").toBool(), true);
- QCOMPARE(debuggerAgent->m_statesWhenPaused.count(), 1);
+ QCOMPARE(debuggerAgent->m_statesWhenPaused.size(), 1);
QCOMPARE(debuggerAgent->m_statesWhenPaused.at(0).fileName, qmlFileName);
QCOMPARE(debuggerAgent->m_statesWhenPaused.at(0).lineNumber, 7);
@@ -699,7 +714,7 @@ void tst_qv4debugger::breakInCatch()
evaluateJavaScript(script, "breakInCatch");
QVERIFY(m_debuggerAgent->m_wasPaused);
QCOMPARE(m_debuggerAgent->m_pauseReason, QV4Debugger::BreakPointHit);
- QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 1);
+ QCOMPARE(m_debuggerAgent->m_statesWhenPaused.size(), 1);
QV4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first();
QCOMPARE(state.fileName, QString("breakInCatch"));
QCOMPARE(state.lineNumber, 4);
@@ -716,7 +731,7 @@ void tst_qv4debugger::breakInWith()
evaluateJavaScript(script, "breakInWith");
QVERIFY(m_debuggerAgent->m_wasPaused);
QCOMPARE(m_debuggerAgent->m_pauseReason, QV4Debugger::BreakPointHit);
- QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 1);
+ QCOMPARE(m_debuggerAgent->m_statesWhenPaused.size(), 1);
QV4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first();
QCOMPARE(state.fileName, QString("breakInWith"));
QCOMPARE(state.lineNumber, 2);
@@ -752,7 +767,7 @@ void tst_qv4debugger::evaluateExpression()
evaluateJavaScript(script, "evaluateExpression");
- QCOMPARE(m_debuggerAgent->m_expressionResults.count(), 4);
+ QCOMPARE(m_debuggerAgent->m_expressionResults.size(), 4);
QJsonObject result0 = m_debuggerAgent->m_expressionResults[0];
QCOMPARE(result0.value("type").toString(), QStringLiteral("number"));
QCOMPARE(result0.value("value").toInt(), 10);
@@ -776,7 +791,7 @@ void tst_qv4debugger::stepToEndOfScript()
evaluateJavaScript(script, "toEnd");
QVERIFY(m_debuggerAgent->m_wasPaused);
QCOMPARE(m_debuggerAgent->m_pauseReason, QV4Debugger::Step);
- QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 5);
+ QCOMPARE(m_debuggerAgent->m_statesWhenPaused.size(), 5);
for (int i = 0; i < 4; ++i) {
QV4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.at(i);
QCOMPARE(state.fileName, QString("toEnd"));
@@ -846,7 +861,7 @@ void tst_qv4debugger::lastLineOfConditional()
evaluateJavaScript(script, "trueBranch");
QVERIFY(m_debuggerAgent->m_wasPaused);
QCOMPARE(m_debuggerAgent->m_pauseReason, QV4Debugger::Step);
- QVERIFY(m_debuggerAgent->m_statesWhenPaused.count() > 1);
+ QVERIFY(m_debuggerAgent->m_statesWhenPaused.size() > 1);
QV4Debugger::ExecutionState firstState = m_debuggerAgent->m_statesWhenPaused.first();
QCOMPARE(firstState.fileName, QString("trueBranch"));
QCOMPARE(firstState.lineNumber, breakPoint);
@@ -873,7 +888,7 @@ void tst_qv4debugger::readThis()
evaluateJavaScript(script, "applyThis");
QVERIFY(m_debuggerAgent->m_wasPaused);
- QCOMPARE(m_debuggerAgent->m_expressionResults.count(), 1);
+ QCOMPARE(m_debuggerAgent->m_expressionResults.size(), 1);
QJsonObject result0 = m_debuggerAgent->m_expressionResults[0];
QCOMPARE(result0.value("type").toString(), QStringLiteral("object"));
QCOMPARE(result0.value("value").toInt(), 1);
@@ -916,6 +931,42 @@ void tst_qv4debugger::signalParameters()
QCOMPARE(obj->property("resultCallbackExternal").toString(), QLatin1String("unset"));
}
+void tst_qv4debugger::debuggerNoCrash()
+{
+ QQmlEngine engine;
+ QV4::ExecutionEngine *v4 = engine.handle();
+ QPointer<QV4Debugger> v4Debugger = new QV4Debugger(v4);
+ v4->setDebugger(v4Debugger.data());
+
+ QScopedPointer<QThread> debugThread(new QThread);
+ debugThread->start();
+ QScopedPointer<TestAgent> debuggerAgent(new TestAgent(v4));
+ debuggerAgent->addDebugger(v4Debugger);
+ debuggerAgent->moveToThread(debugThread.data());
+
+ const QString qmlFileName("qtbug_107607.qml");
+ const QString qmlFilePath(testFile(qmlFileName));
+ QQmlComponent component(&engine, qmlFilePath);
+
+ TestAgent::ExpressionRequest request;
+ request.expression = "this.parent";
+ request.frameNr = 0;
+ request.context = -1;
+ request.shouldLookup = true;
+ debuggerAgent->m_expressionRequests << request;
+ v4Debugger->addBreakPoint(qmlFileName, 7);
+
+ QScopedPointer<QObject> obj(component.create());
+
+ QVERIFY(debuggerAgent->m_lookupResults.size() > 0);
+ const QJsonObject result = debuggerAgent->m_lookupResults[0];
+ const QJsonArray properties = result["0"].toObject().value("properties").toArray();
+ QCOMPARE(properties[0].toObject().value("value").toString(), QStringLiteral("patron"));
+
+ debugThread->quit();
+ debugThread->wait();
+}
+
tst_qv4debugger::tst_qv4debugger() : QQmlDataTest(QT_QMLTEST_DATADIR) { }
QTEST_MAIN(tst_qv4debugger)
diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp
index bc15af706d..bce2c28378 100644
--- a/tests/auto/qml/debugger/shared/debugutil.cpp
+++ b/tests/auto/qml/debugger/shared/debugutil.cpp
@@ -20,7 +20,7 @@ bool QQmlDebugTest::waitForSignal(QObject *sender, const char *member, int timeo
QSignalSpy spy(sender, member);
// Do not use spy.wait(). We want to avoid nested event loops.
- if (QTest::qWaitFor([&]() { return spy.count() > 0; }, timeout))
+ if (QTest::qWaitFor([&]() { return spy.size() > 0; }, timeout))
return true;
qWarning("waitForSignal %s timed out after %d ms", member, timeout);
@@ -132,7 +132,7 @@ QQmlDebugTest::ConnectResult QQmlDebugTest::connectTo(
QSignalSpy okSpy(&stateHandler, &ClientStateHandler::allOk);
QSignalSpy disconnectSpy(m_connection, &QQmlDebugConnection::disconnected);
m_connection->connectToHost(QLatin1String("127.0.0.1"), m_process->debugPort());
- if (!QTest::qWaitFor([&](){ return okSpy.count() > 0 || disconnectSpy.count() > 0; }, 5000))
+ if (!QTest::qWaitFor([&](){ return okSpy.size() > 0 || disconnectSpy.size() > 0; }, 5000))
return ConnectionTimeout;
if (!stateHandler.allEnabled())
@@ -231,7 +231,7 @@ QString debugJsServerPath(const QString &selfPath)
static const char *debugserver = "qqmldebugjsserver";
QString appPath = QCoreApplication::applicationDirPath();
const int position = appPath.lastIndexOf(selfPath);
- return (position == -1 ? appPath : appPath.replace(position, selfPath.length(), debugserver))
+ return (position == -1 ? appPath : appPath.replace(position, selfPath.size(), debugserver))
+ "/" + debugserver;
}
diff --git a/tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp b/tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp
index 3963e9aa48..03706b8e7c 100644
--- a/tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp
+++ b/tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp
@@ -179,17 +179,17 @@ bool Test262Runner::report()
}
if (!crashes.isEmpty()) {
qDebug() << " Encountered" << crashes.size() << "crashes in the following files:";
- for (const QString &f : qAsConst(crashes))
+ for (const QString &f : std::as_const(crashes))
qDebug() << " " << f;
}
if (!unexpectedFailures.isEmpty()) {
qDebug() << " Encountered" << unexpectedFailures.size() << "unexpected failures in the following files:";
- for (const QString &f : qAsConst(unexpectedFailures))
+ for (const QString &f : std::as_const(unexpectedFailures))
qDebug() << " " << f;
}
if (!unexpectedPasses.isEmpty()) {
qDebug() << " Encountered" << unexpectedPasses.size() << "unexpected passes in the following files:";
- for (const QString &f : qAsConst(unexpectedPasses))
+ for (const QString &f : std::as_const(unexpectedPasses))
qDebug() << " " << f;
}
return crashes.isEmpty() && unexpectedFailures.isEmpty() && unexpectedPasses.isEmpty();
@@ -207,7 +207,7 @@ bool Test262Runner::loadTests()
QString harness = "harness";
QString intl402 = "intl402";
- int pathlen = dir.path().length() + 1;
+ int pathlen = dir.path().size() + 1;
QDirIterator it(dir, QDirIterator::Subdirectories);
while (it.hasNext()) {
QString file = it.next().mid(pathlen);
@@ -373,9 +373,7 @@ void Test262Runner::loadTestExpectations()
return;
}
- int line = 0;
while (!file.atEnd()) {
- ++line;
QByteArray line = file.readLine().trimmed();
if (line.startsWith('#') || line.isEmpty())
continue;
@@ -420,9 +418,7 @@ void Test262Runner::updateTestExpectations()
QTemporaryFile updatedExpectations;
updatedExpectations.open();
- int line = 0;
while (!file.atEnd()) {
- ++line;
QByteArray originalLine = file.readLine();
QByteArray line = originalLine.trimmed();
if (line.startsWith('#') || line.isEmpty()) {
@@ -458,7 +454,7 @@ void Test262Runner::writeTestExpectations()
QTemporaryFile expectations;
expectations.open();
- for (auto c : qAsConst(testCases)) {
+ for (auto c : std::as_const(testCases)) {
TestExpectationLine line = TestExpectationLine::fromTestCase(c);
expectations.write(line.toLine());
}
@@ -494,7 +490,7 @@ static bool executeTest(const QByteArray &data, bool runAsModule = false, const
QFile f(url.toLocalFile());
if (f.open(QIODevice::ReadOnly)) {
QByteArray content = harnessForModules + f.readAll();
- module = vm.compileModule(url.toString(), QString::fromUtf8(content.constData(), content.length()), QFileInfo(f).lastModified());
+ module = vm.compileModule(url.toString(), QString::fromUtf8(content.constData(), content.size()), QFileInfo(f).lastModified());
if (vm.hasException)
break;
vm.injectModule(module);
@@ -692,7 +688,7 @@ TestData Test262Runner::getTestData(const TestCase &testCase)
data.harness += harness("assert.js");
data.harness += harness("sta.js");
- for (QByteArray inc : qAsConst(data.includes)) {
+ for (QByteArray inc : std::as_const(data.includes)) {
inc = inc.trimmed();
data.harness += harness(inc);
}
@@ -726,7 +722,7 @@ YamlSection::YamlSection(const QByteArray &yaml, const char *sectionName)
start += static_cast<int>(strlen(sectionName));
int end = yaml.indexOf('\n', start + 1);
if (end < 0)
- end = yaml.length();
+ end = yaml.size();
int s = yaml.indexOf('[', start);
if (s > 0 && s < end) {
diff --git a/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp b/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp
index bf8d194bf4..bee391e62c 100644
--- a/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp
+++ b/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp
@@ -1,7 +1,6 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
#include <QtTest/QtTest>
#include <QProcess>
#include <QLibraryInfo>
@@ -12,16 +11,62 @@ class tst_EcmaScriptTests : public QObject
Q_OBJECT
private slots:
+ void initTestCase();
+ void cleanupTestCase();
void runInterpreted();
void runJitted();
+
+private:
+ static QLoggingCategory::CategoryFilter priorFilter;
+ static void filterCategories(QLoggingCategory *category);
};
+QLoggingCategory::CategoryFilter tst_EcmaScriptTests::priorFilter = nullptr;
+
+static inline bool isNoise(QByteArrayView name)
+{
+#ifdef QT_V4_WANT_ES262_WARNINGS
+ return false;
+#else
+ const QByteArrayView noisy("qt.qml.compiler");
+ return name.startsWith(noisy) && (name.size() <= noisy.size() || name[noisy.size()] == '.');
+#endif
+}
+
+void tst_EcmaScriptTests::filterCategories(QLoggingCategory *category)
+{
+ if (priorFilter)
+ priorFilter(category);
+
+ if (isNoise(category->categoryName())) {
+ category->setEnabled(QtDebugMsg, false);
+ category->setEnabled(QtWarningMsg, false);
+ }
+}
+
+void tst_EcmaScriptTests::initTestCase()
+{
+ /* Suppress lcQmlCompiler's "qt.qml.compiler" warnings; we aren't in a
+ position to fix test262's many warnings and they flood messages so we
+ didn't get to see actual failures unless we passed -maxwarnings with a
+ huge value on the command-line (resulting in huge log output).
+ */
+ priorFilter = QLoggingCategory::installFilter(filterCategories);
+}
+
+void tst_EcmaScriptTests::cleanupTestCase()
+{
+ QLoggingCategory::installFilter(priorFilter);
+}
void tst_EcmaScriptTests::runInterpreted()
{
#if defined(Q_PROCESSOR_X86_64)
QDir::setCurrent(QLatin1String(SRCDIR));
Test262Runner runner(QString(), "test262");
- runner.setFlags(Test262Runner::ForceBytecode|Test262Runner::WithTestExpectations|Test262Runner::Parallel|Test262Runner::Verbose);
+ runner.setFlags(Test262Runner::ForceBytecode
+ | Test262Runner::WithTestExpectations
+ | Test262Runner::Parallel
+ | Test262Runner::Verbose);
bool result = runner.run();
QVERIFY(result);
#endif
@@ -32,7 +77,10 @@ void tst_EcmaScriptTests::runJitted()
#if defined(Q_PROCESSOR_X86_64)
QDir::setCurrent(QLatin1String(SRCDIR));
Test262Runner runner(QString(), "test262");
- runner.setFlags(Test262Runner::ForceJIT|Test262Runner::WithTestExpectations|Test262Runner::Parallel|Test262Runner::Verbose);
+ runner.setFlags(Test262Runner::ForceJIT
+ | Test262Runner::WithTestExpectations
+ | Test262Runner::Parallel
+ | Test262Runner::Verbose);
bool result = runner.run();
QVERIFY(result);
#endif
diff --git a/tests/auto/qml/parserstress/tst_parserstress.cpp b/tests/auto/qml/parserstress/tst_parserstress.cpp
index 7fb2787d31..99af0247a8 100644
--- a/tests/auto/qml/parserstress/tst_parserstress.cpp
+++ b/tests/auto/qml/parserstress/tst_parserstress.cpp
@@ -126,7 +126,7 @@ void tst_parserstress::ecmascript()
if (fileInfo.fileName() == QLatin1String("regress-352044-02-n.js")) {
QVERIFY(component.isError());
- QCOMPARE(component.errors().length(), 2);
+ QCOMPARE(component.errors().size(), 2);
QCOMPARE(component.errors().at(0).description(), QString("Expected token `;'"));
QCOMPARE(component.errors().at(0).line(), 66);
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 0c3a8d1703..8c2f9ae645 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -249,6 +249,8 @@ private slots:
void sortNonStringArray();
void iterateInvalidProxy();
void applyOnHugeArray();
+ void reflectApplyOnHugeArray();
+ void jsonStringifyHugeArray();
void tostringRecursionCheck();
void arrayIncludesWithLargeArray();
@@ -260,6 +262,9 @@ private slots:
void urlObject();
void thisInConstructor();
void forOfAndGc();
+ void staticInNestedClasses();
+
+ void spreadNoOverflow();
public:
Q_INVOKABLE QJSValue throwingCppMethod1();
@@ -5326,6 +5331,36 @@ void tst_QJSEngine::applyOnHugeArray()
QCOMPARE(value.toString(), "RangeError: Array too large for apply().");
}
+
+void tst_QJSEngine::reflectApplyOnHugeArray()
+{
+ QQmlEngine engine;
+ const QJSValue value = engine.evaluate(R"(
+(function(){
+const v1 = [];
+const v3 = [];
+v3.length = 3900000000;
+Reflect.apply(v1.reverse,v1,v3);
+})()
+ )");
+ QVERIFY(value.isError());
+ QCOMPARE(value.toString(), QLatin1String("RangeError: Invalid array length."));
+}
+
+void tst_QJSEngine::jsonStringifyHugeArray()
+{
+ QQmlEngine engine;
+ const QJSValue value = engine.evaluate(R"(
+(function(){
+const v3 = [];
+v3.length = 3900000000;
+JSON.stringify([], v3);
+})()
+ )");
+ QVERIFY(value.isError());
+ QCOMPARE(value.toString(), QLatin1String("RangeError: Invalid array length."));
+}
+
void tst_QJSEngine::typedArraySet()
{
QJSEngine engine;
@@ -5425,7 +5460,7 @@ void tst_QJSEngine::urlObject()
check(QStringLiteral("href"), url.toString());
check(QStringLiteral("origin"), QStringLiteral("http://example.com:777"));
- check(QStringLiteral("protocol"), url.scheme());
+ check(QStringLiteral("protocol"), url.scheme() + QLatin1Char(':'));
check(QStringLiteral("username"), url.userName());
check(QStringLiteral("password"), url.password());
check(QStringLiteral("host"), url.host() + u':' + QString::number(url.port()));
@@ -5571,6 +5606,32 @@ void tst_QJSEngine::forOfAndGc()
QTRY_VERIFY(o->property("count").toInt() > 32768);
}
+void tst_QJSEngine::staticInNestedClasses()
+{
+ QJSEngine engine;
+ const QString program = uR"(
+ class Tester {
+ constructor() {
+ new (class {})();
+ }
+ static get test() { return "a" }
+ }
+ Tester.test
+ )"_s;
+
+ QCOMPARE(engine.evaluate(program).toString(), u"a"_s);
+}
+
+void tst_QJSEngine::spreadNoOverflow()
+{
+ QJSEngine engine;
+
+ const QString program = QString::fromLatin1("var a = [] ;a.length = 555840;Math.max(...a)");
+ const QJSValue result = engine.evaluate(program);
+ QVERIFY(result.isError());
+ QCOMPARE(result.errorType(), QJSValue::RangeError);
+}
+
QTEST_MAIN(tst_QJSEngine)
#include "tst_qjsengine.moc"
diff --git a/tests/auto/qml/qjsmanagedvalue/tst_qjsmanagedvalue.cpp b/tests/auto/qml/qjsmanagedvalue/tst_qjsmanagedvalue.cpp
index 568b14b5ac..6723926585 100644
--- a/tests/auto/qml/qjsmanagedvalue/tst_qjsmanagedvalue.cpp
+++ b/tests/auto/qml/qjsmanagedvalue/tst_qjsmanagedvalue.cpp
@@ -1742,7 +1742,7 @@ void tst_QJSManagedValue::stringByIndex()
const QString testString = QStringLiteral("foobar");
QJSManagedValue str(testString, &engine);
- for (uint i = 0; i < testString.length(); ++i) {
+ for (uint i = 0; i < testString.size(); ++i) {
QVERIFY(str.hasOwnProperty(i));
QVERIFY(str.hasProperty(i));
diff --git a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp
index cc301081cf..6235ff376d 100644
--- a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp
+++ b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp
@@ -52,6 +52,9 @@ private slots:
void writeProperty_javascriptExpression_data();
void writeProperty_javascriptExpression();
+ void cyclicStringify();
+ void recursiveStringify();
+
private:
QByteArray readAsUtf8(const QString &fileName);
static QJsonValue valueFromJson(const QByteArray &json);
@@ -489,6 +492,43 @@ void tst_qjsonbinding::writeProperty_javascriptExpression()
QCOMPARE(ret.toString(), expectedJson);
}
+void tst_qjsonbinding::cyclicStringify()
+{
+ QJSEngine e;
+ const QString program = QStringLiteral(R"(
+ var a = {};
+ a.a = a;
+ JSON.stringify(a);
+ )");
+
+ QJSValue result = e.evaluate(program);
+ QVERIFY(result.isError());
+ QCOMPARE(result.errorType(), QJSValue::TypeError);
+ QVERIFY(result.toString().contains(QLatin1String("Cannot convert circular structure to JSON")));
+}
+
+void tst_qjsonbinding::recursiveStringify()
+{
+ QJSEngine e;
+ const QString program = QStringLiteral(R"(
+ function create() {
+ var a = {}
+ Object.defineProperty(a, "a", {
+ enumerable: true,
+ get: function() { return create(); }
+ });
+ return a;
+ }
+
+ JSON.stringify(create());
+ )");
+
+ QJSValue result = e.evaluate(program);
+ QVERIFY(result.isError());
+ QCOMPARE(result.errorType(), QJSValue::RangeError);
+ QVERIFY(result.toString().contains(QLatin1String("Maximum call stack size exceeded")));
+}
+
QTEST_MAIN(tst_qjsonbinding)
#include "tst_qjsonbinding.moc"
diff --git a/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp
index 339a524604..e329cf948f 100644
--- a/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp
+++ b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp
@@ -95,7 +95,7 @@ void tst_QJSValueIterator::iterateForward()
QCOMPARE(it.hasNext(), false);
it = object;
- for (int i = 0; i < lst.count(); ++i) {
+ for (int i = 0; i < lst.size(); ++i) {
QCOMPARE(it.hasNext(), true);
it.next();
QCOMPARE(it.name(), lst.at(i));
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
index f3e608a6ae..a5a73d7eb1 100644
--- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
+++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
@@ -2,7 +2,11 @@ set(cpp_sources
ambiguous.h
birthdayparty.cpp birthdayparty.h
cppbaseclass.h
+ dummyobjekt.h
dynamicmeta.h
+ enumProperty.h
+ enumproblems.h
+ gadgetwithenum.h
invisible.h
objectwithmethod.h
person.cpp person.h
@@ -49,6 +53,7 @@ set(qml_files
blockComments.qml
boundComponents.qml
callContextPropertyLookupResult.qml
+ callWithSpread.qml
childobject.qml
colorAsVariant.qml
colorString.qml
@@ -66,8 +71,11 @@ set(qml_files
deadStoreLoop.qml
dialog.qml
dynamicscene.qml
+ enumConversion.qml
+ enumFromBadSingleton.qml
enumInvalid.qml
enumLookup.qml
+ enumProblems.qml
enumScope.qml
enumsInOtherObject.qml
enumsUser.qml
@@ -116,6 +124,7 @@ set(qml_files
notEqualsInt.qml
notNotString.qml
nullAccess.qml
+ nullComparison.qml
objectInVar.qml
outOfBounds.qml
overriddenMember.qml
@@ -135,7 +144,9 @@ set(qml_files
shifts.qml
signal.qml
signalHandler.qml
+ signalIndexMismatch.qml
specificParent.qml
+ storeElementSideEffects.qml
stringLength.qml
stringToByteArray.qml
testlogger.js
@@ -144,9 +155,11 @@ set(qml_files
themergood.qml
throwObjectName.qml
toString.qml
+ typePropagationLoop.qml
typePropertyClash.qml
typedArray.qml
undefinedResets.qml
+ undefinedToDouble.qml
unknownAttached.qml
unknownParameter.qml
unstoredUndefined.qml
@@ -155,6 +168,7 @@ set(qml_files
valueTypeLists.qml
valueTypeProperty.qml
variantlist.qml
+ versionmismatch.qml
voidfunction.qml
)
@@ -176,7 +190,7 @@ set_target_properties(codegen_test_module PROPERTIES
)
qt6_add_qml_module(codegen_test_module
- VERSION 1.0
+ VERSION 1.5
URI TestTypes
IMPORT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/imports/"
DEPENDENCIES
diff --git a/tests/auto/qml/qmlcppcodegen/data/badSequence.qml b/tests/auto/qml/qmlcppcodegen/data/badSequence.qml
index 5b0742ab6a..785765ec74 100644
--- a/tests/auto/qml/qmlcppcodegen/data/badSequence.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/badSequence.qml
@@ -3,4 +3,5 @@ import TestTypes
Person {
property Person other: Person { id: oo }
barzles: oo.barzles
+ property int l: oo.barzles.length
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp b/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp
index 4ba76d882d..048459f03a 100644
--- a/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp
+++ b/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp
@@ -28,7 +28,7 @@ QQmlListProperty<Person> BirthdayParty::guests()
int BirthdayParty::guestCount() const
{
- return m_guests.count();
+ return m_guests.size();
}
Person *BirthdayParty::guest(int index) const
diff --git a/tests/auto/qml/qmlcppcodegen/data/callWithSpread.qml b/tests/auto/qml/qmlcppcodegen/data/callWithSpread.qml
new file mode 100644
index 0000000000..3d7f79d68d
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/callWithSpread.qml
@@ -0,0 +1,9 @@
+import QtQml
+
+QtObject {
+ Component.onCompleted: {
+ let f = console.error;
+ const data = [f, ["That is great!"]]
+ data[0](...data[1]);
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/cppbaseclass.h b/tests/auto/qml/qmlcppcodegen/data/cppbaseclass.h
index 416a61defc..eecc3d968e 100644
--- a/tests/auto/qml/qmlcppcodegen/data/cppbaseclass.h
+++ b/tests/auto/qml/qmlcppcodegen/data/cppbaseclass.h
@@ -15,6 +15,8 @@ class CppBaseClass : public QObject
Q_PROPERTY(int cppProp2 MEMBER cppProp2 BINDABLE cppProp2Bindable FINAL)
Q_PROPERTY(QList<int> boo MEMBER boo FINAL CONSTANT)
Q_PROPERTY(QList<qreal> hoo MEMBER hoo FINAL CONSTANT)
+ Q_PROPERTY(int inaccessible READ inaccessible FINAL CONSTANT REVISION(1, 5))
+ QML_ADDED_IN_VERSION(1, 0)
QML_ELEMENT
public:
CppBaseClass(QObject *parent = nullptr)
@@ -35,6 +37,7 @@ public:
Q_INVOKABLE void doCall(QObject *foo);
+ int inaccessible() const { return 7; }
private:
QList<int> boo;
QList<qreal> hoo;
diff --git a/tests/auto/qml/qmlcppcodegen/data/dummyobjekt.h b/tests/auto/qml/qmlcppcodegen/data/dummyobjekt.h
new file mode 100644
index 0000000000..c75501a5b8
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/dummyobjekt.h
@@ -0,0 +1,29 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef DUMMYOBJEKT_H
+#define DUMMYOBJEKT_H
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+
+#if QT_DEPRECATED_SINCE(6, 4)
+class DummyObjekt : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ QML_SINGLETON
+
+public:
+ enum Test {
+ TestA = 1,
+ TestB
+ };
+ Q_ENUM(Test)
+
+ // Deliberately not default constructible
+ explicit DummyObjekt(QObject *parent) : QObject(parent) {}
+};
+#endif
+
+#endif // DUMMYOBJEKT_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/enumConversion.qml b/tests/auto/qml/qmlcppcodegen/data/enumConversion.qml
new file mode 100644
index 0000000000..fee2c50e15
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/enumConversion.qml
@@ -0,0 +1,7 @@
+import TestTypes
+
+MyType {
+ id: root
+ property int test: myEnumType.type
+ property bool test_1: myEnumType.type
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/enumFromBadSingleton.qml b/tests/auto/qml/qmlcppcodegen/data/enumFromBadSingleton.qml
new file mode 100644
index 0000000000..3176fde315
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/enumFromBadSingleton.qml
@@ -0,0 +1,6 @@
+import QtQml
+import TestTypes
+
+QtObject {
+ objectName: "Dummy: " + DummyObjekt.TestA
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/enumProblems.qml b/tests/auto/qml/qmlcppcodegen/data/enumProblems.qml
new file mode 100644
index 0000000000..230172ce48
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/enumProblems.qml
@@ -0,0 +1,13 @@
+import TestTypes
+import QtQml
+
+QtObject {
+ id: root
+
+ readonly property FooFactory f: FooFactory {}
+
+ property QtObject o: QtObject {
+ readonly property FooThing fighter: root.f.get(Foo.Fighter)
+ readonly property FooThing bar: root.f.get(Foo.Component)
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/enumProperty.h b/tests/auto/qml/qmlcppcodegen/data/enumProperty.h
new file mode 100644
index 0000000000..8c13e860a3
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/enumProperty.h
@@ -0,0 +1,34 @@
+#ifndef ENUMPROPERTY_H
+#define ENUMPROPERTY_H
+
+#include <QObject>
+#include <QtQml>
+
+class MyEnumType
+{
+ Q_GADGET
+ QML_ANONYMOUS
+public:
+ enum MyEnum {
+ Sin = 0x01,
+ Saw = 0x02,
+ Tri = 0x04,
+ };
+ Q_ENUM(MyEnum)
+ Q_PROPERTY(MyEnum type READ type)
+ MyEnum type() const { return MyEnum::Tri; }
+};
+
+class MyType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(MyEnumType myEnumType READ myEnumType)
+ QML_ELEMENT
+public:
+ MyEnumType myEnumType() const { return m_type; }
+
+private:
+ MyEnumType m_type;
+};
+
+#endif // ENUMPROPERTY_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/enumproblems.h b/tests/auto/qml/qmlcppcodegen/data/enumproblems.h
new file mode 100644
index 0000000000..08a00acf7e
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/enumproblems.h
@@ -0,0 +1,53 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef ENUMPROBLEMS_H
+#define ENUMPROBLEMS_H
+
+#include <QObject>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlregistration.h>
+
+class Foo : public QObject {
+ Q_OBJECT
+
+public:
+ enum Type {
+ Unknown,
+ Fighter,
+ Component
+ };
+ Q_ENUM(Type)
+
+ explicit Foo(Foo::Type type, QObject *parent = nullptr) : QObject(parent), m_type(type) {}
+
+ Type type() const { return m_type; }
+
+private:
+ Type m_type = Type::Unknown;
+};
+
+namespace FooWrapper {
+ Q_NAMESPACE
+ QML_FOREIGN_NAMESPACE(Foo)
+ QML_NAMED_ELEMENT(Foo)
+};
+
+
+class FooThingWrapper {
+ Q_GADGET
+ QML_FOREIGN(Foo)
+ QML_NAMED_ELEMENT(FooThing)
+ QML_UNCREATABLE("nope")
+};
+
+
+class FooFactory : public QObject {
+ Q_OBJECT
+ QML_ELEMENT
+
+public:
+ Q_INVOKABLE Foo* get(Foo::Type type) const { return new Foo(type); }
+};
+
+#endif // ENUMPROBLEMS_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/failures.qml b/tests/auto/qml/qmlcppcodegen/data/failures.qml
index 39268d84ce..16dd0c764a 100644
--- a/tests/auto/qml/qmlcppcodegen/data/failures.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/failures.qml
@@ -1,5 +1,6 @@
import QtQml
import TestTypes
+import TestTypes as TT2
import Ambiguous 1.2
QtObject {
@@ -35,4 +36,7 @@ QtObject {
signal bar()
// Cannot assign potential undefined
onFoo: objectName = self.bar()
+
+ property int enumFromGadget1: GadgetWithEnum.CONNECTED + 1
+ property int enumFromGadget2: TT2.GadgetWithEnum.CONNECTED + 1
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/gadgetwithenum.h b/tests/auto/qml/qmlcppcodegen/data/gadgetwithenum.h
new file mode 100644
index 0000000000..d146b9f654
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/gadgetwithenum.h
@@ -0,0 +1,23 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef GADGETWITHENUM_H
+#define GADGETWITHENUM_H
+
+#include <QtCore/qobject.h>
+#include <QtQmlIntegration/qqmlintegration.h>
+
+class GadgetWithEnum : public QObject {
+ Q_GADGET
+ QML_ELEMENT
+
+public:
+ enum State {
+ DISCONNECTED,
+ CONNECTING,
+ CONNECTED
+ };
+ Q_ENUM(State)
+};
+
+#endif // GADGETWITHENUM_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/nullComparison.qml b/tests/auto/qml/qmlcppcodegen/data/nullComparison.qml
new file mode 100644
index 0000000000..1f9af7169b
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/nullComparison.qml
@@ -0,0 +1,26 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property int v: 1
+ property int w: 1
+ property int x: 1
+ property int y: 1
+ Component.onCompleted: {
+ var g = null;
+ if (g !== null) {
+ v = 2;
+ }
+ if (g === null) {
+ w = 3;
+ }
+
+ var h = undefined;
+ if (h !== undefined) {
+ x = 4;
+ }
+ if (h === undefined) {
+ y = 5;
+ }
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/signalIndexMismatch.qml b/tests/auto/qml/qmlcppcodegen/data/signalIndexMismatch.qml
new file mode 100644
index 0000000000..ecc03026ba
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/signalIndexMismatch.qml
@@ -0,0 +1,48 @@
+import QtQuick
+import QtQml.Models
+
+Item {
+ property var visualIndexBeforeMove: [-1, -1, -1]
+ property var visualIndexAfterMove: [-1, -1, -1]
+
+ DelegateModel {
+ id: visualModel
+ model: ListModel {
+ ListElement { name: "Apple (id 0)" }
+ ListElement { name: "Orange (id 1)" }
+ ListElement { name: "Banana (id 2)" }
+ }
+
+ delegate: DropArea {
+ id: delegateRoot
+
+ required property string name
+ // property that was not updated correctly in QTBUG-104047
+ readonly property int visualIndex: DelegateModel.itemsIndex
+ Rectangle {
+ id: child
+
+ readonly property int visualIndex: delegateRoot.visualIndex
+ }
+ }
+ }
+
+ Repeater {
+ id: root
+ model: visualModel
+ }
+
+ Component.onCompleted: {
+ visualIndexBeforeMove[0] = root.itemAt(0).visualIndex
+ visualIndexBeforeMove[1] = root.itemAt(1).visualIndex
+ visualIndexBeforeMove[2] = root.itemAt(2).visualIndex
+ visualModel.items.move(2, 0)
+ // test that bindings on the QQmlDelegateModelAttached are captured properly:
+ // after the move, the visualIndex property should be updated to the new value,
+ // which in this case is also the index used in itemAt()
+ visualIndexAfterMove[0] = root.itemAt(0).visualIndex
+ visualIndexAfterMove[1] = root.itemAt(1).visualIndex
+ visualIndexAfterMove[2] = root.itemAt(2).visualIndex
+ }
+
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/storeElementSideEffects.qml b/tests/auto/qml/qmlcppcodegen/data/storeElementSideEffects.qml
new file mode 100644
index 0000000000..273f08aad5
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/storeElementSideEffects.qml
@@ -0,0 +1,6 @@
+import QtQml
+
+QtObject {
+ property var myItem: []
+ Component.onCompleted: myItem[0] = 10
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/typePropagationLoop.qml b/tests/auto/qml/qmlcppcodegen/data/typePropagationLoop.qml
new file mode 100644
index 0000000000..b2fdabfd2d
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/typePropagationLoop.qml
@@ -0,0 +1,9 @@
+import QtQml
+
+QtObject {
+ property int j: {
+ var tmp = Qt.PartiallyChecked
+ for (var i = 0; i < Qt.Checked; i++) {}
+ return tmp + i;
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/undefinedToDouble.qml b/tests/auto/qml/qmlcppcodegen/data/undefinedToDouble.qml
new file mode 100644
index 0000000000..e76443a2e0
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/undefinedToDouble.qml
@@ -0,0 +1,6 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property double d: Math.max(undefined, 40)
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/versionmismatch.qml b/tests/auto/qml/qmlcppcodegen/data/versionmismatch.qml
new file mode 100644
index 0000000000..2fa163c047
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/versionmismatch.qml
@@ -0,0 +1,10 @@
+import QtQml
+import TestTypes 1.0
+
+QtObject {
+ property int inaccessible: 4
+ property CppBaseClass a: CppBaseClass {
+ property int b: inaccessible + 1
+ }
+ property int c: a.b
+}
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 186758518e..7d302d611f 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -2,6 +2,7 @@
#include <data/birthdayparty.h>
#include <data/cppbaseclass.h>
+#include <data/enumproblems.h>
#include <data/objectwithmethod.h>
#include <QtQml/private/qqmlengine_p.h>
@@ -132,6 +133,16 @@ private slots:
void stringToByteArray();
void listPropertyAsModel();
void notNotString();
+ void inaccessibleProperty();
+ void typePropagationLoop();
+ void nullComparison();
+ void signalIndexMismatch();
+ void callWithSpread();
+ void enumConversion();
+ void enumProblems();
+ void storeElementSideEffects();
+ void undefinedToDouble();
+ void enumFromBadSingleton();
};
void tst_QmlCppCodegen::simpleBinding()
@@ -1956,8 +1967,19 @@ void tst_QmlCppCodegen::typedArray()
QList<int>({1, 2, 3, 4}));
QCOMPARE(qvariant_cast<QList<QDateTime>>(o->property("values4")),
QList<QDateTime>({date, date, date}));
- QCOMPARE(qvariant_cast<QList<double>>(o->property("values5")),
- QList<double>({1, 2, 3.4, 30, 0, 0}));
+ {
+ const QList<double> actual
+ = qvariant_cast<QList<double>>(o->property("values5"));
+ const QList<double> expected
+ = QList<double>({1, 2, 3.4, 30, std::numeric_limits<double>::quiet_NaN(), 0});
+ QCOMPARE(actual.size(), expected.size());
+ for (qsizetype i = 0, end = actual.size(); i != end; ++i) {
+ if (std::isnan(expected[i]))
+ QVERIFY(std::isnan(actual[i]));
+ else
+ QCOMPARE(actual[i], expected[i]);
+ }
+ }
date = QDateTime::currentDateTime();
o->setProperty("aDate", date);
QCOMPARE(qvariant_cast<QList<QDateTime>>(o->property("values4")),
@@ -2366,6 +2388,7 @@ void tst_QmlCppCodegen::badSequence()
other->setBarzles(barzles);
QCOMPARE(self->barzles(), barzles);
+ QCOMPARE(self->property("l").toInt(), 2);
}
void tst_QmlCppCodegen::enumLookup()
@@ -2438,6 +2461,151 @@ void tst_QmlCppCodegen::runInterpreted()
#endif
}
+void tst_QmlCppCodegen::inaccessibleProperty()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/versionmismatch.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+
+ QCOMPARE(o->property("c").toInt(), 5);
+}
+
+void tst_QmlCppCodegen::typePropagationLoop()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/typePropagationLoop.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+
+ QCOMPARE(o->property("j").toInt(), 3);
+}
+
+void tst_QmlCppCodegen::nullComparison()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/nullComparison.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+
+ QCOMPARE(o->property("v").toInt(), 1);
+ QCOMPARE(o->property("w").toInt(), 3);
+ QCOMPARE(o->property("x").toInt(), 1);
+ QCOMPARE(o->property("y").toInt(), 5);
+}
+
+void tst_QmlCppCodegen::signalIndexMismatch()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c1(&engine, QUrl(u"qrc:/TestTypes/signalIndexMismatch.qml"_s));
+ QVERIFY2(c1.isReady(), qPrintable(c1.errorString()));
+
+ QScopedPointer<QObject> item(c1.create());
+ const auto visualIndexBeforeMoveList = item->property("visualIndexBeforeMove").toList();
+ const auto visualIndexAfterMoveList = item->property("visualIndexAfterMove").toList();
+
+ QCOMPARE(visualIndexBeforeMoveList, QList<QVariant>({ 0, 1, 2 }));
+ QCOMPARE(visualIndexAfterMoveList, QList<QVariant>({ 0, 1, 2 }));
+}
+
+void tst_QmlCppCodegen::callWithSpread()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/callWithSpread.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QTest::ignoreMessage(QtCriticalMsg, "That is great!");
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+};
+
+void tst_QmlCppCodegen::enumConversion()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/enumConversion.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(o);
+ QCOMPARE(o->property("test").toInt(), 0x04);
+ QCOMPARE(o->property("test_1").toBool(), true);
+};
+
+void tst_QmlCppCodegen::enumProblems()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/enumProblems.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> outer(c.create());
+ QVERIFY(!outer.isNull());
+ QObject *inner = outer->property("o").value<QObject *>();
+ QVERIFY(inner);
+
+ Foo *bar = inner->property("bar").value<Foo *>();
+ QVERIFY(bar);
+ QCOMPARE(bar->type(), Foo::Component);
+
+ Foo *fighter = inner->property("fighter").value<Foo *>();
+ QVERIFY(fighter);
+ QCOMPARE(fighter->type(), Foo::Fighter);
+}
+
+void tst_QmlCppCodegen::storeElementSideEffects()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/storeElementSideEffects.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(o);
+
+ const QJSValue prop = o->property("myItem").value<QJSValue>();
+ QVERIFY(prop.isArray());
+ QCOMPARE(prop.property(0).toInt(), 10);
+};
+
+void tst_QmlCppCodegen::undefinedToDouble()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/undefinedToDouble.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+ const QVariant d = o->property("d");
+ QCOMPARE(d.metaType(), QMetaType::fromType<double>());
+ QVERIFY(std::isnan(d.toDouble()));
+}
+
+void tst_QmlCppCodegen::enumFromBadSingleton()
+{
+ QQmlEngine e;
+ const QUrl url(u"qrc:/TestTypes/enumFromBadSingleton.qml"_s);
+ QQmlComponent c(&e, url);
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+
+#if QT_DEPRECATED_SINCE(6,4)
+ QTest::ignoreMessage(
+ QtWarningMsg, qPrintable(
+ url.toString()
+ + u":5:5: TypeError: Cannot read property 'TestA' of undefined"_s));
+#else
+ QTest::ignoreMessage(
+ QtWarningMsg, qPrintable(
+ url.toString()
+ + u":5:5: ReferenceError: DummyObjekt is not defined"_s));
+#endif
+
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(o);
+ QVERIFY(o->objectName().isEmpty());
+}
+
QTEST_MAIN(tst_QmlCppCodegen)
#include "tst_qmlcppcodegen.moc"
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
index dc4b66e8f9..7aeb23a398 100644
--- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
+++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
@@ -40,6 +40,7 @@ private slots:
void cppRegisteredSingletonDependency();
void cacheModuleScripts();
void reuseStaticMappings();
+ void invalidateSaveLoadCache();
private:
QDir m_qmlCacheDirectory;
@@ -527,6 +528,7 @@ void tst_qmldiskcache::recompileAfterChange()
CleanlyLoadingComponent component(&engine, testCompiler.testFilePath);
QScopedPointer<TypeVersion2> obj(qobject_cast<TypeVersion2*>(component.create()));
QVERIFY(!obj.isNull());
+ qDebug() << obj->property("x");
QVERIFY(QFileInfo(testCompiler.cacheFilePath).lastModified() > initialCacheTimeStamp);
}
}
@@ -697,7 +699,7 @@ void tst_qmldiskcache::cacheResources()
}
const QSet<QString> entries = entrySet(m_qmlCacheDirectory).subtract(existingFiles);
- QCOMPARE(entries.count(), 1);
+ QCOMPARE(entries.size(), 1);
QDateTime cacheFileTimeStamp;
@@ -726,7 +728,7 @@ void tst_qmldiskcache::cacheResources()
{
const QSet<QString> entries = entrySet(m_qmlCacheDirectory).subtract(existingFiles);
- QCOMPARE(entries.count(), 1);
+ QCOMPARE(entries.size(), 1);
QCOMPARE(QFileInfo(m_qmlCacheDirectory.absoluteFilePath(*entries.cbegin())).lastModified().toMSecsSinceEpoch(),
cacheFileTimeStamp.toMSecsSinceEpoch());
@@ -972,7 +974,7 @@ void tst_qmldiskcache::cacheModuleScripts()
const QSet<QString> entries = entrySet(m_qmlCacheDirectory, QStringList("*.mjsc"));
- QCOMPARE(entries.count(), 1);
+ QCOMPARE(entries.size(), 1);
QDateTime cacheFileTimeStamp;
@@ -1007,6 +1009,112 @@ void tst_qmldiskcache::reuseStaticMappings()
QCOMPARE(testCompiler.unitData(), data1);
}
+class AParent : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int x MEMBER x)
+public:
+ AParent(QObject *parent = nullptr) : QObject(parent) {}
+ int x = 25;
+};
+
+class BParent : public QObject
+{
+ Q_OBJECT
+
+ // Insert y before x, to change the property index of x
+ Q_PROPERTY(int y MEMBER y)
+
+ Q_PROPERTY(int x MEMBER x)
+public:
+ BParent(QObject *parent = nullptr) : QObject(parent) {}
+ int y = 13;
+ int x = 25;
+};
+
+static QString writeTempFile(
+ const QTemporaryDir &tempDir, const QString &fileName, const char *contents) {
+ QFile f(tempDir.path() + '/' + fileName);
+ const bool ok = f.open(QIODevice::WriteOnly | QIODevice::Truncate);
+ Q_ASSERT(ok);
+ f.write(contents);
+ return f.fileName();
+};
+
+void tst_qmldiskcache::invalidateSaveLoadCache()
+{
+ qmlRegisterType<AParent>("Base", 1, 0, "Parent");
+ QQmlEngine e;
+
+ // If you store a CU to a .qmlc file at run time, the .qmlc file will contain
+ // alias entries with the encodedMetaPropertyIndex pre-resolved. That's in
+ // contrast to .qmlc files generated ahead of time. Exploit that to cause
+ // a need to recompile the file.
+
+ QTemporaryDir tempDir;
+ const QString fileName = writeTempFile(
+ tempDir, QLatin1String("a.qml"),
+ "import Base\nParent { id: self; property alias z: self.x }");
+ const QUrl url = QUrl::fromLocalFile(fileName);
+ waitForFileSystem();
+
+ {
+ QQmlComponent a(&e, url);
+ QVERIFY2(a.isReady(), qPrintable(a.errorString()));
+ QScopedPointer<QObject> ao(a.create());
+ QVERIFY(!ao.isNull());
+ AParent *ap = qobject_cast<AParent *>(ao.data());
+ QCOMPARE(ap->property("z").toInt(), ap->x);
+ }
+
+ QString errorString;
+ QQmlRefPointer<QV4::ExecutableCompilationUnit> oldUnit
+ = QV4::ExecutableCompilationUnit::create();
+ QVERIFY2(oldUnit->loadFromDisk(url, QFileInfo(fileName).lastModified(), &errorString), qPrintable(errorString));
+
+ // Produce a checksum mismatch.
+ e.clearComponentCache();
+ qmlClearTypeRegistrations();
+ qmlRegisterType<BParent>("Base", 1, 0, "Parent");
+
+ {
+ QQmlComponent b(&e, url);
+ QVERIFY2(b.isReady(), qPrintable(b.errorString()));
+ QScopedPointer<QObject> bo(b.create());
+ QVERIFY(!bo.isNull());
+ BParent *bp = qobject_cast<BParent *>(bo.data());
+ QCOMPARE(bp->property("z").toInt(), bp->x);
+ }
+
+ // Make it recompile again.
+ e.clearComponentCache();
+ {
+ QFile file(fileName);
+ file.open(QIODevice::WriteOnly | QIODevice::Append);
+ file.write(" ");
+ }
+ waitForFileSystem();
+
+ {
+ QQmlComponent b(&e, url);
+ QVERIFY2(b.isReady(), qPrintable(b.errorString()));
+ QScopedPointer<QObject> bo(b.create());
+ QVERIFY(!bo.isNull());
+ BParent *bp = qobject_cast<BParent *>(bo.data());
+ QCOMPARE(bp->property("z").toInt(), bp->x);
+ }
+
+ // Verify that the mapped unit data is actually different now.
+ // The cache should have been invalidated after all.
+ // So, now we should be able to load a freshly written CU.
+
+ QQmlRefPointer<QV4::ExecutableCompilationUnit> unit
+ = QV4::ExecutableCompilationUnit::create();
+ QVERIFY2(unit->loadFromDisk(url, QFileInfo(fileName).lastModified(), &errorString), qPrintable(errorString));
+
+ QVERIFY(unit->unitData() != oldUnit->unitData());
+}
+
QTEST_MAIN(tst_qmldiskcache)
#include "tst_qmldiskcache.moc"
diff --git a/tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml b/tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml
new file mode 100644
index 0000000000..0c7a2829c9
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/dontRemoveComments.formatted.qml
@@ -0,0 +1,13 @@
+Item {
+ property var test: [{
+ // Testing
+ "foo": "bar"
+ }]
+
+ onTestChanged: {
+ fooBar(test, {
+ // Testing
+ "foo": "bar"
+ });
+ }
+}
diff --git a/tests/auto/qml/qmlformat/data/dontRemoveComments.qml b/tests/auto/qml/qmlformat/data/dontRemoveComments.qml
new file mode 100644
index 0000000000..1797834879
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/dontRemoveComments.qml
@@ -0,0 +1,13 @@
+Item {
+ property var test: [{
+// Testing
+ "foo": "bar"
+ }]
+
+ onTestChanged: {
+ fooBar(test, {
+ // Testing
+ "foo": "bar"
+ });
+ }
+}
diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
index 9d7beb23a7..bc59b8dce1 100644
--- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp
+++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
@@ -147,7 +147,7 @@ void TestQmlformat::initTestCase()
QStringList TestQmlformat::findFiles(const QDir &d)
{
- for (int ii = 0; ii < m_excludedDirs.count(); ++ii) {
+ for (int ii = 0; ii < m_excludedDirs.size(); ++ii) {
QString s = m_excludedDirs.at(ii);
if (d.absolutePath().endsWith(s))
return QStringList();
@@ -276,6 +276,9 @@ void TestQmlformat::testFormat_data()
QTest::newRow("forWithLet")
<< "forWithLet.qml"
<< "forWithLet.formatted.qml" << QStringList {} << RunOption::OnCopy;
+ QTest::newRow("dontRemoveComments")
+ << "dontRemoveComments.qml"
+ << "dontRemoveComments.formatted.qml" << QStringList {} << RunOption::OnCopy;
}
void TestQmlformat::testFormat()
diff --git a/tests/auto/qml/qmllint/data/Foo.qml b/tests/auto/qml/qmllint/data/Foo.qml
new file mode 100644
index 0000000000..6e47488e95
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/Foo.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+QtObject {
+ function whatSUp() : string { return "I'm crashing"; }
+}
diff --git a/tests/auto/qml/qmllint/data/callBase.qml b/tests/auto/qml/qmllint/data/callBase.qml
new file mode 100644
index 0000000000..435a5f04dd
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/callBase.qml
@@ -0,0 +1,7 @@
+import QtQml
+
+QtObject {
+ function bar(foo : Foo) {
+ var state = foo.whatSUp()
+ }
+}
diff --git a/tests/auto/qml/qmllint/data/enumsOfScrollBar.qml b/tests/auto/qml/qmllint/data/enumsOfScrollBar.qml
new file mode 100644
index 0000000000..d0cd5591b9
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/enumsOfScrollBar.qml
@@ -0,0 +1,7 @@
+import QtQuick
+import QtQuick.Controls
+
+Item {
+ Component.onCompleted: console.log(ScrollBar.AlwaysOn)
+}
+
diff --git a/tests/auto/qml/qmllint/data/inlineComponentNoComponent.qml b/tests/auto/qml/qmllint/data/inlineComponentNoComponent.qml
new file mode 100644
index 0000000000..f72b0a27c5
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/inlineComponentNoComponent.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+Item {
+ component Base : eItm { }
+}
+
diff --git a/tests/auto/qml/qmllint/data/invalidAliasTarget.qml b/tests/auto/qml/qmllint/data/invalidAliasTarget.qml
new file mode 100644
index 0000000000..e6ad63b518
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/invalidAliasTarget.qml
@@ -0,0 +1,11 @@
+import QtQuick
+
+Item {
+ Item {
+
+ property alias innerinner
+ property alias name: function f() {}
+
+ property alias innerObj: 1+1
+ }
+}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index e0e690ed99..d28390b719 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -89,6 +89,8 @@ private Q_SLOTS:
void importMultipartUri();
+ void testLineEndings();
+
#if QT_CONFIG(library)
void testPlugin();
void quickPlugin();
@@ -449,6 +451,18 @@ void TestQmllint::dirtyQmlCode_data()
<< Result { { Message {
QStringLiteral("Alias \"a\" is part of an alias cycle"),
3, 1 } } };
+ QTest::newRow("invalidAliasTarget1") << QStringLiteral("invalidAliasTarget.qml")
+ << Result { { Message {
+ QStringLiteral("Invalid alias expression – an initalizer is needed."),
+ 6, 18 } } };
+ QTest::newRow("invalidAliasTarget2") << QStringLiteral("invalidAliasTarget.qml")
+ << Result { { Message {
+ QStringLiteral("Invalid alias expression. Only IDs and field member expressions can be aliased"),
+ 7, 30 } } };
+ QTest::newRow("invalidAliasTarget3") << QStringLiteral("invalidAliasTarget.qml")
+ << Result { { Message {
+ QStringLiteral("Invalid alias expression. Only IDs and field member expressions can be aliased"),
+ 9, 34 } } };
QTest::newRow("badParent")
<< QStringLiteral("badParent.qml")
<< Result { { Message { QStringLiteral("Property \"rrr\" not found on type \"Item\""),
@@ -782,6 +796,11 @@ expression: \${expr} \${expr} \\\${expr} \\\${expr}`)",
<< QStringLiteral("nestedInlineComponents.qml")
<< Result { { Message {
QStringLiteral("Nested inline components are not supported") } } };
+ QTest::newRow("inlineComponentNoComponent")
+ << QStringLiteral("inlineComponentNoComponent.qml")
+ << Result { { Message {
+ QStringLiteral("Inline component declaration must be followed by a typename"),
+ 3, 2 } } };
QTest::newRow("WithStatement") << QStringLiteral("WithStatement.qml")
<< Result { { Message { QStringLiteral(
"with statements are strongly discouraged") } } };
@@ -1145,6 +1164,8 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("BindingTypeMismatchFunction") << QStringLiteral("bindingTypeMismatchFunction.qml");
QTest::newRow("BindingTypeMismatch") << QStringLiteral("bindingTypeMismatch.qml");
QTest::newRow("template literal (substitution)") << QStringLiteral("templateStringSubstitution.qml");
+ QTest::newRow("enumsOfScrollBar") << QStringLiteral("enumsOfScrollBar.qml");
+ QTest::newRow("callBase") << QStringLiteral("callBase.qml");
}
void TestQmllint::cleanQmlCode()
@@ -1618,6 +1639,36 @@ void TestQmllint::importMultipartUri()
runTest("here.qml", Result::clean(), {}, { testFile("Elsewhere/qmldir") });
}
+void TestQmllint::testLineEndings()
+{
+ {
+ const auto textWithLF = QString::fromUtf16(u"import QtQuick 2.0\nimport QtTest 2.0 // qmllint disable unused-imports\n"
+ "import QtTest 2.0 // qmllint disable\n\nItem {\n @Deprecated {}\n property string deprecated\n\n "
+ "property string a: root.a // qmllint disable unqualifi77777777777777777777777777777777777777777777777777777"
+ "777777777777777777777777777777777777ed\n property string b: root.a // qmllint di000000000000000000000000"
+ "000000000000000000inyyyyyyyyg c: root.a\n property string d: root.a\n // qmllint enable unqualified\n\n "
+ "//qmllint d 4isable\n property string e: root.a\n Component.onCompleted: {\n console.log"
+ "(deprecated);\n }\n // qmllint enable\n\n}\n");
+
+ const auto lintResult = m_linter.lintFile( {}, &textWithLF, true, nullptr, {}, {}, {}, {});
+
+ QCOMPARE(lintResult, QQmlJSLinter::LintResult::HasWarnings);
+ }
+ {
+ const auto textWithCRLF = QString::fromUtf16(u"import QtQuick 2.0\nimport QtTest 2.0 // qmllint disable unused-imports\n"
+ "import QtTest 2.0 // qmllint disable\n\nItem {\n @Deprecated {}\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r"
+ "\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\n property string deprecated\n\n property string a: root.a "
+ "// qmllint disable unqualifi77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777ed\n "
+ "property string b: root.a // qmllint di000000000000000000000000000000000000000000inyyyyyyyyg c: root.a\n property string d: "
+ "root.a\n // qmllint enable unqualified\n\n //qmllint d 4isable\n property string e: root.a\n Component.onCompleted: "
+ "{\n console.log(deprecated);\n }\n // qmllint enable\n\n}\n");
+
+ const auto lintResult = m_linter.lintFile( {}, &textWithCRLF, true, nullptr, {}, {}, {}, {});
+
+ QCOMPARE(lintResult, QQmlJSLinter::LintResult::HasWarnings);
+ }
+}
+
#if QT_CONFIG(library)
void TestQmllint::testPlugin()
{
diff --git a/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt b/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt
index 45fc2492dd..cf3cd41fa4 100644
--- a/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt
+++ b/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt
@@ -90,6 +90,8 @@ set(qml_sources
deferredProperties_group.qml
deferredProperties_attached.qml
deferredProperties_complex.qml
+ repeaterCrash.qml
+ aliases.qml
# support types:
DefaultPropertySingleChild.qml
@@ -98,6 +100,9 @@ set(qml_sources
LocalWithOnCompleted.qml
LocallyImported_context.qml
# SingletonThing.qml
+ ComponentWithAlias1.qml
+ ComponentWithAlias2.qml
+ ComponentWithAlias3.qml
badFile.qml
)
diff --git a/tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias1.qml b/tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias1.qml
new file mode 100644
index 0000000000..210cf1e159
--- /dev/null
+++ b/tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias1.qml
@@ -0,0 +1,8 @@
+import QtQuick
+
+Item {
+ property alias setMe: firstComponent.setMe
+ ComponentWithAlias2 {
+ id: firstComponent
+ }
+}
diff --git a/tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias2.qml b/tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias2.qml
new file mode 100644
index 0000000000..818f3a464e
--- /dev/null
+++ b/tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias2.qml
@@ -0,0 +1,8 @@
+import QtQuick
+
+Item {
+ property alias setMe: firstComponent.setMe
+ ComponentWithAlias3 {
+ id: firstComponent
+ }
+}
diff --git a/tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias3.qml b/tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias3.qml
new file mode 100644
index 0000000000..87b917ad19
--- /dev/null
+++ b/tests/auto/qml/qmltc/QmltcTests/ComponentWithAlias3.qml
@@ -0,0 +1,5 @@
+import QtQuick
+
+Item {
+ property string setMe: "Set me!"
+}
diff --git a/tests/auto/qml/qmltc/QmltcTests/aliases.qml b/tests/auto/qml/qmltc/QmltcTests/aliases.qml
new file mode 100644
index 0000000000..9f13f7b17a
--- /dev/null
+++ b/tests/auto/qml/qmltc/QmltcTests/aliases.qml
@@ -0,0 +1,29 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+
+Item {
+ property alias aliasToAlias: subItem.aliasToAlias
+ Item {
+ id: subItem
+ property alias aliasToAlias: subsubItem.aliasToAlias
+
+ Item {
+ id: subsubItem
+ property alias aliasToAlias: subsubsubItem.value
+
+ Item {
+ id: subsubsubItem
+ property string value: "Hello World!"
+ }
+ }
+ }
+
+ property alias aliasToOtherFile: inOtherFile.setMe
+
+ ComponentWithAlias1 {
+ id: inOtherFile
+ }
+}
+
diff --git a/tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml b/tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml
new file mode 100644
index 0000000000..7c4dad5a4e
--- /dev/null
+++ b/tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml
@@ -0,0 +1,22 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+
+Item {
+ Item {
+ property string objName: "Child1"
+ }
+
+ Repeater {
+ model: 4
+
+ Item {
+ property string objName: "Child" + (index + 1)
+ }
+ }
+
+ Item {
+ property string objName: "Child6"
+ }
+}
diff --git a/tests/auto/qml/qmltc/tst_qmltc.cpp b/tests/auto/qml/qmltc/tst_qmltc.cpp
index 5a0d7eea9d..f958b1880b 100644
--- a/tests/auto/qml/qmltc/tst_qmltc.cpp
+++ b/tests/auto/qml/qmltc/tst_qmltc.cpp
@@ -69,7 +69,8 @@
#include "privatepropertysubclass.h"
#include "calqlatrbits.h"
#include "propertychangeandsignalhandlers.h"
-
+#include "repeatercrash.h"
+#include "aliases.h"
#include "testprivateproperty.h"
// Qt:
@@ -1052,8 +1053,8 @@ void tst_qmltc::propertyAlias_external()
QSignalSpy heightAliasChangedSpy(&created, &PREPEND_NAMESPACE(propertyAlias_external)::heightAliasChanged);
created.setHeight(10);
QCOMPARE(created.heightAlias(), 10);
- QCOMPARE(heightChangedSpy.count(), 1);
- QCOMPARE(heightAliasChangedSpy.count(), 1);
+ QCOMPARE(heightChangedSpy.size(), 1);
+ QCOMPARE(heightAliasChangedSpy.size(), 1);
}
// TODO: we need to support RESET in aliases as well? (does it make sense?)
@@ -1138,15 +1139,15 @@ void tst_qmltc::complexAliases()
created.setAFont(newFont);
QCOMPARE(created.aFont(), newFont);
QCOMPARE(created.aFont(), theText->property("font").value<QFont>());
- QCOMPARE(aFontSpy.count(), 1);
+ QCOMPARE(aFontSpy.size(), 1);
newFont.setStyle(QFont::StyleOblique);
theText->setProperty("font", newFont);
QCOMPARE(theText->property("font").value<QFont>(), newFont);
QCOMPARE(created.aFont(), theText->property("font").value<QFont>());
- QCOMPARE(aFontSpy.count(), 2);
+ QCOMPARE(aFontSpy.size(), 2);
created.setAWordSpacing(1);
- QCOMPARE(aFontSpy.count(), 3);
+ QCOMPARE(aFontSpy.size(), 3);
// aliasToObjectAlias:
QCOMPARE(created.aliasToObjectAlias(), created.aRectObject());
@@ -1181,12 +1182,12 @@ void tst_qmltc::complexAliases()
QCOMPARE(created.aliasToValueTypeAlias(), newFont);
QCOMPARE(created.aliasToValueTypeAlias(), created.aFont());
QCOMPARE(created.aliasToValueTypeAlias(), theText->property("font").value<QFont>());
- QCOMPARE(aFontSpy.count(), 4);
- QCOMPARE(aliasToValueTypeAliasSpy.count(), 1);
+ QCOMPARE(aFontSpy.size(), 4);
+ QCOMPARE(aliasToValueTypeAliasSpy.size(), 1);
newFont.setPixelSize(12);
created.setAFont(newFont);
- QCOMPARE(aFontSpy.count(), 5);
- QCOMPARE(aliasToValueTypeAliasSpy.count(), 2);
+ QCOMPARE(aFontSpy.size(), 5);
+ QCOMPARE(aliasToValueTypeAliasSpy.size(), 2);
QCOMPARE(created.aliasToValueTypeAlias(), created.aFont());
QCOMPARE(created.aliasToValueTypeAlias(), theText->property("font").value<QFont>());
@@ -1195,8 +1196,8 @@ void tst_qmltc::complexAliases()
created.setAliasToPropertyOfValueTypeAlias(3);
QCOMPARE(created.aliasToPropertyOfValueTypeAlias(), created.aFont().pixelSize());
QCOMPARE(created.aFont(), theText->property("font").value<QFont>());
- QCOMPARE(aFontSpy.count(), 6);
- QCOMPARE(aliasToValueTypeAliasSpy.count(), 3);
+ QCOMPARE(aFontSpy.size(), 6);
+ QCOMPARE(aliasToValueTypeAliasSpy.size(), 3);
// aliasToImportedMessage:
QCOMPARE(created.aliasToImportedMessage(), localImport->property("message").toString());
@@ -1234,7 +1235,7 @@ void tst_qmltc::complexAliases()
newPalette->fromQPalette(QPalette(QColor(u"cyan"_s)));
QCOMPARE(newPalette->button(), QColor(u"cyan"_s));
created.setAliasToPrivatePalette(newPalette);
- QCOMPARE(paletteChangedSpy.count(), 1);
+ QCOMPARE(paletteChangedSpy.size(), 1);
QCOMPARE(QQuickItemPrivate::get(theRect)->palette()->button(), QColor(u"cyan"_s));
QCOMPARE(created.aliasToPrivatePalette(), QQuickItemPrivate::get(theRect)->palette());
@@ -1316,9 +1317,9 @@ void tst_qmltc::componentHelloWorld()
QCOMPARE(created->hello(), QStringLiteral("Hello, World!"));
QSignalSpy onDestroySpy(created.get(), &PREPEND_NAMESPACE(ComponentHelloWorld)::sDestroying);
- QCOMPARE(onDestroySpy.count(), 0);
+ QCOMPARE(onDestroySpy.size(), 0);
created.reset();
- QCOMPARE(onDestroySpy.count(), 1);
+ QCOMPARE(onDestroySpy.size(), 1);
}
void tst_qmltc::propertyReturningFunction()
@@ -2091,7 +2092,7 @@ void tst_qmltc::calqlatrBits()
QSignalSpy scaleChangedSpy(textItem, &QQuickItem::scaleChanged);
controller->completeToBeginning();
- QTRY_VERIFY(scaleChangedSpy.count() > 0);
+ QTRY_VERIFY(scaleChangedSpy.size() > 0);
}
void tst_qmltc::trickyPropertyChangeAndSignalHandlers()
@@ -2161,4 +2162,66 @@ void tst_qmltc::trickyPropertyChangeAndSignalHandlers()
QCOMPARE(created.cChangedCount3(), 22);
}
+void tst_qmltc::repeaterCrash()
+{
+ QQmlEngine e;
+ PREPEND_NAMESPACE(repeaterCrash) fromQmltc(&e);
+
+ QQmlComponent component(&e, "qrc:/QmltcTests/repeaterCrash.qml");
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QQuickItem> fromEngine(qobject_cast<QQuickItem *>(component.create()));
+ QVERIFY(fromEngine);
+
+ const int size = 7;
+
+ const auto listFromEngine = fromEngine->childItems();
+ const auto listFromQmltc = fromQmltc.childItems();
+
+ QCOMPARE(listFromEngine.size(), size);
+ QCOMPARE(listFromQmltc.size(), size);
+
+ for (int i = 0; i < size; i++) {
+ // the repeater itself has no objName property
+ if (i == 5)
+ continue;
+
+ const QVariant nameFromEngine = listFromEngine.at(i)->property("objName");
+ const QVariant nameFromQmltc = listFromQmltc.at(i)->property("objName");
+
+ QVERIFY(nameFromEngine.isValid());
+ QVERIFY(nameFromQmltc.isValid());
+ QCOMPARE(nameFromQmltc.toString(), nameFromEngine.toString());
+ }
+}
+
+void tst_qmltc::aliases()
+{
+ QQmlEngine e;
+ PREPEND_NAMESPACE(aliases) fromQmltc(&e);
+
+ QQmlComponent component(&e);
+ component.loadUrl(QUrl("qrc:/QmltcTests/aliases.qml"));
+ QVERIFY2(!component.isError(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> fromComponent(component.create());
+ const QString testString = u"myTestString"_s;
+
+ QCOMPARE(fromQmltc.aliasToAlias(), u"Hello World!"_s);
+ QCOMPARE(fromComponent->property("aliasToAlias"), u"Hello World!"_s);
+
+ fromQmltc.setAliasToAlias(testString);
+ QVERIFY(fromComponent->setProperty("aliasToAlias", testString));
+
+ QCOMPARE(fromQmltc.aliasToAlias(), testString);
+ QCOMPARE(fromComponent->property("aliasToAlias"), testString);
+
+ QCOMPARE(fromQmltc.aliasToOtherFile(), u"Set me!"_s);
+ QCOMPARE(fromComponent->property("aliasToOtherFile"), u"Set me!"_s);
+
+ fromQmltc.setAliasToOtherFile(testString);
+ QVERIFY(fromComponent->setProperty("aliasToOtherFile", testString));
+
+ QCOMPARE(fromQmltc.aliasToOtherFile(), testString);
+ QCOMPARE(fromComponent->property("aliasToOtherFile"), testString);
+}
+
QTEST_MAIN(tst_qmltc)
diff --git a/tests/auto/qml/qmltc/tst_qmltc.h b/tests/auto/qml/qmltc/tst_qmltc.h
index 19f225a548..bbc3be73a7 100644
--- a/tests/auto/qml/qmltc/tst_qmltc.h
+++ b/tests/auto/qml/qmltc/tst_qmltc.h
@@ -82,4 +82,6 @@ private slots:
void privateProperties();
void calqlatrBits(); // corner cases from calqlatr demo
void trickyPropertyChangeAndSignalHandlers();
+ void repeaterCrash();
+ void aliases();
};
diff --git a/tests/auto/qml/qmltc_qprocess/data/kebab-case.qml b/tests/auto/qml/qmltc_qprocess/data/kebab-case.qml
new file mode 100644
index 0000000000..68c21087cb
--- /dev/null
+++ b/tests/auto/qml/qmltc_qprocess/data/kebab-case.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.15
+
+Item {
+
+}
diff --git a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp
index b3079334b6..911906f44d 100644
--- a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp
+++ b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp
@@ -47,6 +47,7 @@ private slots:
void inlineComponent();
void singleton();
void warningsAsErrors();
+ void dashesInFilename();
};
#ifndef TST_QMLTC_QPROCESS_RESOURCES
@@ -192,5 +193,14 @@ void tst_qmltc_qprocess::warningsAsErrors()
QVERIFY2(errors.contains(u"Error:"_s), qPrintable(errors)); // Note: not a warning!
}
+void tst_qmltc_qprocess::dashesInFilename()
+{
+ {
+ const auto errors = runQmltc(u"kebab-case.qml"_s, false);
+ QVERIFY(errors.contains(
+ u"The given QML filename is unsuited for type compilation: the name must consist of letters, digits and underscores, starting with a letter or an underscore and ending in '.qml'!"_s));
+ }
+}
+
QTEST_MAIN(tst_qmltc_qprocess)
#include "tst_qmltc_qprocess.moc"
diff --git a/tests/auto/qml/qqmlapplicationengine/androidassets/tst_androidassets.cpp b/tests/auto/qml/qqmlapplicationengine/androidassets/tst_androidassets.cpp
index 4ba7deb98e..7a6774c268 100644
--- a/tests/auto/qml/qqmlapplicationengine/androidassets/tst_androidassets.cpp
+++ b/tests/auto/qml/qqmlapplicationengine/androidassets/tst_androidassets.cpp
@@ -41,7 +41,7 @@ void tst_AndroidAssets::loadsFromAssetsPath()
// load QML file from assets, by path:
engine.load(pathPrefix() + QStringLiteral("/qml/main.qml"));
- QTRY_VERIFY(engine.rootObjects().length() == 1);
+ QTRY_VERIFY(engine.rootObjects().size() == 1);
QVERIFY(failureSpy.isEmpty());
}
@@ -52,7 +52,7 @@ void tst_AndroidAssets::loadsFromAssetsUrl()
// load QML file from assets, by URL:
engine.load(QUrl(urlPrefix() + QStringLiteral("/qml/main.qml")));
- QTRY_VERIFY(engine.rootObjects().length() == 1);
+ QTRY_VERIFY(engine.rootObjects().size() == 1);
QVERIFY(failureSpy.isEmpty());
}
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
index 43f7296d4f..d0f580cf5f 100644
--- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
+++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
@@ -57,14 +57,14 @@ void tst_qqmlapplicationengine::basicLoading()
QSignalSpy objectCreated(test, SIGNAL(objectCreated(QObject*,QUrl)));
test->load(testFileUrl("basicTest.qml"));
- QCOMPARE(objectCreated.count(), size);//one less than rootObjects().size() because we missed the first one
+ QCOMPARE(objectCreated.size(), size);//one less than rootObjects().size() because we missed the first one
QCOMPARE(test->rootObjects().size(), ++size);
QVERIFY(test->rootObjects()[size -1]);
QVERIFY(test->rootObjects()[size -1]->property("success").toBool());
QByteArray testQml("import QtQml 2.0; QtObject{property bool success: true; property TestItem t: TestItem{}}");
test->loadData(testQml, testFileUrl("dynamicTest.qml"));
- QCOMPARE(objectCreated.count(), size);
+ QCOMPARE(objectCreated.size(), size);
QCOMPARE(test->rootObjects().size(), ++size);
QVERIFY(test->rootObjects()[size -1]);
QVERIFY(test->rootObjects()[size -1]->property("success").toBool());
@@ -215,10 +215,10 @@ void tst_qqmlapplicationengine::applicationProperties()
QCoreApplication::setOrganizationName(originalOrganization);
QCoreApplication::setOrganizationDomain(originalDomain);
- QCOMPARE(nameChanged.count(), 1);
- QCOMPARE(versionChanged.count(), 1);
- QCOMPARE(organizationChanged.count(), 1);
- QCOMPARE(domainChanged.count(), 1);
+ QCOMPARE(nameChanged.size(), 1);
+ QCOMPARE(versionChanged.size(), 1);
+ QCOMPARE(organizationChanged.size(), 1);
+ QCOMPARE(domainChanged.size(), 1);
delete test;
}
@@ -230,12 +230,12 @@ void tst_qqmlapplicationengine::removeObjectsWhenDestroyed()
QSignalSpy objectCreated(test.data(), SIGNAL(objectCreated(QObject*,QUrl)));
test->load(testFileUrl("basicTest.qml"));
- QCOMPARE(objectCreated.count(), 1);
+ QCOMPARE(objectCreated.size(), 1);
QSignalSpy objectDestroyed(test->rootObjects().first(), SIGNAL(destroyed()));
test->rootObjects().first()->deleteLater();
objectDestroyed.wait();
- QCOMPARE(objectDestroyed.count(), 1);
+ QCOMPARE(objectDestroyed.size(), 1);
QCOMPARE(test->rootObjects().size(), 0);
}
@@ -315,7 +315,7 @@ void tst_qqmlapplicationengine::failureToLoadTriggersWarningSignal()
QQmlApplicationEngine test;
QSignalSpy warningObserver(&test, &QQmlApplicationEngine::warnings);
test.load(url);
- QTRY_COMPARE(warningObserver.count(), 1);
+ QTRY_COMPARE(warningObserver.size(), 1);
}
void tst_qqmlapplicationengine::errorWhileCreating()
@@ -330,8 +330,8 @@ void tst_qqmlapplicationengine::errorWhileCreating()
test.load(url);
- QTRY_COMPARE(observer.count(), 1);
- QCOMPARE(failureObserver.count(), 1);
+ QTRY_COMPARE(observer.size(), 1);
+ QCOMPARE(failureObserver.size(), 1);
QCOMPARE(failureObserver.first().first(), url);
QList<QVariant> args = observer.takeFirst();
QVERIFY(args.at(0).isNull());
diff --git a/tests/auto/qml/qqmlbinding/data/bindingWithHandler.qml b/tests/auto/qml/qqmlbinding/data/bindingWithHandler.qml
new file mode 100644
index 0000000000..bd819167d8
--- /dev/null
+++ b/tests/auto/qml/qqmlbinding/data/bindingWithHandler.qml
@@ -0,0 +1,7 @@
+import QtQml
+
+Binding {
+ property string input
+ property string output
+ onInputChanged: output = input
+}
diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
index 53a8c49e94..9c0caf1aee 100644
--- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
+++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
@@ -37,6 +37,7 @@ private slots:
void bindNaNToInt();
void intOverflow();
void generalizedGroupedProperties();
+ void localSignalHandler();
private:
QQmlEngine engine;
@@ -309,7 +310,7 @@ void tst_qqmlbinding::warningOnUnknownProperty()
QScopedPointer<QQuickItem> item { qobject_cast<QQuickItem *>(c.create()) };
QVERIFY(item);
- QCOMPARE(messageHandler.messages().count(), 1);
+ QCOMPARE(messageHandler.messages().size(), 1);
const QString expectedMessage = c.url().toString() + QLatin1String(":6:5: QML Binding: Property 'unknown' does not exist on Item.");
QCOMPARE(messageHandler.messages().first(), expectedMessage);
@@ -324,7 +325,7 @@ void tst_qqmlbinding::warningOnReadOnlyProperty()
QScopedPointer<QQuickItem> item { qobject_cast<QQuickItem *>(c.create()) };
QVERIFY(item);
- QCOMPARE(messageHandler.messages().count(), 1);
+ QCOMPARE(messageHandler.messages().size(), 1);
const QString expectedMessage = c.url().toString() + QLatin1String(":8:5: QML Binding: Property 'name' on Item is read-only.");
QCOMPARE(messageHandler.messages().first(), expectedMessage);
@@ -339,7 +340,7 @@ void tst_qqmlbinding::disabledOnUnknownProperty()
QScopedPointer<QQuickItem> item { qobject_cast<QQuickItem *>(c.create()) };
QVERIFY(item);
- QCOMPARE(messageHandler.messages().count(), 0);
+ QCOMPARE(messageHandler.messages().size(), 0);
}
void tst_qqmlbinding::disabledOnReadonlyProperty()
@@ -350,7 +351,7 @@ void tst_qqmlbinding::disabledOnReadonlyProperty()
QQmlComponent c(&engine, testFileUrl("disabledReadonly.qml"));
QScopedPointer<QQuickItem> item { qobject_cast<QQuickItem *>(c.create()) };
QVERIFY(item);
- QCOMPARE(messageHandler.messages().count(), 0);
+ QCOMPARE(messageHandler.messages().size(), 0);
}
void tst_qqmlbinding::delayed()
@@ -447,7 +448,7 @@ void tst_qqmlbinding::bindingOverwriting()
QVERIFY(item);
QLoggingCategory::setFilterRules(QString());
- QCOMPARE(messageHandler.messages().count(), 2);
+ QCOMPARE(messageHandler.messages().size(), 2);
}
void tst_qqmlbinding::bindToQmlComponent()
@@ -572,6 +573,17 @@ void tst_qqmlbinding::generalizedGroupedProperties()
QCOMPARE(rootAttached->objectName(), QString());
}
+void tst_qqmlbinding::localSignalHandler()
+{
+ QQmlEngine e;
+ QQmlComponent c(&e, testFileUrl("bindingWithHandler.qml"));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+ o->setProperty("input", QStringLiteral("abc"));
+ QCOMPARE(o->property("output").toString(), QStringLiteral("abc"));
+}
+
QTEST_MAIN(tst_qqmlbinding)
#include "tst_qqmlbinding.moc"
diff --git a/tests/auto/qml/qqmlchangeset/CMakeLists.txt b/tests/auto/qml/qqmlchangeset/CMakeLists.txt
index da06b85fad..510e304717 100644
--- a/tests/auto/qml/qqmlchangeset/CMakeLists.txt
+++ b/tests/auto/qml/qqmlchangeset/CMakeLists.txt
@@ -1,10 +1,10 @@
# Generated from qqmlchangeset.pro.
#####################################################################
-## tst_qqmlhangeset Test:
+## tst_qqmlchangeset Test:
#####################################################################
-qt_internal_add_test(tst_qqmlhangeset
+qt_internal_add_test(tst_qqmlchangeset
SOURCES
tst_qqmlchangeset.cpp
PUBLIC_LIBRARIES
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
index c15fdf0323..cf3894ccbb 100644
--- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -162,7 +162,7 @@ void tst_qqmlcomponent::loadEmptyUrl()
c.loadUrl(QUrl());
QVERIFY(c.isError());
- QCOMPARE(c.errors().count(), 1);
+ QCOMPARE(c.errors().size(), 1);
QQmlError error = c.errors().first();
QCOMPARE(error.url(), QUrl());
QCOMPARE(error.line(), -1);
@@ -338,7 +338,7 @@ void tst_qqmlcomponent::qmlCreateObjectDirty()
QQmlEngine engine;
engine.setOutputWarningsToStandardError(false);
QObject::connect(&engine, &QQmlEngine::warnings, [](const QList<QQmlError> &warnings) {
- QCOMPARE(warnings.count(), 1);
+ QCOMPARE(warnings.size(), 1);
QCOMPARE(warnings[0].description(),
"QML Component: Unsuitable arguments passed to createObject(). The first argument "
"should be a QObject* or null, and the second argument should be a JavaScript "
@@ -556,7 +556,7 @@ void tst_qqmlcomponent::onDestructionCount()
engine.setOutputWarningsToStandardError(false);
QCOMPARE(engine.outputWarningsToStandardError(), false);
- QCOMPARE(warnings.count(), 0);
+ QCOMPARE(warnings.size(), 0);
}
void tst_qqmlcomponent::recursion()
@@ -1095,7 +1095,7 @@ void tst_qqmlcomponent::qmlPropertySignalExists()
QSignalSpy changeSignalSpy(o.get(), SIGNAL(pChanged()));
QVERIFY(QMetaObject::invokeMethod(o.get(), "doStuff"));
- QCOMPARE(changeSignalSpy.count(), 1);
+ QCOMPARE(changeSignalSpy.size(), 1);
QCOMPARE(o->property("p").toInt(), 42);
}
diff --git a/tests/auto/qml/qqmlconnections/data/invalidTarget.qml b/tests/auto/qml/qqmlconnections/data/invalidTarget.qml
new file mode 100644
index 0000000000..23599649ec
--- /dev/null
+++ b/tests/auto/qml/qqmlconnections/data/invalidTarget.qml
@@ -0,0 +1,31 @@
+import QtQml
+
+QtObject {
+ id: root
+ objectName: button.objectName
+
+ property QtObject b: QtObject {
+ objectName: "button"
+ id: button
+ signal clicked
+ }
+
+ property Connections c: Connections {
+ id: connections
+ target: null
+ function onClicked() { button.destroy(); }
+ }
+
+ property Timer t: Timer {
+ interval: 10
+ running: true
+ onTriggered: {
+ root.objectName = connections.target.objectName
+ }
+ }
+
+ Component.onCompleted: {
+ connections.target = button;
+ button.clicked()
+ }
+}
diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
index f203bd1800..f23c474907 100644
--- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
+++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
@@ -53,6 +53,7 @@ private slots:
void noAcceleratedGlobalLookup();
void bindToPropertyWithUnderscoreChangeHandler();
+ void invalidTarget();
private:
QQmlEngine engine;
@@ -227,7 +228,7 @@ void tst_qqmlconnections::errors()
QQmlComponent c(&engine, url);
QVERIFY(c.isError());
QList<QQmlError> errors = c.errors();
- QCOMPARE(errors.count(), 1);
+ QCOMPARE(errors.size(), 1);
QCOMPARE(errors.at(0).description(), error);
}
@@ -465,6 +466,25 @@ void tst_qqmlconnections::bindToPropertyWithUnderscoreChangeHandler()
QVERIFY(root->property("success").toBool());
}
+void tst_qqmlconnections::invalidTarget()
+{
+ QQmlEngine engine;
+ const QUrl url = testFileUrl("invalidTarget.qml");
+ QQmlComponent component(&engine, url);
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+
+ QScopedPointer<QObject> root {component.create()};
+ QVERIFY(root);
+ QCOMPARE(root->objectName(), QStringLiteral("button"));
+
+ QTest::ignoreMessage(
+ QtWarningMsg,
+ qPrintable(
+ url.toString()
+ + QLatin1String(":5:5: TypeError: Cannot read property 'objectName' of null")));
+ QTRY_VERIFY(root->objectName().isEmpty());
+}
+
QTEST_MAIN(tst_qqmlconnections)
#include "tst_qqmlconnections.moc"
diff --git a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp
index 1737d1eaeb..11d79707d0 100644
--- a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp
+++ b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp
@@ -58,7 +58,7 @@ void tst_qqmlcpputils::fastConnect()
qmlobject_connect(obj, MyObject, SIGNAL(signal1()), obj, MyObject, SIGNAL(signal2()));
obj->signal1();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
delete obj;
}
diff --git a/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
index 491324fa57..ca66ddb618 100644
--- a/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+++ b/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
@@ -56,7 +56,7 @@ public:
if (parent.isValid())
return 0;
- return mValues.count();
+ return mValues.size();
}
int columnCount(const QModelIndex &parent) const override
@@ -187,15 +187,15 @@ void tst_QQmlDelegateModel::nestedDelegates()
QScopedPointer<QObject> o(c.create());
QQuickItem *item = qobject_cast<QQuickItem *>(o.data());
- QCOMPARE(item->childItems().length(), 2);
+ QCOMPARE(item->childItems().size(), 2);
for (QQuickItem *child : item->childItems()) {
if (child->objectName() != QLatin1String("loader"))
continue;
- QCOMPARE(child->childItems().length(), 1);
+ QCOMPARE(child->childItems().size(), 1);
QQuickItem *timeMarks = child->childItems().at(0);
const QList<QQuickItem *> children = timeMarks->childItems();
- QCOMPARE(children.length(), 2);
+ QCOMPARE(children.size(), 2);
// One of them is the repeater, the other one is the rectangle
QVERIFY(children.at(0)->objectName() == QLatin1String("zap")
diff --git a/tests/auto/qml/qqmlecmascript/BLACKLIST b/tests/auto/qml/qqmlecmascript/BLACKLIST
deleted file mode 100644
index bd25566eef..0000000000
--- a/tests/auto/qml/qqmlecmascript/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[gcCrashRegressionTest]
-macos arm
diff --git a/tests/auto/qml/qqmlecmascript/data/aliasPropertyToIC.qml b/tests/auto/qml/qqmlecmascript/data/aliasPropertyToIC.qml
new file mode 100644
index 0000000000..17116bb091
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/aliasPropertyToIC.qml
@@ -0,0 +1,11 @@
+import QtQml
+
+
+QtObject {
+ id: root
+
+ component Test : QtObject {}
+
+ property alias myalias: other
+ property var direct: Test { id: other }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/frozenQObject2.qml b/tests/auto/qml/qqmlecmascript/data/frozenQObject2.qml
new file mode 100644
index 0000000000..ebff0cde8b
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/frozenQObject2.qml
@@ -0,0 +1,19 @@
+import QtQml
+import test
+
+FrozenObjects {
+ id: app;
+
+ property bool caughtSignal: false
+ onFooMember2Emitted: caughtSignal = true
+
+ Component.onCompleted: {
+ app.fooMember.name = "John";
+ app.fooMemberConst;
+ app.fooMember.name = "Jane";
+
+ app.fooMember2.name = "John";
+ app.triggerSignal();
+ app.fooMember2.name = "Jane";
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/methodTypeMismatch.qml b/tests/auto/qml/qqmlecmascript/data/methodTypeMismatch.qml
new file mode 100644
index 0000000000..fdf5f4ea11
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/methodTypeMismatch.qml
@@ -0,0 +1,25 @@
+import QtQuick 2.0
+
+Item {
+ id: self
+ property font myFont
+ property int notMyFont
+
+ property var object
+
+ function callWithFont() {
+ object.method_gadget(myFont) // should be fine
+ }
+ function callWithInt() {
+ object.method_gadget(123)
+ }
+ function callWithInt2() {
+ object.method_gadget(notMyFont)
+ }
+ function callWithNull() {
+ object.method_gadget(null)
+ }
+ function callWithAllowedNull() {
+ object.method_qobject(null)
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/qmlTypeWrapperArgs.qml b/tests/auto/qml/qqmlecmascript/data/qmlTypeWrapperArgs.qml
new file mode 100644
index 0000000000..7f1b5b0317
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/qmlTypeWrapperArgs.qml
@@ -0,0 +1,8 @@
+import QtQml
+
+QtObject {
+ id: root
+ required property QtObject invokableObject
+
+ Component.onCompleted: root.invokableObject.method_QObject(Component)
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/qmlTypeWrapperArgs2.qml b/tests/auto/qml/qqmlecmascript/data/qmlTypeWrapperArgs2.qml
new file mode 100644
index 0000000000..1904740b26
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/qmlTypeWrapperArgs2.qml
@@ -0,0 +1,9 @@
+import QtQml
+import QtQml as NS
+
+QtObject {
+ id: root
+ required property QtObject invokableObject
+
+ Component.onCompleted: root.invokableObject.method_QObject(NS)
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/qpropertyBindingNoQPropertyCapture.qml b/tests/auto/qml/qqmlecmascript/data/qpropertyBindingNoQPropertyCapture.qml
new file mode 100644
index 0000000000..d3a151efe3
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/qpropertyBindingNoQPropertyCapture.qml
@@ -0,0 +1,19 @@
+import QtQuick
+
+Item {
+ objectName: "redRectangle"
+ id: redRectangle
+
+ property bool b: false
+ function toggle() { b = !b }
+ width: b ? 600 : 500
+
+ Item {
+ id: blueRectangle
+ objectName: "blueRectangle"
+ // width: b ? (100 + redRectangle.width / 2) : 25
+ width: b ? redRectangle.width : 25
+ }
+
+ property int blueRectangleWidth: blueRectangle.width
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/readOnlyBindable.qml b/tests/auto/qml/qqmlecmascript/data/readOnlyBindable.qml
new file mode 100644
index 0000000000..116036c9ff
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/readOnlyBindable.qml
@@ -0,0 +1,7 @@
+import Qt.test
+import QtQuick
+
+ReadOnlyBindable {
+ property int v: 12
+ x: v
+}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp
index cb2dd9373a..40f5e5cf5c 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.cpp
+++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp
@@ -401,7 +401,7 @@ void QObjectContainer::children_append(QQmlListProperty<QObject> *prop, QObject
qsizetype QObjectContainer::children_count(QQmlListProperty<QObject> *prop)
{
- return static_cast<QObjectContainer*>(prop->object)->dataChildren.count();
+ return static_cast<QObjectContainer*>(prop->object)->dataChildren.size();
}
QObject *QObjectContainer::children_at(QQmlListProperty<QObject> *prop, qsizetype index)
@@ -541,6 +541,7 @@ void registerTypes()
qmlRegisterType<Receiver>("Qt.test", 1,0, "Receiver");
qmlRegisterType<Sender>("Qt.test", 1,0, "Sender");
+ qmlRegisterTypesAndRevisions<ReadOnlyBindable>("Qt.test", 1);
}
#include "testtypes.moc"
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
index 9a0ef2cd68..76c1a31e43 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.h
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -938,12 +938,38 @@ public:
Q_INVOKABLE void method_overload2(QString a) { invoke(36); m_actuals << a; }
Q_INVOKABLE void method_overload2() { invoke(37); }
+ Q_PROPERTY(QFont someFont READ someFont WRITE setSomeFont NOTIFY someFontChanged);
+ QFont someFont() { return m_someFont; }
+ void setSomeFont(const QFont &f)
+ {
+ if (f == m_someFont)
+ return;
+ m_someFont = f;
+ emit someFontChanged();
+ }
+ Q_INVOKABLE void method_gadget(QFont f)
+ {
+ invoke(40);
+ m_actuals << f;
+ }
+ Q_INVOKABLE void method_qobject(QObject *o)
+ {
+ invoke(41);
+ m_actuals << QVariant::fromValue(o);
+ }
+
private:
friend class MyInvokableBaseObject;
void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
int m_invoked;
bool m_invokedError;
QVariantList m_actuals;
+
+ QFont m_someFont;
+
+public:
+Q_SIGNALS:
+ void someFontChanged();
};
MyInvokableBaseObject::~MyInvokableBaseObject() {}
@@ -1952,6 +1978,25 @@ public slots:
int slot1(int i, int j, int k) {return i+j+k;}
};
+class ReadOnlyBindable : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(int x READ x WRITE setX BINDABLE bindableX)
+ Q_OBJECT_BINDABLE_PROPERTY(ReadOnlyBindable, int, _xProp)
+
+public:
+ ReadOnlyBindable(QObject *parent = nullptr)
+ : QObject(parent)
+ {
+ setX(7);
+ }
+
+ int x() const { return _xProp.value(); }
+ void setX(int x) { _xProp.setValue(x); }
+ QBindable<int> bindableX() const { return &_xProp; }
+};
+
void registerTypes();
#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 87995b0aca..7f48c244d8 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -96,6 +96,7 @@ private slots:
void outerBindingOverridesInnerBinding();
void aliasPropertyAndBinding();
void aliasPropertyReset();
+ void aliasPropertyToIC();
void nonExistentAttachedObject();
void scope();
void importScope();
@@ -292,6 +293,7 @@ private slots:
void bindingBoundFunctions();
void qpropertyAndQtBinding();
void qpropertyBindingReplacement();
+ void qpropertyBindingNoQPropertyCapture();
void deleteRootObjectInCreation();
void onDestruction();
void onDestructionViaGC();
@@ -386,6 +388,7 @@ private slots:
void urlConstruction();
void urlPropertyInvalid();
void urlPropertySet();
+ void colonAfterProtocol();
void urlSearchParamsConstruction();
void urlSearchParamsMethods();
void variantConversionMethod();
@@ -408,6 +411,9 @@ private slots:
void functionAsDefaultArgument();
void internalClassParentGc();
+ void methodTypeMismatch();
+
+ void doNotCrashOnReadOnlyBindable();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -1911,6 +1917,24 @@ void tst_qqmlecmascript::aliasPropertyReset()
QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
}
+void tst_qqmlecmascript::aliasPropertyToIC()
+{
+ QQmlEngine engine;
+ std::unique_ptr<QObject> root;
+
+ // test that a manual write (of undefined) to a resettable aliased property succeeds
+ QQmlComponent c(&engine, testFileUrl("aliasPropertyToIC.qml"));
+ root.reset(c.create());
+ QVERIFY(root);
+ auto mo = root->metaObject();
+ int aliasIndex = mo->indexOfProperty("myalias");
+ auto prop = mo->property(aliasIndex);
+ QVERIFY(prop.isAlias());
+ auto fromAlias = prop.read(root.get()).value<QObject *>();
+ auto direct = root->property("direct").value<QObject *>();
+ QCOMPARE(fromAlias, direct);
+}
+
void tst_qqmlecmascript::componentCreation_data()
{
QTest::addColumn<QString>("method");
@@ -2269,9 +2293,9 @@ void tst_qqmlecmascript::scriptErrors()
QQmlComponent component(&engine, testFileUrl("scriptErrors.qml"));
QString url = component.url().toString();
- QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
+ QString warning1 = url.left(url.size() - 3) + "js:2: Error: Invalid write to global property \"a\"";
QString warning2 = url + ":5: ReferenceError: a is not defined";
- QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
+ QString warning3 = url.left(url.size() - 3) + "js:4: Error: Invalid write to global property \"a\"";
QString warning4 = url + ":13: ReferenceError: a is not defined";
QString warning5 = url + ":11: ReferenceError: a is not defined";
QString warning6 = url + ":10:5: Unable to assign [undefined] to int";
@@ -2833,26 +2857,26 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_ERROR("object.method_nonexistent()"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_ERROR("object.method_nonexistent(10, 11)"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
// Insufficient arguments
o->reset();
QVERIFY(EVALUATE_ERROR("object.method_int()"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_ERROR("object.method_intint(10)"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
// Excessive arguments
QTest::ignoreMessage(QtWarningMsg, qPrintable("Too many arguments, ignoring 1"));
@@ -2861,7 +2885,7 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_int(10, 11)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 8);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(10));
QTest::ignoreMessage(QtWarningMsg, qPrintable("Too many arguments, ignoring 1"));
@@ -2870,7 +2894,7 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_intint(10, 11, 12)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 9);
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(10));
QCOMPARE(o->actuals().at(1), QVariant(11));
@@ -2879,19 +2903,19 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_NoArgs()", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 0);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_NoArgs_int()", QV4::Primitive::fromInt32(6)));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_NoArgs_real()", QV4::Primitive::fromDouble(19.75)));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 2);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
{
@@ -2900,7 +2924,7 @@ void tst_qqmlecmascript::callQtInvokables()
QCOMPARE(scope.engine->toVariant(ret, QMetaType {}), QVariant(QPointF(123, 4.5)));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 3);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
}
o->reset();
@@ -2910,14 +2934,14 @@ void tst_qqmlecmascript::callQtInvokables()
QCOMPARE(qobjectWrapper->object(), (QObject *)o);
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 4);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
}
o->reset();
QVERIFY(EVALUATE_ERROR("object.method_NoArgs_unknown()"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
{
@@ -2926,63 +2950,63 @@ void tst_qqmlecmascript::callQtInvokables()
QCOMPARE(ret->toQStringNoThrow(), QString("Hello world"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 6);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
}
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_NoArgs_QVariant()", QV4::ScopedValue(scope, scope.engine->newString("QML rocks"))));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 7);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
// Test arg types
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_int(94)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 8);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(94));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_int(\"94\")", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 8);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(94));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_int(\"not a number\")", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 8);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(0));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_int(null)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 8);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(0));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_int(undefined)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 8);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(0));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_int(object)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 8);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(0));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_intint(122, 9)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 9);
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(122));
QCOMPARE(o->actuals().at(1), QVariant(9));
@@ -2990,56 +3014,56 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_real(94.3)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 10);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(94.3));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_real(\"94.3\")", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 10);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(94.3));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_real(\"not a number\")", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 10);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QVERIFY(qIsNaN(o->actuals().at(0).toDouble()));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_real(null)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 10);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(0));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_real(undefined)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 10);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QVERIFY(qIsNaN(o->actuals().at(0).toDouble()));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_real(object)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 10);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QVERIFY(qIsNaN(o->actuals().at(0).toDouble()));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QString(\"Hello world\")", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 11);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant("Hello world"));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QString(19)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 11);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant("19"));
o->reset();
@@ -3048,7 +3072,7 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_QString(object)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 11);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(expected));
}
@@ -3056,120 +3080,140 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_QString(null)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 11);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(QString()));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QString(undefined)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 11);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(QString()));
o->reset();
QVERIFY(EVALUATE_ERROR("object.method_QPointF(0)"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_ERROR("object.method_QPointF(null)"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_ERROR("object.method_QPointF(undefined)"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_ERROR("object.method_QPointF(object)"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPointF())", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 12);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(QPointF(99.3, -10.2)));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPoint())", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 12);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(QPointF(9, 12)));
o->reset();
QVERIFY(EVALUATE_ERROR("object.method_QObject(0)"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_ERROR("object.method_QObject(\"Hello world\")"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QObject(null)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 13);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant::fromValue((QObject *)nullptr));
+ {
+ o->reset();
+ QQmlComponent comp(&qmlengine, testFileUrl("qmlTypeWrapperArgs.qml"));
+ QScopedPointer<QObject> root {comp.createWithInitialProperties({{"invokableObject", QVariant::fromValue(o)}}) };
+ QVERIFY(root);
+ QCOMPARE(o->error(), false);
+ QCOMPARE(o->invoked(), 13);
+ QCOMPARE(o->actuals().size(), 1);
+ QCOMPARE(o->actuals().at(0).value<QObject *>()->metaObject()->className(), "QQmlComponentAttached");
+ }
+
+ {
+ o->reset();
+ QQmlComponent comp(&qmlengine, testFileUrl("qmlTypeWrapperArgs2.qml"));
+ QScopedPointer<QObject> root {comp.createWithInitialProperties({{"invokableObject", QVariant::fromValue(o)}}) };
+ QVERIFY(root);
+ QCOMPARE(o->error(), false);
+ QCOMPARE(o->invoked(), -1); // no function got called due to incompatible arguments
+ }
+
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QObject(undefined)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 13);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant::fromValue((QObject *)nullptr));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QObject(object)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 13);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant::fromValue((QObject *)o));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(null)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 14);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(0)).isNull());
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(undefined)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 14);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(0)).isUndefined());
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(19)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 14);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(0)).strictlyEquals(QJSValue(19)));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QScriptValue([19, 20])", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 14);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(0)).isArray());
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(4, null)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 15);
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(4));
QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(1)).isNull());
@@ -3177,7 +3221,7 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(8, undefined)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 15);
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(8));
QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(1)).isUndefined());
@@ -3185,7 +3229,7 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(3, 19)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 15);
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(3));
QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(1)).strictlyEquals(QJSValue(19)));
@@ -3193,7 +3237,7 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(44, [19, 20])", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 15);
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(44));
QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(1)).isArray());
@@ -3201,20 +3245,20 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_ERROR("object.method_overload()"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_overload(10)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 16);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(10));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_overload(10, 11)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 17);
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(10));
QCOMPARE(o->actuals().at(1), QVariant(11));
@@ -3222,21 +3266,21 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_overload(\"Hello\")", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 18);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(QString("Hello")));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_with_enum(9)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 19);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(9));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_default(10)", QV4::Primitive::fromInt32(19)));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 20);
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(10));
QCOMPARE(o->actuals().at(1), QVariant(19));
@@ -3244,7 +3288,7 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_default(10, 13)", QV4::Primitive::fromInt32(13)));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 20);
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(10));
QCOMPARE(o->actuals().at(1), QVariant(13));
@@ -3252,14 +3296,14 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_inherited(9)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -3);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(o->actuals().at(0), QVariant(9));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QVariant(9)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 21);
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(9));
QCOMPARE(o->actuals().at(1), QVariant());
@@ -3267,7 +3311,7 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_QVariant(\"Hello\", \"World\")", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 21);
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(QString("Hello")));
QCOMPARE(o->actuals().at(1), QVariant(QString("World")));
@@ -3275,104 +3319,104 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_QJsonObject({foo:123})", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 22);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonObject>(o->actuals().at(0)), QJsonDocument::fromJson("{\"foo\":123}").object());
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QJsonArray([123])", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 23);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonArray>(o->actuals().at(0)), QJsonDocument::fromJson("[123]").array());
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(123)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 24);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(123));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(42.35)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 24);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(42.35));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QJsonValue('ciao')", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 24);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(QStringLiteral("ciao")));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(true)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 24);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(true));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(false)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 24);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(false));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(null)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 24);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(QJsonValue::Null));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(undefined)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 24);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(QJsonValue::Undefined));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_overload({foo:123})", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 25);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonObject>(o->actuals().at(0)), QJsonDocument::fromJson("{\"foo\":123}").object());
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_overload([123])", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 26);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonArray>(o->actuals().at(0)), QJsonDocument::fromJson("[123]").array());
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_overload(null)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 27);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(QJsonValue::Null));
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_overload(undefined)", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 27);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(QJsonValue::Undefined));
o->reset();
QVERIFY(EVALUATE_ERROR("object.method_unknown(null)"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), -1);
- QCOMPARE(o->actuals().count(), 0);
+ QCOMPARE(o->actuals().size(), 0);
o->reset();
QVERIFY(EVALUATE_VALUE("object.method_QByteArray(\"Hello\")", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 29);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QByteArray>(o->actuals().at(0)), QByteArray("Hello"));
o->reset();
@@ -3381,7 +3425,7 @@ void tst_qqmlecmascript::callQtInvokables()
QCOMPARE(o->invoked(), 30);
QVERIFY(ret->isString());
QCOMPARE(ret->toQStringNoThrow(), QString("Hello world!"));
- QCOMPARE(o->actuals().count(), 2);
+ QCOMPARE(o->actuals().size(), 2);
QCOMPARE(o->actuals().at(0), QVariant(123));
QJSValue callback = qvariant_cast<QJSValue>(o->actuals().at(1));
QVERIFY(!callback.isNull());
@@ -3391,7 +3435,7 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_overload2('foo', 12, [1, 2, 3])", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 31);
- QCOMPARE(o->actuals().count(), 3);
+ QCOMPARE(o->actuals().size(), 3);
QCOMPARE(qvariant_cast<QString>(o->actuals().at(0)), QStringLiteral("foo"));
QCOMPARE(qvariant_cast<int>(o->actuals().at(1)), 12);
QCOMPARE(qvariant_cast<QVariantList>(o->actuals().at(2)), (QVariantList {1.0, 2.0, 3.0}));
@@ -3400,7 +3444,7 @@ void tst_qqmlecmascript::callQtInvokables()
QVERIFY(EVALUATE_VALUE("object.method_overload2(11, 12, {a: 1, b: 2})", QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 31);
- QCOMPARE(o->actuals().count(), 3);
+ QCOMPARE(o->actuals().size(), 3);
QCOMPARE(qvariant_cast<int>(o->actuals().at(0)), 11);
QCOMPARE(qvariant_cast<int>(o->actuals().at(1)), 12);
QCOMPARE(qvariant_cast<QVariantMap>(o->actuals().at(2)),
@@ -3411,7 +3455,7 @@ void tst_qqmlecmascript::callQtInvokables()
QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 32);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QVariantList>(o->actuals().at(0)),
(QVariantList {1.0, QStringLiteral("bar"), 0.2}));
@@ -3420,13 +3464,26 @@ void tst_qqmlecmascript::callQtInvokables()
QV4::Primitive::undefinedValue()));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 33);
- QCOMPARE(o->actuals().count(), 1);
+ QCOMPARE(o->actuals().size(), 1);
QCOMPARE(qvariant_cast<QVariantMap>(o->actuals().at(0)),
(QVariantMap {
{QStringLiteral("one"), 1.0},
{QStringLiteral("two"), QStringLiteral("bar")},
{QStringLiteral("three"), 0.2}
}));
+
+ o->reset();
+ QVERIFY(EVALUATE_VALUE("object.method_gadget(object.someFont)",
+ QV4::Primitive::undefinedValue()));
+ QCOMPARE(o->error(), false);
+ QCOMPARE(o->invoked(), 40);
+ QCOMPARE(o->actuals(), QVariantList() << QVariant(o->someFont()));
+
+ o->reset();
+ QVERIFY(EVALUATE_ERROR("object.method_gadget(123)"));
+ QCOMPARE(o->error(), false);
+ QCOMPARE(o->invoked(), -1);
+ QCOMPARE(o->actuals(), QVariantList());
}
void tst_qqmlecmascript::resolveClashingProperties()
@@ -4428,7 +4485,7 @@ void tst_qqmlecmascript::singletonType()
if (!errorMessage.isEmpty())
QTest::ignoreMessage(QtWarningMsg, errorMessage.toLatin1().constData());
- for (const QString &warning : qAsConst(warningMessages))
+ for (const QString &warning : std::as_const(warningMessages))
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
QScopedPointer<QObject> object(component.create());
@@ -4785,7 +4842,7 @@ void tst_qqmlecmascript::importScripts()
QTest::ignoreMessage(QtWarningMsg, errorMessage.toLatin1().constData());
if (compilationShouldSucceed) {
- for (const QString &warning : qAsConst(warningMessages))
+ for (const QString &warning : std::as_const(warningMessages))
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
}
@@ -4794,7 +4851,7 @@ void tst_qqmlecmascript::importScripts()
else {
QVERIFY(component.isError());
QCOMPARE(warningMessages.size(), 1);
- QCOMPARE(component.errors().count(), 2);
+ QCOMPARE(component.errors().size(), 2);
QCOMPARE(component.errors().at(1).toString(), warningMessages.first());
return;
}
@@ -5809,22 +5866,22 @@ void tst_qqmlecmascript::sequenceConversionRead()
QMetaObject::invokeMethod(object.data(), "readSequences");
QList<int> intList; intList << 1 << 2 << 3 << 4;
- QCOMPARE(object->property("intListLength").toInt(), intList.length());
+ QCOMPARE(object->property("intListLength").toInt(), intList.size());
QCOMPARE(object->property("intList").value<QList<int> >(), intList);
QList<qreal> qrealList; qrealList << 1.1 << 2.2 << 3.3 << 4.4;
- QCOMPARE(object->property("qrealListLength").toInt(), qrealList.length());
+ QCOMPARE(object->property("qrealListLength").toInt(), qrealList.size());
QCOMPARE(object->property("qrealList").value<QList<qreal> >(), qrealList);
QList<bool> boolList; boolList << true << false << true << false;
- QCOMPARE(object->property("boolListLength").toInt(), boolList.length());
+ QCOMPARE(object->property("boolListLength").toInt(), boolList.size());
QCOMPARE(object->property("boolList").value<QList<bool> >(), boolList);
QList<QString> stringList; stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
- QCOMPARE(object->property("stringListLength").toInt(), stringList.length());
+ QCOMPARE(object->property("stringListLength").toInt(), stringList.size());
QCOMPARE(object->property("stringList").value<QList<QString> >(), stringList);
QList<QUrl> urlList; urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com");
- QCOMPARE(object->property("urlListLength").toInt(), urlList.length());
+ QCOMPARE(object->property("urlListLength").toInt(), urlList.size());
QCOMPARE(object->property("urlList").value<QList<QUrl> >(), urlList);
QStringList qstringList; qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
- QCOMPARE(object->property("qstringListLength").toInt(), qstringList.length());
+ QCOMPARE(object->property("qstringListLength").toInt(), qstringList.size());
QCOMPARE(object->property("qstringList").value<QStringList>(), qstringList);
QMetaObject::invokeMethod(object.data(), "readSequenceElements");
@@ -7300,7 +7357,7 @@ void tst_qqmlecmascript::nonNotifyable()
QLatin1String(object->metaObject()->className()) +
QLatin1String("::value");
- QCOMPARE(messageHandler.messages().length(), 2);
+ QCOMPARE(messageHandler.messages().size(), 2);
QCOMPARE(messageHandler.messages().at(0), expected1);
QCOMPARE(messageHandler.messages().at(1), expected2);
}
@@ -7358,7 +7415,7 @@ void tst_qqmlecmascript::qtbug_22679()
QScopedPointer<QObject> o(component.create());
QVERIFY2(o, qPrintable(component.errorString()));
- QCOMPARE(warningsSpy.count(), 0);
+ QCOMPARE(warningsSpy.size(), 0);
}
void tst_qqmlecmascript::qtbug_22843_data()
@@ -7382,7 +7439,7 @@ void tst_qqmlecmascript::qtbug_22843()
QQmlComponent component(&engine, testFileUrl(fileName));
QString url = component.url().toString();
- QString expectedError = url.left(url.length()-3) + QLatin1String("js:4:16: Expected token `;'");
+ QString expectedError = url.left(url.size()-3) + QLatin1String("js:4:16: Expected token `;'");
QVERIFY(component.isError());
QCOMPARE(component.errors().value(1).toString(), expectedError);
@@ -7722,6 +7779,28 @@ void tst_qqmlecmascript::qpropertyBindingReplacement()
QCOMPARE(root->objectName(), u"overwritten"_s);
}
+void tst_qqmlecmascript::qpropertyBindingNoQPropertyCapture()
+{
+
+ QQmlEngine engine;
+ QQmlComponent comp(&engine, testFileUrl("qpropertyBindingNoQPropertyCapture.qml"));
+ std::unique_ptr<QObject> root(comp.create());
+ QVERIFY2(root, qPrintable(comp.errorString()));
+ auto redRectangle = root.get();
+
+ QQmlProperty blueRectangleWidth(redRectangle, "blueRectangleWidth", &engine);
+
+ auto toggle = [&](){
+ QMetaObject::invokeMethod(root.get(), "toggle");
+ };
+
+ QCOMPARE(blueRectangleWidth.read().toInt(), 25);
+ toggle();
+ QCOMPARE(blueRectangleWidth.read().toInt(), 600);
+ toggle();
+ QCOMPARE(blueRectangleWidth.read().toInt(), 25);
+}
+
void tst_qqmlecmascript::deleteRootObjectInCreation()
{
QQmlEngine engine;
@@ -8190,8 +8269,8 @@ void tst_qqmlecmascript::jsOwnedObjectsDeletedOnEngineDestroy()
QSignalSpy spy1(object1, SIGNAL(destroyed()));
QSignalSpy spy2(object2, SIGNAL(destroyed()));
myEngine.reset();
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy1.size(), 1);
+ QCOMPARE(spy2.size(), 1);
deleteObject.deleteNestedObject();
}
@@ -8506,14 +8585,14 @@ void tst_qqmlecmascript::garbageCollectionDuringCreation()
QVERIFY2(object, qPrintable(component.errorString()));
QObjectContainer *container = qobject_cast<QObjectContainer*>(object.data());
- QCOMPARE(container->dataChildren.count(), 1);
+ QCOMPARE(container->dataChildren.size(), 1);
QObject *child = container->dataChildren.first();
QQmlData *ddata = QQmlData::get(child);
QVERIFY(!ddata->jsWrapper.isNullOrUndefined());
gc(engine);
- QCOMPARE(container->dataChildren.count(), 0);
+ QCOMPARE(container->dataChildren.size(), 0);
}
void tst_qqmlecmascript::qtbug_39520()
@@ -9546,7 +9625,7 @@ void tst_qqmlecmascript::urlConstruction()
QV4::UrlObject *validUrl = ret->as<QV4::UrlObject>();
QVERIFY(validUrl != nullptr);
- QCOMPARE(validUrl->protocol(), "https");
+ QCOMPARE(validUrl->protocol(), "https:");
QCOMPARE(validUrl->hostname(), "example.com");
QCOMPARE(validUrl->username(), "username");
QCOMPARE(validUrl->password(), "password");
@@ -9566,7 +9645,7 @@ void tst_qqmlecmascript::urlConstruction()
QV4::UrlObject *validRelativeUrl = retRel->as<QV4::UrlObject>();
QVERIFY(validRelativeUrl != nullptr);
- QCOMPARE(validRelativeUrl->protocol(), "https");
+ QCOMPARE(validRelativeUrl->protocol(), "https:");
QCOMPARE(validRelativeUrl->hostname(), "example.com");
QCOMPARE(validRelativeUrl->username(), "username");
QCOMPARE(validRelativeUrl->password(), "password");
@@ -9626,7 +9705,7 @@ void tst_qqmlecmascript::urlPropertySet()
// protocol
QVERIFY(EVALUATE("this.url.protocol = 'https';"));
- QCOMPARE(url->protocol(), "https");
+ QCOMPARE(url->protocol(), "https:");
QCOMPARE(url->href(), "https://localhost/a/b/c");
QCOMPARE(url->origin(), "https://localhost");
@@ -9689,7 +9768,7 @@ void tst_qqmlecmascript::urlPropertySet()
"this.url.href = "
"'https://username:password@example.com:1234/path/to/something?search=value#hash';"));
- QCOMPARE(url->protocol(), "https");
+ QCOMPARE(url->protocol(), "https:");
QCOMPARE(url->hostname(), "example.com");
QCOMPARE(url->username(), "username");
QCOMPARE(url->password(), "password");
@@ -9703,6 +9782,57 @@ void tst_qqmlecmascript::urlPropertySet()
QCOMPARE(url->hash(), "#hash");
}
+void tst_qqmlecmascript::colonAfterProtocol()
+{
+ QQmlEngine qmlengine;
+
+ QObject *o = new QObject(&qmlengine);
+
+ QV4::ExecutionEngine *engine = qmlengine.handle();
+ QV4::Scope scope(engine);
+
+ QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(engine, o));
+
+ QV4::ScopedValue ret(scope, EVALUATE("this.url = new URL('http://localhost/a/b/c');"));
+ QV4::UrlObject *url = ret->as<QV4::UrlObject>();
+ QVERIFY(url != nullptr);
+
+ // https without colon
+ QVERIFY(EVALUATE("this.url.protocol = 'https';"));
+ QCOMPARE(url->protocol(), "https:");
+ QCOMPARE(url->href(), "https://localhost/a/b/c");
+ QCOMPARE(url->origin(), "https://localhost");
+
+ QV4::ScopedValue retHttps(scope, EVALUATE("this.url = new URL('https://localhost/a/b/c');"));
+ QV4::UrlObject *urlHttps = retHttps->as<QV4::UrlObject>();
+ QVERIFY(urlHttps != nullptr);
+
+ // ftp with a colon
+ QVERIFY(EVALUATE("this.url.protocol = 'ftp:';"));
+ QCOMPARE(urlHttps->protocol(), "ftp:");
+ QCOMPARE(urlHttps->href(), "ftp://localhost/a/b/c");
+ QCOMPARE(urlHttps->origin(), "ftp://localhost");
+
+ QV4::ScopedValue retHttp(scope, EVALUATE("this.url = new URL('http://localhost/a/b/c');"));
+ QV4::UrlObject *ftpHttps = retHttp->as<QV4::UrlObject>();
+ QVERIFY(ftpHttps != nullptr);
+
+ // ftp with three colons
+ QVERIFY(EVALUATE("this.url.protocol = 'ftp:::';"));
+ QCOMPARE(ftpHttps->protocol(), "ftp:");
+ QCOMPARE(ftpHttps->href(), "ftp://localhost/a/b/c");
+ QCOMPARE(ftpHttps->origin(), "ftp://localhost");
+
+ QV4::ScopedValue retWss(scope, EVALUATE("this.url = new URL('wss://localhost/a/b/c');"));
+ QV4::UrlObject *urlFtpHttp = retWss->as<QV4::UrlObject>();
+ QVERIFY(urlFtpHttp != nullptr);
+
+ // ftp and http with a colon inbetween
+ QVERIFY(EVALUATE("this.url.protocol = 'ftp:http:';"));
+ QCOMPARE(urlFtpHttp->protocol(), "ftp:");
+ QCOMPARE(urlFtpHttp->href(), "ftp://localhost/a/b/c");
+ QCOMPARE(urlFtpHttp->origin(), "ftp://localhost");
+}
void tst_qqmlecmascript::urlSearchParamsConstruction()
{
@@ -9836,14 +9966,65 @@ void tst_qqmlecmascript::cmpInThrows()
QCOMPARE(stacktrace.at(0), QStringLiteral("%entry:14:-1:file:foo.js"));
}
+class FrozenFoo : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name MEMBER m_name NOTIFY nameChanged)
+
+public:
+ FrozenFoo(QObject *parent = nullptr) : QObject(parent) {}
+ QString name() const { return m_name; }
+
+signals:
+ void nameChanged();
+
+private:
+ QString m_name{ "Foo" };
+};
+
+class FrozenObjects : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(FrozenFoo *fooMember READ fooMember CONSTANT);
+ Q_PROPERTY(const FrozenFoo *fooMemberConst READ fooMemberConst CONSTANT);
+ Q_PROPERTY(FrozenFoo *fooMember2 READ fooMember2 CONSTANT);
+
+public:
+ FrozenObjects(QObject *parent = nullptr) : QObject(parent) {}
+
+ Q_INVOKABLE void triggerSignal() { emit fooMember2Emitted(&m_fooMember2); }
+
+ FrozenFoo *fooMember() { return &m_fooMember; }
+ FrozenFoo *fooMember2() { return &m_fooMember2; }
+
+signals:
+ void fooMember2Emitted(const FrozenFoo *fooMember2);
+
+private:
+ const FrozenFoo *fooMemberConst() const { return &m_fooMember; }
+
+ FrozenFoo m_fooMember;
+ FrozenFoo m_fooMember2;
+};
+
void tst_qqmlecmascript::frozenQObject()
{
+ qmlRegisterType<FrozenObjects>("test", 1, 0, "FrozenObjects");
+
QQmlEngine engine;
- QQmlComponent component(&engine, testFileUrl("frozenQObject.qml"));
- QScopedPointer<QObject> root(component.create());
- QVERIFY2(root, qPrintable(component.errorString()));
- QVERIFY(root->property("caughtException").toBool());
- QVERIFY(root->property("nameCorrect").toBool());
+ QQmlComponent component1(&engine, testFileUrl("frozenQObject.qml"));
+ QScopedPointer<QObject> root1(component1.create());
+ QVERIFY2(root1, qPrintable(component1.errorString()));
+ QVERIFY(root1->property("caughtException").toBool());
+ QVERIFY(root1->property("nameCorrect").toBool());
+
+ QQmlComponent component2(&engine, testFileUrl("frozenQObject2.qml"));
+ QScopedPointer<QObject> root2(component2.create());
+ FrozenObjects *frozenObjects = qobject_cast<FrozenObjects *>(root2.data());
+ QVERIFY2(frozenObjects, qPrintable(component2.errorString()));
+ QVERIFY(frozenObjects->property("caughtSignal").toBool());
+ QCOMPARE(frozenObjects->fooMember()->name(), QStringLiteral("Jane"));
+ QCOMPARE(frozenObjects->fooMember2()->name(), QStringLiteral("Jane"));
}
struct ConstPointer : QObject
@@ -10080,6 +10261,85 @@ void tst_qqmlecmascript::internalClassParentGc()
QCOMPARE(root->objectName(), "3");
}
+void tst_qqmlecmascript::methodTypeMismatch()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("methodTypeMismatch.qml"));
+
+ QScopedPointer<MyInvokableObject> object(new MyInvokableObject());
+
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY2(o, qPrintable(component.errorString()));
+ o->setProperty("object", QVariant::fromValue(object.get()));
+
+ auto mo = o->metaObject();
+ QVERIFY(mo);
+
+ auto method = mo->method(mo->indexOfMethod("callWithFont()"));
+ QVERIFY(method.isValid());
+ QVERIFY(method.invoke(o.get()));
+ QCOMPARE(object->actuals(), QVariantList() << QVariant(object->someFont()));
+
+ QRegularExpression argumentConversionErrorMatcher("Could not convert argument 0");
+ QRegularExpression argumentConversionErrorMatcher2(".*/methodTypeMismatch.qml");
+ QRegularExpression typeErrorMatcher(
+ ".*/methodTypeMismatch\\.qml:..: TypeError: Passing incompatible arguments to C\\+\\+ "
+ "functions from JavaScript is not allowed.");
+
+ QTest::ignoreMessage(QtWarningMsg, argumentConversionErrorMatcher);
+ QTest::ignoreMessage(QtWarningMsg, argumentConversionErrorMatcher2);
+ QTest::ignoreMessage(QtWarningMsg, typeErrorMatcher);
+ object->reset();
+ method = mo->method(mo->indexOfMethod("callWithInt()"));
+ QVERIFY(method.isValid());
+ QVERIFY(method.invoke(o.get()));
+ QCOMPARE(object->actuals().size(),
+ 0); // actuals() should not contain reinterpret_cast<QFont>(123) !!!
+
+ QTest::ignoreMessage(QtWarningMsg, argumentConversionErrorMatcher);
+ QTest::ignoreMessage(QtWarningMsg, argumentConversionErrorMatcher2);
+ QTest::ignoreMessage(QtWarningMsg, typeErrorMatcher);
+ object->reset();
+ method = mo->method(mo->indexOfMethod("callWithInt2()"));
+ QVERIFY(method.isValid());
+ QVERIFY(method.invoke(o.get()));
+ QCOMPARE(object->actuals().size(),
+ 0); // actuals() should not contain reinterpret_cast<QFont>(0) !!!
+
+ QTest::ignoreMessage(QtWarningMsg, argumentConversionErrorMatcher);
+ QTest::ignoreMessage(QtWarningMsg, argumentConversionErrorMatcher2);
+ QTest::ignoreMessage(QtWarningMsg, typeErrorMatcher);
+ object->reset();
+ method = mo->method(mo->indexOfMethod("callWithNull()"));
+ QVERIFY(method.isValid());
+ QVERIFY(method.invoke(o.get()));
+ QCOMPARE(object->actuals().size(),
+ 0); // actuals() should not contain reinterpret_cast<QFont>(nullptr) !!!
+
+ // make sure that null is still accepted by functions accepting, e.g., a QObject*!
+ object->reset();
+ method = mo->method(mo->indexOfMethod("callWithAllowedNull()"));
+ QVERIFY(method.isValid());
+ QVERIFY(method.invoke(o.get()));
+ QCOMPARE(object->actuals(), QVariantList() << QVariant::fromValue((QObject *)nullptr));
+}
+
+void tst_qqmlecmascript::doNotCrashOnReadOnlyBindable()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("readOnlyBindable.qml"));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+#ifndef QT_NO_DEBUG
+ QTest::ignoreMessage(
+ QtWarningMsg,
+ "setBinding: Could not set binding via bindable interface. "
+ "The QBindable is read-only.");
+#endif
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(o);
+ QCOMPARE(o->property("x").toInt(), 7);
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"
diff --git a/tests/auto/qml/qqmlfile/tst_qqmlfile.cpp b/tests/auto/qml/qqmlfile/tst_qqmlfile.cpp
index e9de34f657..3f75a14bf6 100644
--- a/tests/auto/qml/qqmlfile/tst_qqmlfile.cpp
+++ b/tests/auto/qml/qqmlfile/tst_qqmlfile.cpp
@@ -118,6 +118,27 @@ void tst_qqmlfile::urlData()
QTest::addRow("file:content 1 slash") << QStringLiteral("file:content:/foo/bar") << true << QStringLiteral("content:/foo/bar");
QTest::addRow("file:content 2 slashes") << QStringLiteral("file:content://foo/bar") << true << QStringLiteral("content://foo/bar");
QTest::addRow("file:content 3 slashes") << QStringLiteral("file:content:///foo/bar") << true << QStringLiteral("content:///foo/bar");
+
+ const QString contentExternalstoragePath = hasAssetsAndContent ?
+ QStringLiteral("content://com.android.externalstorage.documents/foo") : invalid;
+ const QString contentDownloadsPath = hasAssetsAndContent ?
+ QStringLiteral("content://com.android.providers.downloads.documents/foo") : invalid;
+ const QString contentMediaPath = hasAssetsAndContent ?
+ QStringLiteral("content://com.android.providers.media.documents") : invalid;
+
+ QTest::addRow("content externalstorage") << QStringLiteral("content://com.android.externalstorage.documents/foo")
+ << hasAssetsAndContent << contentExternalstoragePath;
+ QTest::addRow("content downloads documents") << QStringLiteral("content://com.android.providers.downloads.documents/foo")
+ << hasAssetsAndContent << contentDownloadsPath;
+ QTest::addRow("content media documents") << QStringLiteral("content://com.android.providers.media.documents")
+ << hasAssetsAndContent << contentMediaPath;
+
+ QTest::addRow("assets externalstorage") << QStringLiteral("assets://com.android.externalstorage.documents/foo")
+ << false << invalid;
+ QTest::addRow("assets downloads documents") << QStringLiteral("assets://com.android.providers.downloads.documents/foo")
+ << false << invalid;
+ QTest::addRow("assets media documents") << QStringLiteral("assets://com.android.providers.media.documents")
+ << false << invalid;
}
void tst_qqmlfile::isLocalFile_data()
diff --git a/tests/auto/qml/qqmlfileselector/data/qmldirtest/main.qml b/tests/auto/qml/qqmlfileselector/data/qmldirtest/main.qml
new file mode 100644
index 0000000000..d6dd2c9b90
--- /dev/null
+++ b/tests/auto/qml/qqmlfileselector/data/qmldirtest/main.qml
@@ -0,0 +1,13 @@
+import QtQuick
+import qmldirtest
+
+Window {
+ width: 640
+ height: 480
+ visible: true
+ property color color: mybutton.color
+
+ MyButton {
+ id: mybutton
+ }
+}
diff --git a/tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/+linux/MyButton.qml b/tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/+linux/MyButton.qml
new file mode 100644
index 0000000000..cc6eb967da
--- /dev/null
+++ b/tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/+linux/MyButton.qml
@@ -0,0 +1,7 @@
+import QtQuick
+
+Rectangle {
+ width: 300
+ height: 50
+ color: "blue"
+}
diff --git a/tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/+macos/MyButton.qml b/tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/+macos/MyButton.qml
new file mode 100644
index 0000000000..5bf632c48d
--- /dev/null
+++ b/tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/+macos/MyButton.qml
@@ -0,0 +1,7 @@
+import QtQuick
+
+Rectangle {
+ width: 300
+ height: 50
+ color: "yellow"
+}
diff --git a/tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/MyButton.qml b/tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/MyButton.qml
new file mode 100644
index 0000000000..32db428c4f
--- /dev/null
+++ b/tests/auto/qml/qqmlfileselector/data/qmldirtest/qml/MyButton.qml
@@ -0,0 +1,7 @@
+import QtQuick
+
+Rectangle {
+ width: 300
+ height: 50
+ color: "green"
+}
diff --git a/tests/auto/qml/qqmlfileselector/data/qmldirtest/qmldir b/tests/auto/qml/qqmlfileselector/data/qmldirtest/qmldir
new file mode 100644
index 0000000000..ac68d9097d
--- /dev/null
+++ b/tests/auto/qml/qqmlfileselector/data/qmldirtest/qmldir
@@ -0,0 +1,5 @@
+module qmldirtest
+MyButton 1.0 qml/MyButton.qml
+MyButton 1.0 qml/+linux/MyButton.qml
+MyButton 1.0 qml/+macos/MyButton.qml
+
diff --git a/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp b/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp
index 7dd7a68107..46df20378c 100644
--- a/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp
+++ b/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp
@@ -22,7 +22,7 @@ private slots:
void basicTest();
void basicTestCached();
void applicationEngineTest();
-
+ void qmldirCompatibility();
};
void tst_qqmlfileselector::basicTest()
@@ -70,6 +70,23 @@ void tst_qqmlfileselector::applicationEngineTest()
QCOMPARE(object->property("value").toString(), QString("selected"));
}
+void tst_qqmlfileselector::qmldirCompatibility()
+{
+ QQmlApplicationEngine engine;
+ engine.addImportPath(dataDirectory());
+ engine.load(testFileUrl("qmldirtest/main.qml"));
+ QVERIFY(!engine.rootObjects().isEmpty());
+ QObject *object = engine.rootObjects().at(0);
+ auto color = object->property("color").value<QColor>();
+#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
+ QCOMPARE(color, QColorConstants::Svg::blue);
+#elif defined(Q_OS_DARWIN)
+ QCOMPARE(color, QColorConstants::Svg::yellow);
+#else
+ QCOMPARE(color, QColorConstants::Svg::green);
+#endif
+}
+
QTEST_MAIN(tst_qqmlfileselector)
#include "tst_qqmlfileselector.moc"
diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
index 4460dd7de5..fdf3fffeb6 100644
--- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
+++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
@@ -170,26 +170,26 @@ void tst_QQmlImport::uiFormatLoading()
QSignalSpy objectCreated(test, SIGNAL(objectCreated(QObject*,QUrl)));
test->load(testFileUrl("TestForm.ui.qml"));
- QCOMPARE(objectCreated.count(), size);//one less than rootObjects().size() because we missed the first one
+ QCOMPARE(objectCreated.size(), size);//one less than rootObjects().size() because we missed the first one
QCOMPARE(test->rootObjects().size(), ++size);
QVERIFY(test->rootObjects()[size -1]);
QVERIFY(test->rootObjects()[size -1]->property("success").toBool());
QByteArray testQml("import QtQml 2.0; QtObject{property bool success: true; property TestForm t: TestForm{}}");
test->loadData(testQml, testFileUrl("dynamicTestForm.ui.qml"));
- QCOMPARE(objectCreated.count(), size);
+ QCOMPARE(objectCreated.size(), size);
QCOMPARE(test->rootObjects().size(), ++size);
QVERIFY(test->rootObjects()[size -1]);
QVERIFY(test->rootObjects()[size -1]->property("success").toBool());
test->load(testFileUrl("openTestFormFromDir.qml"));
- QCOMPARE(objectCreated.count(), size);
+ QCOMPARE(objectCreated.size(), size);
QCOMPARE(test->rootObjects().size(), ++size);
QVERIFY(test->rootObjects()[size -1]);
QVERIFY(test->rootObjects()[size -1]->property("success").toBool());
test->load(testFileUrl("openTestFormFromQmlDir.qml"));
- QCOMPARE(objectCreated.count(), size);
+ QCOMPARE(objectCreated.size(), size);
QCOMPARE(test->rootObjects().size(), ++size);
QVERIFY(test->rootObjects()[size -1]);
QVERIFY(test->rootObjects()[size -1]->property("success").toBool());
diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
index e6c8ad721e..1baf61574e 100644
--- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
+++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
@@ -517,7 +517,7 @@ void tst_qqmlincubator::statusChanged()
MyIncubator incubator(QQmlIncubator::Synchronous);
component.create(incubator);
QVERIFY(incubator.isReady());
- QCOMPARE(incubator.statuses.count(), 3);
+ QCOMPARE(incubator.statuses.size(), 3);
QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
QCOMPARE(incubator.statuses.at(1), -1);
QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready));
@@ -531,7 +531,7 @@ void tst_qqmlincubator::statusChanged()
MyIncubator incubator(QQmlIncubator::Asynchronous);
component.create(incubator);
QVERIFY(incubator.isLoading());
- QCOMPARE(incubator.statuses.count(), 1);
+ QCOMPARE(incubator.statuses.size(), 1);
QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
{
@@ -539,7 +539,7 @@ void tst_qqmlincubator::statusChanged()
controller.incubateWhile(&b);
}
- QCOMPARE(incubator.statuses.count(), 3);
+ QCOMPARE(incubator.statuses.size(), 3);
QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
QCOMPARE(incubator.statuses.at(1), -1);
QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready));
@@ -553,7 +553,7 @@ void tst_qqmlincubator::statusChanged()
MyIncubator incubator(QQmlIncubator::Asynchronous);
component2.create(incubator);
QVERIFY(incubator.isLoading());
- QCOMPARE(incubator.statuses.count(), 1);
+ QCOMPARE(incubator.statuses.size(), 1);
QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
{
@@ -562,7 +562,7 @@ void tst_qqmlincubator::statusChanged()
}
QVERIFY(incubator.isReady());
- QCOMPARE(incubator.statuses.count(), 3);
+ QCOMPARE(incubator.statuses.size(), 3);
QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
QCOMPARE(incubator.statuses.at(1), -1);
QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready));
diff --git a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
index 03add4b309..4908ca210b 100644
--- a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
+++ b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
@@ -226,7 +226,7 @@ void tst_qqmlinfo::attachedObject()
QScopedPointer<QObject> object(component.create());
QVERIFY2(object != nullptr, qPrintable(component.errorString()));
- QCOMPARE(warningSpy.count(), 2);
+ QCOMPARE(warningSpy.size(), 2);
// The Attached C++ type has no QML engine since it was created in C++, so we should see its parent instead.
const auto cppWarnings = warningSpy.at(0).first().value<QList<QQmlError>>();
diff --git a/tests/auto/qml/qqmlinstantiator/stringmodel.h b/tests/auto/qml/qqmlinstantiator/stringmodel.h
index 69d617a07f..d9676b9460 100644
--- a/tests/auto/qml/qqmlinstantiator/stringmodel.h
+++ b/tests/auto/qml/qqmlinstantiator/stringmodel.h
@@ -37,7 +37,7 @@ public:
int rowCount(const QModelIndex &) const override
{
- return items.count();
+ return items.size();
}
QHash<int, QByteArray> roleNames() const override
@@ -72,7 +72,7 @@ public:
QVariant data (const QModelIndex & index, int role) const override
{
int row = index.row();
- if ((row<0) || (row>=items.count()))
+ if ((row<0) || (row>=items.size()))
return QVariant(QMetaType(QMetaType::UnknownType));
switch (role) {
diff --git a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp
index aeca3f4046..1097c65f02 100644
--- a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp
+++ b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp
@@ -124,19 +124,19 @@ void tst_qqmlinstantiator::activeProperty()
QCOMPARE(instantiator->count(), 0);
QVERIFY(instantiator->delegate()->isReady());
- QCOMPARE(activeSpy.count(), 0);
- QCOMPARE(countSpy.count(), 0);
- QCOMPARE(objectSpy.count(), 0);
- QCOMPARE(modelSpy.count(), 0);
+ QCOMPARE(activeSpy.size(), 0);
+ QCOMPARE(countSpy.size(), 0);
+ QCOMPARE(objectSpy.size(), 0);
+ QCOMPARE(modelSpy.size(), 0);
instantiator->setActive(true);
QCOMPARE(instantiator->isActive(), true);
QCOMPARE(instantiator->count(), 1);
- QCOMPARE(activeSpy.count(), 1);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(objectSpy.count(), 1);
- QCOMPARE(modelSpy.count(), 0);
+ QCOMPARE(activeSpy.size(), 1);
+ QCOMPARE(countSpy.size(), 1);
+ QCOMPARE(objectSpy.size(), 1);
+ QCOMPARE(modelSpy.size(), 0);
QObject *object = instantiator->object();
QVERIFY(object);
@@ -178,18 +178,18 @@ void tst_qqmlinstantiator::intModelChange()
QSignalSpy modelSpy(instantiator, SIGNAL(modelChanged()));
QCOMPARE(instantiator->count(), 10);
- QCOMPARE(activeSpy.count(), 0);
- QCOMPARE(countSpy.count(), 0);
- QCOMPARE(objectSpy.count(), 0);
- QCOMPARE(modelSpy.count(), 0);
+ QCOMPARE(activeSpy.size(), 0);
+ QCOMPARE(countSpy.size(), 0);
+ QCOMPARE(objectSpy.size(), 0);
+ QCOMPARE(modelSpy.size(), 0);
instantiator->setModel(QVariant(2));
QCOMPARE(instantiator->count(), 2);
- QCOMPARE(activeSpy.count(), 0);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(objectSpy.count(), 2);
- QCOMPARE(modelSpy.count(), 1);
+ QCOMPARE(activeSpy.size(), 0);
+ QCOMPARE(countSpy.size(), 1);
+ QCOMPARE(objectSpy.size(), 2);
+ QCOMPARE(modelSpy.size(), 1);
for (int i=0; i<2; i++) {
QObject *object = instantiator->objectAt(i);
@@ -267,7 +267,7 @@ void tst_qqmlinstantiator::handlerWithParent()
QScopedPointer<QObject> rootObject(component.create());
QVERIFY(rootObject != nullptr);
const auto handlers = rootObject->findChildren<QObject *>("pointHandler");
- QCOMPARE(handlers.count(), 2);
+ QCOMPARE(handlers.size(), 2);
for (const auto *h : handlers) {
QCOMPARE(h->parent(), rootObject.data());
}
diff --git a/tests/auto/qml/qqmlitemmodels/qtestmodel.h b/tests/auto/qml/qqmlitemmodels/qtestmodel.h
index 9839e4c7f9..6cbec533b1 100644
--- a/tests/auto/qml/qqmlitemmodels/qtestmodel.h
+++ b/tests/auto/qml/qqmlitemmodels/qtestmodel.h
@@ -74,7 +74,7 @@ public:
Node *n = (Node*)parent.internalPointer();
if (!n)
n = tree;
- return n->children.count();
+ return n->children.size();
}
int columnCount(const QModelIndex& parent = QModelIndex()) const override {
@@ -97,7 +97,7 @@ public:
Node *pn = (Node*)parent.internalPointer();
if (!pn)
pn = tree;
- if (row >= pn->children.count())
+ if (row >= pn->children.size())
return QModelIndex();
Node *n = pn->children.at(row);
@@ -130,7 +130,7 @@ public:
if (pn != tree)
pn = pn->parent;
if (idx.row() < 0 || idx.column() < 0 || idx.column() >= cols
- || idx.row() >= pn->children.count()) {
+ || idx.row() >= pn->children.size()) {
wrongIndex = true;
qWarning("Invalid modelIndex [%d,%d,%p]", idx.row(), idx.column(),
idx.internalPointer());
@@ -268,15 +268,15 @@ public:
void addRows(int row, int count)
{
if (count > 0) {
- children.reserve(children.count() + count);
+ children.reserve(children.size() + count);
children.insert(row, count, (Node *)0);
}
}
void removeRows(int row, int count, bool keepAlive = false)
{
- int newCount = qMax(children.count() - count, 0);
- int effectiveCountDiff = children.count() - newCount;
+ int newCount = qMax(children.size() - count, 0);
+ int effectiveCountDiff = children.size() - newCount;
if (effectiveCountDiff > 0) {
if (!keepAlive)
for (int i = 0; i < effectiveCountDiff; i++)
diff --git a/tests/auto/qml/qqmlitemmodels/tst_qqmlitemmodels.cpp b/tests/auto/qml/qqmlitemmodels/tst_qqmlitemmodels.cpp
index f046fcd35d..339a61f996 100644
--- a/tests/auto/qml/qqmlitemmodels/tst_qqmlitemmodels.cpp
+++ b/tests/auto/qml/qqmlitemmodels/tst_qqmlitemmodels.cpp
@@ -163,7 +163,7 @@ void tst_qqmlitemmodels::itemSelection()
QCOMPARE(isVariant.userType(), qMetaTypeId<QItemSelection>());
const QItemSelection &sel = isVariant.value<QItemSelection>();
- QCOMPARE(sel.count(), object->itemSelection().count());
+ QCOMPARE(sel.size(), object->itemSelection().size());
QCOMPARE(sel, object->itemSelection());
}
}
@@ -181,7 +181,7 @@ void tst_qqmlitemmodels::modelIndexList()
QCOMPARE(object->property("count").toInt(), 10);
const QModelIndexList &mil = object->modelIndexList();
- QCOMPARE(mil.count(), 4);
+ QCOMPARE(mil.size(), 4);
for (int i = 0; i < 3; i++)
QCOMPARE(mil.at(i), model.index(2 + i, 2 + i));
QCOMPARE(mil.at(3), QModelIndex()); // The string inserted at the end should result in an invalid index
@@ -198,7 +198,7 @@ void tst_qqmlitemmodels::modelIndexList()
QCOMPARE(milVariant.userType(), qMetaTypeId<QModelIndexList>());
const QModelIndexList &milProp = milVariant.value<QModelIndexList>();
- QCOMPARE(milProp.count(), mil.count());
+ QCOMPARE(milProp.size(), mil.size());
QCOMPARE(milProp, mil);
}
}
diff --git a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
index a5efd3147e..9646e8004a 100644
--- a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
+++ b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
@@ -571,7 +571,7 @@ void tst_qqmljsscope::scriptIndices()
queue.push_back(c);
}
- for (const QmlIR::Object *irObject : qAsConst(document.objects)) {
+ for (const QmlIR::Object *irObject : std::as_const(document.objects)) {
const QString objectName = document.stringAt(irObject->inheritedTypeNameIndex);
for (auto it = irObject->functionsBegin(); it != irObject->functionsEnd(); ++it) {
QString name = document.stringAt(it->nameIndex);
diff --git a/tests/auto/qml/qqmllanguage/data/ComponentType.qml b/tests/auto/qml/qqmllanguage/data/ComponentType.qml
new file mode 100644
index 0000000000..e8addde1c4
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/ComponentType.qml
@@ -0,0 +1,8 @@
+import QtQml
+
+Component {
+ id: componentRoot
+ QtObject {
+ objectName: "enclosed"
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/SignalInlineComponentArg.qml b/tests/auto/qml/qqmllanguage/data/SignalInlineComponentArg.qml
new file mode 100644
index 0000000000..0424ac1534
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/SignalInlineComponentArg.qml
@@ -0,0 +1,21 @@
+import QtQuick
+
+Item {
+ component Abc: Item {
+ property string success
+ }
+
+ signal canYouFeelIt(arg1: Abc)
+ property Abc someAbc: Abc {
+ success: "Signal was called"
+ }
+ property string success: "Signal not called yet"
+
+ Component.onCompleted: {
+ canYouFeelIt(someAbc);
+ }
+
+ onCanYouFeelIt: (arg) => {
+ success = arg.success
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/alias.15.qml b/tests/auto/qml/qqmllanguage/data/alias.15.qml
index 5f3de9c83e..7e362d8823 100644
--- a/tests/auto/qml/qqmllanguage/data/alias.15.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.15.qml
@@ -9,4 +9,25 @@ Item {
Item {
id: symbol
}
+
+ Rectangle {
+ id: txtElevationValue
+
+ property Rectangle background: Rectangle { }
+
+ state: "ValidatorInvalid"
+
+ states: [
+ State {
+ name: "ValidatorInvalid"
+ PropertyChanges {
+ target: txtElevationValue
+ background.border.color: "red" // this line caused the segfault in qtbug107795
+ }
+ },
+ State {
+ name: "ValidatorAcceptable"
+ }
+ ]
+ }
}
diff --git a/tests/auto/qml/qqmllanguage/data/badGroupedProperty.qml b/tests/auto/qml/qqmllanguage/data/badGroupedProperty.qml
new file mode 100644
index 0000000000..1b8ba61725
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/badGroupedProperty.qml
@@ -0,0 +1,10 @@
+import QtQml
+
+QtObject {
+ id: testItem
+ property rect rect
+ onComplete {
+ rect.x: 2
+ rect.width: 22
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/bindingAliasToComponentUrl.qml b/tests/auto/qml/qqmllanguage/data/bindingAliasToComponentUrl.qml
new file mode 100644
index 0000000000..44fbd03354
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/bindingAliasToComponentUrl.qml
@@ -0,0 +1,10 @@
+import QtQuick
+Item {
+ id: root
+ Component {
+ id: accessibleNormal
+ Item {}
+ }
+ property alias accessibleNormalUrl: accessibleNormal.url
+ property url urlClone: root.accessibleNormalUrl // crashes qml utility
+}
diff --git a/tests/auto/qml/qqmllanguage/data/bindingAliasToComponentUrl2.qml b/tests/auto/qml/qqmllanguage/data/bindingAliasToComponentUrl2.qml
new file mode 100644
index 0000000000..cfdec5e39b
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/bindingAliasToComponentUrl2.qml
@@ -0,0 +1,11 @@
+import QtQuick
+Item {
+ id: root
+ Component {
+ id: accessibleNormal
+ ComponentType {
+ id: inaccessibleNormal
+ }
+ }
+ property alias accessibleNormalProgress: accessibleNormal.progress
+}
diff --git a/tests/auto/qml/qqmllanguage/data/nullIsNull.qml b/tests/auto/qml/qqmllanguage/data/nullIsNull.qml
new file mode 100644
index 0000000000..a6cbbee0bf
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/nullIsNull.qml
@@ -0,0 +1,28 @@
+import QtQml
+
+QtObject {
+ id: root
+ property alias someProperty: internal.someProperty
+
+ property Timer t: Timer {
+ interval: 1
+ running: true
+ onTriggered: root.someProperty = null
+ }
+
+ property QtObject a: QtObject {
+ id: someObjectInstance
+ }
+
+ property QtObject b: QtObject {
+ id: internal
+ property QtObject someProperty: someObjectInstance ? someObjectInstance : null
+ }
+
+ property Connections c: Connections {
+ target: internal
+ function onSomePropertyChanged() {
+ internal.someProperty = null
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/signalInlineComponentArg1.qml b/tests/auto/qml/qqmllanguage/data/signalInlineComponentArg1.qml
new file mode 100644
index 0000000000..e20710edd9
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/signalInlineComponentArg1.qml
@@ -0,0 +1,30 @@
+import QtQuick
+
+// this file performs two tests: first, using a signal with a inline component from another file
+// and second, calling the signal from another file using an inline component from another file
+
+Item {
+ signal canYouFeelIt(arg1:SignalInlineComponentArg.Abc)
+
+ property SignalInlineComponentArg.Abc someAbc: SignalInlineComponentArg.Abc {
+ success: "Own signal was called with component from another file"
+ }
+
+ property SignalInlineComponentArg fromAnotherFile: SignalInlineComponentArg {}
+
+ // success of own signal call with parameter from another file
+ property string successFromOwnSignal: "Signal not called yet"
+ // makes it easier to test
+ property string successFromSignalFromFile: fromAnotherFile.success
+
+ Component.onCompleted: {
+ canYouFeelIt(someAbc);
+ fromAnotherFile.someAbc.success = "Signal was called from another file"
+ fromAnotherFile.canYouFeelIt(fromAnotherFile.someAbc)
+ }
+
+ onCanYouFeelIt: (arg) => {
+ successFromOwnSignal = arg.success
+ }
+}
+
diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp
index 2b6f8e867e..f4b6acc848 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.cpp
+++ b/tests/auto/qml/qqmllanguage/testtypes.cpp
@@ -189,7 +189,7 @@ void CustomBinding::componentComplete()
void EnumSupportingCustomParser::verifyBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
{
- if (bindings.count() != 1) {
+ if (bindings.size() != 1) {
error(bindings.first(), QStringLiteral("Custom parser invoked incorrectly for unit test"));
return;
}
@@ -221,7 +221,7 @@ void SimpleObjectCustomParser::applyBindings(QObject *object, const QQmlRefPoint
{
SimpleObjectWithCustomParser *o = qobject_cast<SimpleObjectWithCustomParser*>(object);
Q_ASSERT(o);
- o->setCustomBindingsCount(bindings.count());
+ o->setCustomBindingsCount(bindings.size());
}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 59ba9594f9..409c56d504 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -387,8 +387,11 @@ private slots:
void v4SequenceMethodsWithParams_data();
void v4SequenceMethodsWithParams();
void jsFunctionOverridesImport();
-
+ void bindingAliasToComponentUrl();
+ void badGroupedProperty();
void bindableOnly();
+ void signalInlineComponentArg();
+ void nullIsNull();
private:
QQmlEngine engine;
@@ -6143,7 +6146,7 @@ void tst_qqmllanguage::qualifiedScopeInCustomParser()
"ListModel {\n"
" ListElement { text: \"a\"; type: BACKEND.EnumTester.FIRST }\n"
"}\n", QUrl());
- QVERIFY(component.isReady());
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
QScopedPointer<QObject> obj(component.create());
QVERIFY(!obj.isNull());
}
@@ -7367,6 +7370,69 @@ void tst_qqmllanguage::jsFunctionOverridesImport()
QCOMPARE(object->objectName(), u"foo"_s);
}
+void tst_qqmllanguage::bindingAliasToComponentUrl()
+{
+ QQmlEngine engine;
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingAliasToComponentUrl.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object);
+ QCOMPARE(object->property("accessibleNormalUrl"), object->property("urlClone"));
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingAliasToComponentUrl2.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object);
+ QCOMPARE(object->property("accessibleNormalProgress"), QVariant(1.0));
+ }
+}
+
+void tst_qqmllanguage::badGroupedProperty()
+{
+ QQmlEngine engine;
+ const QUrl url = testFileUrl("badGroupedProperty.qml");
+ QQmlComponent c(&engine, url);
+ QVERIFY(c.isError());
+ QCOMPARE(c.errorString(),
+ QStringLiteral("%1:6 Cannot assign to non-existent property \"onComplete\"\n")
+ .arg(url.toString()));
+}
+
+void tst_qqmllanguage::signalInlineComponentArg()
+{
+ QQmlEngine engine;
+ {
+ QQmlComponent component(&engine, testFileUrl("SignalInlineComponentArg.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> object(component.create());
+
+ QCOMPARE(object->property("success"), u"Signal was called"_s);
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("signalInlineComponentArg1.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> object(component.create());
+
+ QCOMPARE(object->property("successFromOwnSignal"),
+ u"Own signal was called with component from another file"_s);
+ QCOMPARE(object->property("successFromSignalFromFile"),
+ u"Signal was called from another file"_s);
+ }
+}
+
+void tst_qqmllanguage::nullIsNull()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("nullIsNull.qml"));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+ QVERIFY(o->property("someProperty").value<QObject*>() != nullptr);
+ QTRY_COMPARE(o->property("someProperty").value<QObject*>(), nullptr);
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"
diff --git a/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp b/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp
index dd9df84867..2d02cac9f8 100644
--- a/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp
+++ b/tests/auto/qml/qqmllistcompositor/tst_qqmllistcompositor.cpp
@@ -1022,7 +1022,7 @@ void tst_qqmllistcompositor::moveFromEnd()
QVector<C::Insert> inserts;
compositor.listItemsInserted(a, 0, 1, &inserts);
- QCOMPARE(inserts.count(), 1);
+ QCOMPARE(inserts.size(), 1);
QCOMPARE(inserts.at(0).index[1], 1);
QCOMPARE(inserts.at(0).count, 1);
diff --git a/tests/auto/qml/qqmllistmodel/data/Model.qml b/tests/auto/qml/qqmllistmodel/data/Model.qml
new file mode 100644
index 0000000000..f6aeed5bdd
--- /dev/null
+++ b/tests/auto/qml/qqmllistmodel/data/Model.qml
@@ -0,0 +1,9 @@
+import QtQml.Models
+
+ListModel {
+ enum Choose { Foo, Bar, Baz }
+
+ ListElement { choose: Model.Choose.Foo }
+ ListElement { choose: Model.Choose.Bar }
+ ListElement { choose: Model.Choose.Baz }
+}
diff --git a/tests/auto/qml/qqmllistmodel/data/enumsInListElement.qml b/tests/auto/qml/qqmllistmodel/data/enumsInListElement.qml
new file mode 100644
index 0000000000..e8d594dfd8
--- /dev/null
+++ b/tests/auto/qml/qqmllistmodel/data/enumsInListElement.qml
@@ -0,0 +1,8 @@
+import QtQuick
+
+ListView {
+ width: 180
+ height: 200
+ model: Model {}
+ delegate: Text { text: choose }
+}
diff --git a/tests/auto/qml/qqmllistmodel/data/protectQObjectFromGC.qml b/tests/auto/qml/qqmllistmodel/data/protectQObjectFromGC.qml
new file mode 100644
index 0000000000..43b375b681
--- /dev/null
+++ b/tests/auto/qml/qqmllistmodel/data/protectQObjectFromGC.qml
@@ -0,0 +1,21 @@
+import QtQml
+import QtQml.Models
+
+ListModel {
+ id: filesModel
+ property Component testComponent: Component {
+ id: testComponent
+ QtObject {
+ required property string name
+ }
+ }
+ Component.onCompleted: {
+ filesModel.clear()
+ for(let i = 0; i < 10; i++) {
+ filesModel.append({
+ path: testComponent.createObject(null, { name: "" + i })
+ })
+ }
+ gc()
+ }
+}
diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
index c92956bd49..e522f280a3 100644
--- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
+++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
@@ -4,6 +4,7 @@
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquicktext_p.h>
#include <QtQuick/private/qquickanimation_p.h>
+#include <QtQuick/private/qquicklistview_p.h>
#include <QtQml/private/qqmlengine_p.h>
#include <QtQmlModels/private/qqmllistmodel_p.h>
#include <QtQml/private/qqmlexpression_p.h>
@@ -116,6 +117,8 @@ private slots:
void listElementWithTemplateString();
void destroyComponentObject();
void objectOwnershipFlip();
+ void enumsInListElement();
+ void protectQObjectFromGC();
};
bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object)
@@ -126,10 +129,10 @@ bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVarian
if (model == nullptr)
return false;
- if (model->count() != testList.count())
+ if (model->count() != testList.size())
return false;
- for (int i=0 ; i < testList.count() ; ++i) {
+ for (int i=0 ; i < testList.size() ; ++i) {
const QVariant &testVariant = testList.at(i);
if (testVariant.typeId() != QMetaType::QVariantMap)
return false;
@@ -595,7 +598,7 @@ void tst_qqmllistmodel::dynamic()
QCOMPARE(actual,result);
if (model.count() > 0)
- QVERIFY(spyCount.count() > 0);
+ QVERIFY(spyCount.size() > 0);
}
void tst_qqmllistmodel::enumerate()
@@ -703,7 +706,7 @@ void tst_qqmllistmodel::error()
} else {
QVERIFY(component.isError());
QList<QQmlError> errors = component.errors();
- QCOMPARE(errors.count(),1);
+ QCOMPARE(errors.size(),1);
QCOMPARE(errors.at(0).description(),error);
}
}
@@ -801,7 +804,7 @@ void tst_qqmllistmodel::get()
QCOMPARE(model->data(index, role), roleValue);
}
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> spyResult = spy.takeFirst();
QCOMPARE(spyResult.at(0).value<QModelIndex>(), model->index(index, 0, QModelIndex()));
@@ -902,7 +905,7 @@ void tst_qqmllistmodel::get_nested()
testData << qMakePair(1, QString("listRoleB"));
testData << qMakePair(1, QString("listRoleC"));
- for (int i=0; i<testData.count(); i++) {
+ for (int i=0; i<testData.size(); i++) {
int outerListIndex = testData[i].first;
QString outerListRoleName = testData[i].second;
int outerListRole = roleFromName(model, outerListRoleName);
@@ -925,7 +928,7 @@ void tst_qqmllistmodel::get_nested()
} else {
QCOMPARE(childModel->data(index, role), roleValue);
}
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> spyResult = spy.takeFirst();
QCOMPARE(spyResult.at(0).value<QModelIndex>(), childModel->index(index, 0, QModelIndex()));
@@ -1095,7 +1098,7 @@ void tst_qqmllistmodel::property_changes()
expr.evaluate();
QVERIFY2(!expr.hasError(), qPrintable(expr.error().toString()));
- QString signalHandler = "on" + QString(roleName[0].toUpper()) + roleName.mid(1, roleName.length()) + "Changed:";
+ QString signalHandler = "on" + QString(roleName[0].toUpper()) + roleName.mid(1, roleName.size()) + "Changed:";
QString qml = "import QtQuick 2.0\n"
"Connections {\n"
"property bool gotSignal: false\n"
@@ -1120,11 +1123,11 @@ void tst_qqmllistmodel::property_changes()
// test itemsChanged() is emitted correctly
if (itemsChanged) {
- QCOMPARE(spyItemsChanged.count(), 1);
+ QCOMPARE(spyItemsChanged.size(), 1);
QCOMPARE(spyItemsChanged.at(0).at(0).value<QModelIndex>(), model.index(listIndex, 0, QModelIndex()));
QCOMPARE(spyItemsChanged.at(0).at(1).value<QModelIndex>(), model.index(listIndex, 0, QModelIndex()));
} else {
- QCOMPARE(spyItemsChanged.count(), 0);
+ QCOMPARE(spyItemsChanged.size(), 0);
}
expr.setExpression(testExpression);
@@ -1641,7 +1644,7 @@ void tst_qqmllistmodel::crash_append_empty_array()
QQmlExpression expr(engine.rootContext(), model, "append(new Array())");
expr.evaluate();
QVERIFY2(!expr.hasError(), qPrintable(expr.error().toString()));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_qqmllistmodel::dynamic_roles_crash_QTBUG_38907()
@@ -1853,7 +1856,7 @@ void tst_qqmllistmodel::destroyComponentObject()
Q_RETURN_ARG(QVariant, retVal));
QVERIFY(retVal.toBool());
QTRY_VERIFY(created.isNull());
- QTRY_VERIFY(list->get(0).property("obj").isUndefined());
+ QTRY_VERIFY(list->get(0).property("obj").isNull());
QCOMPARE(list->count(), 1);
}
@@ -1891,6 +1894,41 @@ void tst_qqmllistmodel::objectOwnershipFlip()
QCOMPARE(QJSEngine::objectOwnership(item.data()), QJSEngine::CppOwnership);
}
+void tst_qqmllistmodel::enumsInListElement()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("enumsInListElement.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY(!root.isNull());
+
+ QQuickListView *listView = qobject_cast<QQuickListView *>(root.data());
+ QVERIFY(listView);
+ QCOMPARE(listView->count(), 3);
+ for (int i = 0; i < 3; ++i) {
+ QCOMPARE(listView->itemAtIndex(i)->property("text"), QVariant(QString::number(i)));
+ }
+}
+
+void tst_qqmllistmodel::protectQObjectFromGC()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("protectQObjectFromGC.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY(!root.isNull());
+
+ QQmlListModel *listModel = qobject_cast<QQmlListModel *>(root.data());
+ QVERIFY(listModel);
+ QCOMPARE(listModel->count(), 10);
+
+ for (int i = 0; i < 10; ++i) {
+ QObject *element = qjsvalue_cast<QObject *>(listModel->get(i).property("path"));
+ QVERIFY(element);
+ QCOMPARE(element->property("name").toString(), QString::number(i));
+ }
+}
+
QTEST_MAIN(tst_qqmllistmodel)
#include "tst_qqmllistmodel.moc"
diff --git a/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp
index 6a9cc93abd..4875602314 100644
--- a/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp
+++ b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp
@@ -91,10 +91,10 @@ bool tst_qqmllistmodelworkerscript::compareVariantList(const QVariantList &testL
if (model == nullptr)
return false;
- if (model->count() != testList.count())
+ if (model->count() != testList.size())
return false;
- for (int i=0 ; i < testList.count() ; ++i) {
+ for (int i=0 ; i < testList.size() ; ++i) {
const QVariant &testVariant = testList.at(i);
if (testVariant.typeId() != QMetaType::QVariantMap)
return false;
@@ -331,8 +331,8 @@ void tst_qqmllistmodelworkerscript::dynamic_worker()
QSignalSpy spyCount(&model, SIGNAL(countChanged()));
- if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
- script = script.mid(1, script.length() - 2);
+ if (script[0] == QLatin1Char('{') && script[script.size()-1] == QLatin1Char('}'))
+ script = script.mid(1, script.size() - 2);
QVariantList operations;
foreach (const QString &s, script.split(';')) {
if (!s.isEmpty())
@@ -348,7 +348,7 @@ void tst_qqmllistmodelworkerscript::dynamic_worker()
QCOMPARE(QQmlProperty(item, "result").read().toInt(), result);
if (model.count() > 0)
- QVERIFY(spyCount.count() > 0);
+ QVERIFY(spyCount.size() > 0);
delete item;
qApp->processEvents();
@@ -380,8 +380,8 @@ void tst_qqmllistmodelworkerscript::dynamic_worker_sync()
QQuickItem *item = createWorkerTest(&eng, &component, &model);
QVERIFY(item != nullptr);
- if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
- script = script.mid(1, script.length() - 2);
+ if (script[0] == QLatin1Char('{') && script[script.size()-1] == QLatin1Char('}'))
+ script = script.mid(1, script.size() - 2);
QVariantList operations;
foreach (const QString &s, script.split(';')) {
if (!s.isEmpty())
@@ -394,7 +394,7 @@ void tst_qqmllistmodelworkerscript::dynamic_worker_sync()
// execute a set of commands on the worker list model, then check the
// changes are reflected in the list model in the main thread
QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
+ Q_ARG(QVariant, operations.mid(0, operations.size()-1))));
waitForWorker(item);
QQmlExpression e(eng.rootContext(), &model, operations.last().toString());
@@ -468,7 +468,7 @@ void tst_qqmllistmodelworkerscript::get_worker()
QCOMPARE(model.data(index, role), roleValue);
}
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> spyResult = spy.takeFirst();
QCOMPARE(spyResult.at(0).value<QModelIndex>(), model.index(index, 0, QModelIndex()));
@@ -585,11 +585,11 @@ void tst_qqmllistmodelworkerscript::property_changes_worker()
// test itemsChanged() is emitted correctly
if (itemsChanged) {
- QCOMPARE(spyItemsChanged.count(), 1);
+ QCOMPARE(spyItemsChanged.size(), 1);
QCOMPARE(spyItemsChanged.at(0).at(0).value<QModelIndex>(), model.index(listIndex, 0, QModelIndex()));
QCOMPARE(spyItemsChanged.at(0).at(1).value<QModelIndex>(), model.index(listIndex, 0, QModelIndex()));
} else {
- QCOMPARE(spyItemsChanged.count(), 0);
+ QCOMPARE(spyItemsChanged.size(), 0);
}
delete item;
@@ -638,32 +638,32 @@ void tst_qqmllistmodelworkerscript::worker_sync()
QCOMPARE(model.count(), 2);
QCOMPARE(childModel->count(), 1);
- QCOMPARE(spyModelInserted.count(), 0);
- QCOMPARE(spyChildInserted.count(), 0);
+ QCOMPARE(spyModelInserted.size(), 0);
+ QCOMPARE(spyChildInserted.size(), 0);
QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
waitForWorker(item);
QCOMPARE(model.count(), 2);
QCOMPARE(childModel->count(), 2);
- QCOMPARE(spyModelInserted.count(), 0);
- QCOMPARE(spyChildInserted.count(), 1);
+ QCOMPARE(spyModelInserted.size(), 0);
+ QCOMPARE(spyChildInserted.size(), 1);
QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker"));
waitForWorker(item);
QCOMPARE(model.count(), 2);
QCOMPARE(childModel->count(), 2);
- QCOMPARE(spyModelInserted.count(), 0);
- QCOMPARE(spyChildInserted.count(), 1);
+ QCOMPARE(spyModelInserted.size(), 0);
+ QCOMPARE(spyChildInserted.size(), 1);
QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
waitForWorker(item);
QCOMPARE(model.count(), 2);
QCOMPARE(childModel->count(), 3);
- QCOMPARE(spyModelInserted.count(), 0);
- QCOMPARE(spyChildInserted.count(), 2);
+ QCOMPARE(spyModelInserted.size(), 0);
+ QCOMPARE(spyChildInserted.size(), 2);
delete item;
qApp->processEvents();
@@ -688,7 +688,7 @@ void tst_qqmllistmodelworkerscript::worker_remove_element()
QSignalSpy spyModelRemoved(&model, SIGNAL(rowsRemoved(QModelIndex,int,int)));
QCOMPARE(model.count(), 0);
- QCOMPARE(spyModelRemoved.count(), 0);
+ QCOMPARE(spyModelRemoved.size(), 0);
QVERIFY(QMetaObject::invokeMethod(item, "addItem"));
@@ -698,13 +698,13 @@ void tst_qqmllistmodelworkerscript::worker_remove_element()
waitForWorker(item);
QCOMPARE(model.count(), 1);
- QCOMPARE(spyModelRemoved.count(), 0);
+ QCOMPARE(spyModelRemoved.size(), 0);
QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
waitForWorker(item);
QCOMPARE(model.count(), 0);
- QCOMPARE(spyModelRemoved.count(), 1);
+ QCOMPARE(spyModelRemoved.size(), 1);
delete item;
qApp->processEvents();
@@ -751,7 +751,7 @@ void tst_qqmllistmodelworkerscript::worker_remove_list()
QSignalSpy spyModelRemoved(&model, SIGNAL(rowsRemoved(QModelIndex,int,int)));
QCOMPARE(model.count(), 0);
- QCOMPARE(spyModelRemoved.count(), 0);
+ QCOMPARE(spyModelRemoved.size(), 0);
QVERIFY(QMetaObject::invokeMethod(item, "addList"));
@@ -761,13 +761,13 @@ void tst_qqmllistmodelworkerscript::worker_remove_list()
waitForWorker(item);
QCOMPARE(model.count(), 1);
- QCOMPARE(spyModelRemoved.count(), 0);
+ QCOMPARE(spyModelRemoved.size(), 0);
QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
waitForWorker(item);
QCOMPARE(model.count(), 0);
- QCOMPARE(spyModelRemoved.count(), 1);
+ QCOMPARE(spyModelRemoved.size(), 1);
delete item;
qApp->processEvents();
@@ -798,8 +798,8 @@ void tst_qqmllistmodelworkerscript::dynamic_role()
QQmlExpression preExp(engine.rootContext(), &model, preamble);
QCOMPARE(preExp.evaluate().toInt(), 0);
- if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
- script = script.mid(1, script.length() - 2);
+ if (script[0] == QLatin1Char('{') && script[script.size()-1] == QLatin1Char('}'))
+ script = script.mid(1, script.size() - 2);
QVariantList operations;
foreach (const QString &s, script.split(';')) {
if (!s.isEmpty())
@@ -809,7 +809,7 @@ void tst_qqmllistmodelworkerscript::dynamic_role()
// execute a set of commands on the worker list model, then check the
// changes are reflected in the list model in the main thread
QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
+ Q_ARG(QVariant, operations.mid(0, operations.size()-1))));
waitForWorker(item);
QQmlExpression e(engine.rootContext(), &model, operations.last().toString());
diff --git a/tests/auto/qml/qqmllocale/data/functions.qml b/tests/auto/qml/qqmllocale/data/functions.qml
index 9fee78a836..42e26a508c 100644
--- a/tests/auto/qml/qqmllocale/data/functions.qml
+++ b/tests/auto/qml/qqmllocale/data/functions.qml
@@ -3,9 +3,6 @@ import QtQuick
QtObject {
property var locale: Qt.locale()
- // TODO: Workaround for not being able to use "Locale" in QQmlExpression (QTBUG-91747).
- property var localeType: Locale
-
function setLocale(l) {
locale = Qt.locale(l)
}
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
index 90420b7630..b678fbd1e2 100644
--- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -498,9 +498,9 @@ void tst_qqmllocale::weekDays()
QList<QVariant> qmlDays = val.toList();
QList<Qt::DayOfWeek> days = QLocale(locale).weekdays();
- QCOMPARE(days.count(), qmlDays.count());
+ QCOMPARE(days.size(), qmlDays.size());
- for (int i = 0; i < days.count(); ++i) {
+ for (int i = 0; i < days.size(); ++i) {
int day = int(days.at(i));
if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
day = 0;
@@ -540,9 +540,9 @@ void tst_qqmllocale::uiLanguages()
QList<QVariant> qmlLangs = val.toList();
QStringList langs = QLocale(locale).uiLanguages();
- QCOMPARE(langs.count(), qmlLangs.count());
+ QCOMPARE(langs.size(), qmlLangs.size());
- for (int i = 0; i < langs.count(); ++i) {
+ for (int i = 0; i < langs.size(); ++i) {
QCOMPARE(langs.at(i), qmlLangs.at(i).toString());
}
@@ -663,15 +663,15 @@ void tst_qqmllocale::addFormattedDataSizeDataForLocale(const QString &localeStr)
expectedResult = locale.formattedDataSize(1000000, 3);
QTest::newRow(qPrintable(makeTag())) << localeStr << functionCallScript << expectedResult << expectedErrorMessage;
- functionCallScript = QLatin1String("locale.formattedDataSize(1000000, 3, localeType.DataSizeIecFormat)");
+ functionCallScript = QLatin1String("locale.formattedDataSize(1000000, 3, Locale.DataSizeIecFormat)");
expectedResult = locale.formattedDataSize(1000000, 3, QLocale::DataSizeIecFormat);
QTest::newRow(qPrintable(makeTag())) << localeStr << functionCallScript << expectedResult << expectedErrorMessage;
- functionCallScript = QLatin1String("locale.formattedDataSize(1000000, 3, localeType.DataSizeTraditionalFormat)");
+ functionCallScript = QLatin1String("locale.formattedDataSize(1000000, 3, Locale.DataSizeTraditionalFormat)");
expectedResult = locale.formattedDataSize(1000000, 3, QLocale::DataSizeTraditionalFormat);
QTest::newRow(qPrintable(makeTag())) << localeStr << functionCallScript << expectedResult << expectedErrorMessage;
- functionCallScript = QLatin1String("locale.formattedDataSize(1000000, 3, localeType.DataSizeSIFormat)");
+ functionCallScript = QLatin1String("locale.formattedDataSize(1000000, 3, Locale.DataSizeSIFormat)");
expectedResult = locale.formattedDataSize(1000000, 3, QLocale::DataSizeSIFormat);
QTest::newRow(qPrintable(makeTag())) << localeStr << functionCallScript << expectedResult << expectedErrorMessage;
}
@@ -695,7 +695,7 @@ void tst_qqmllocale::formattedDataSize_data()
QString errorMessage = ".*Locale: formattedDataSize\\(\\): Expected 1-3 arguments, but received 0";
QTest::newRow("too few args") << "en_AU" << functionCallScript << QString() << errorMessage;
- functionCallScript = "locale.formattedDataSize(10, 1, localeType.DataSizeIecFormat, \"foo\")";
+ functionCallScript = "locale.formattedDataSize(10, 1, Locale.DataSizeIecFormat, \"foo\")";
errorMessage = ".*Locale: formattedDataSize\\(\\): Expected 1-3 arguments, but received 4";
QTest::newRow("too many args") << "en_AU" << functionCallScript << QString() << errorMessage;
@@ -727,7 +727,9 @@ void tst_qqmllocale::formattedDataSize()
QVERIFY(QMetaObject::invokeMethod(object.data(), "setLocale", Qt::DirectConnection,
Q_ARG(QVariant, QVariant(localeStr))));
- QQmlExpression qmlExpression(engine.rootContext(), object.data(), functionCallScript);
+ // Make sure that we use the object's context rather than the root context,
+ // so that e.g. enums from the Locale type are available (QTBUG-91747).
+ QQmlExpression qmlExpression(qmlContext(object.data()), object.data(), functionCallScript);
const QVariant evaluationResult = qmlExpression.evaluate();
if (expectedErrorMessagePattern.isEmpty()) {
QVERIFY2(!qmlExpression.hasError(), qPrintable(qmlExpression.error().toString()));
diff --git a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
index ed6f24aaf3..d945f460eb 100644
--- a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
+++ b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
@@ -227,18 +227,18 @@ void tst_QQmlMetaObject::property()
QCOMPARE(value, expectedValue);
else
QVERIFY(value.isValid());
- QCOMPARE(changedSpy.count(), 0);
+ QCOMPARE(changedSpy.size(), 0);
if (isWritable) {
QVERIFY(prop.write(object, newValue));
- QCOMPARE(changedSpy.count(), 1);
+ QCOMPARE(changedSpy.size(), 1);
QVariant value = prop.read(object);
if (value.userType() == qMetaTypeId<QJSValue>())
value = value.value<QJSValue>().toVariant();
QCOMPARE(value, newValue);
} else {
QVERIFY(!prop.write(object, prop.read(object)));
- QCOMPARE(changedSpy.count(), 0);
+ QCOMPARE(changedSpy.size(), 0);
}
}
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
index 6f4221539d..1304930583 100644
--- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
+++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
@@ -49,6 +49,8 @@ private slots:
void enumsInRecursiveImport_data();
void enumsInRecursiveImport();
+
+ void clearPropertyCaches();
};
class TestType : public QObject
@@ -711,6 +713,18 @@ void tst_qqmlmetatype::enumsInRecursiveImport()
QTRY_COMPARE(obj->property("color").toString(), QString("green"));
}
+void tst_qqmlmetatype::clearPropertyCaches()
+{
+ qmlClearTypeRegistrations();
+ qmlRegisterType<TestType>("ClearPropertyCaches", 1, 0, "A");
+ QQmlPropertyCache::ConstPtr oldCache = QQmlMetaType::propertyCache(&TestType::staticMetaObject);
+ QVERIFY(oldCache);
+ qmlClearTypeRegistrations();
+ qmlRegisterType<TestType>("ClearPropertyCaches", 1, 0, "B");
+ QQmlPropertyCache::ConstPtr newCache = QQmlMetaType::propertyCache(&TestType::staticMetaObject);
+ QVERIFY(oldCache.data() != newCache.data());
+}
+
QTEST_MAIN(tst_qqmlmetatype)
#include "tst_qqmlmetatype.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
index b36a43243d..a4901aebad 100644
--- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
@@ -133,7 +133,7 @@ void registerStaticPlugin(const char *uri)
PluginType::metaData.append(QCborValue(QCborMap::fromJsonObject(md)).toCbor());
auto rawMetaDataFunctor = []() -> QPluginMetaData {
- return {reinterpret_cast<const uchar *>(PluginType::metaData.constData()), size_t(PluginType::metaData.length())};
+ return {reinterpret_cast<const uchar *>(PluginType::metaData.constData()), size_t(PluginType::metaData.size())};
};
QStaticPlugin plugin(instanceFunctor, rawMetaDataFunctor);
qRegisterStaticPluginFunction(plugin);
@@ -235,7 +235,7 @@ void tst_qqmlmoduleplugin::incorrectPluginCase()
QQmlComponent component(&engine, testFileUrl(QStringLiteral("incorrectCase.qml")));
QList<QQmlError> errors = component.errors();
- QCOMPARE(errors.count(), 1);
+ QCOMPARE(errors.size(), 1);
QString expectedError = QLatin1String("module \"org.qtproject.WrongCase\" plugin \"PluGin\" not found");
@@ -566,7 +566,7 @@ void tst_qqmlmoduleplugin::importStrictModule()
QVERIFY(object != nullptr);
} else {
QVERIFY(!component.isReady());
- QCOMPARE(component.errors().count(), 1);
+ QCOMPARE(component.errors().size(), 1);
QCOMPARE(component.errors().first().toString(), url.toString() + error);
}
}
diff --git a/tests/auto/qml/qqmlnotifier/BLACKLIST b/tests/auto/qml/qqmlnotifier/BLACKLIST
new file mode 100644
index 0000000000..fc23287720
--- /dev/null
+++ b/tests/auto/qml/qqmlnotifier/BLACKLIST
@@ -0,0 +1,3 @@
+# e64548973d33295268881ac3bed49d1bbedd8a10
+[deleteFromHandler]
+macos ci
diff --git a/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp b/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp
index 438dc3d3c2..d007f4d024 100644
--- a/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp
+++ b/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp
@@ -15,7 +15,7 @@ private slots:
static bool compareItems(QQmlObjectModel *model, const QObjectList &items)
{
- for (int i = 0; i < items.count(); ++i) {
+ for (int i = 0; i < items.size(); ++i) {
if (model->get(i) != items.at(i))
return false;
}
@@ -65,81 +65,81 @@ void tst_QQmlObjectModel::changes()
model.append(&item0); items.append(&item0);
QCOMPARE(model.count(), ++count);
QVERIFY(compareItems(&model, items));
- QCOMPARE(countSpy.count(), ++countSignals);
- QCOMPARE(childrenSpy.count(), ++childrenSignals);
- QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals);
+ QCOMPARE(countSpy.size(), ++countSignals);
+ QCOMPARE(childrenSpy.size(), ++childrenSignals);
+ QCOMPARE(modelUpdateSpy.size(), ++modelUpdateSignals);
QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 1, 0, false));
// insert(0, item1) -> [item1, item0]
model.insert(0, &item1); items.insert(0, &item1);
QCOMPARE(model.count(), ++count);
QVERIFY(compareItems(&model, items));
- QCOMPARE(countSpy.count(), ++countSignals);
- QCOMPARE(childrenSpy.count(), ++childrenSignals);
- QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals);
+ QCOMPARE(countSpy.size(), ++countSignals);
+ QCOMPARE(childrenSpy.size(), ++childrenSignals);
+ QCOMPARE(modelUpdateSpy.size(), ++modelUpdateSignals);
QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 1, 0, false));
// append(item2) -> [item1, item0, item2]
model.append(&item2); items.append(&item2);
QCOMPARE(model.count(), ++count);
QVERIFY(compareItems(&model, items));
- QCOMPARE(countSpy.count(), ++countSignals);
- QCOMPARE(childrenSpy.count(), ++childrenSignals);
- QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals);
+ QCOMPARE(countSpy.size(), ++countSignals);
+ QCOMPARE(childrenSpy.size(), ++childrenSignals);
+ QCOMPARE(modelUpdateSpy.size(), ++modelUpdateSignals);
QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 1, 0, false));
// insert(2, item3) -> [item1, item0, item3, item2]
model.insert(2, &item3); items.insert(2, &item3);
QCOMPARE(model.count(), ++count);
QVERIFY(compareItems(&model, items));
- QCOMPARE(countSpy.count(), ++countSignals);
- QCOMPARE(childrenSpy.count(), ++childrenSignals);
- QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals);
+ QCOMPARE(countSpy.size(), ++countSignals);
+ QCOMPARE(childrenSpy.size(), ++childrenSignals);
+ QCOMPARE(modelUpdateSpy.size(), ++modelUpdateSignals);
QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 1, 0, false));
// move(0, 1) -> [item0, item1, item3, item2]
model.move(0, 1); items.move(0, 1);
QCOMPARE(model.count(), count);
QVERIFY(compareItems(&model, items));
- QCOMPARE(countSpy.count(), countSignals);
- QCOMPARE(childrenSpy.count(), ++childrenSignals);
- QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals);
+ QCOMPARE(countSpy.size(), countSignals);
+ QCOMPARE(childrenSpy.size(), ++childrenSignals);
+ QCOMPARE(modelUpdateSpy.size(), ++modelUpdateSignals);
QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 1, 1, true, 1));
// move(3, 2) -> [item0, item1, item2, item3]
model.move(3, 2); items.move(3, 2);
QCOMPARE(model.count(), count);
QVERIFY(compareItems(&model, items));
- QCOMPARE(countSpy.count(), countSignals);
- QCOMPARE(childrenSpy.count(), ++childrenSignals);
- QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals);
+ QCOMPARE(countSpy.size(), countSignals);
+ QCOMPARE(childrenSpy.size(), ++childrenSignals);
+ QCOMPARE(modelUpdateSpy.size(), ++modelUpdateSignals);
QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 1, 1, true, 2));
// remove(0) -> [item1, item2, item3]
model.remove(0); items.removeAt(0);
QCOMPARE(model.count(), --count);
QVERIFY(compareItems(&model, items));
- QCOMPARE(countSpy.count(), ++countSignals);
- QCOMPARE(childrenSpy.count(), ++childrenSignals);
- QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals);
+ QCOMPARE(countSpy.size(), ++countSignals);
+ QCOMPARE(childrenSpy.size(), ++childrenSignals);
+ QCOMPARE(modelUpdateSpy.size(), ++modelUpdateSignals);
QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 0, 1, false));
// remove(2) -> [item1, item2]
model.remove(2); items.removeAt(2);
QCOMPARE(model.count(), --count);
QVERIFY(compareItems(&model, items));
- QCOMPARE(countSpy.count(), ++countSignals);
- QCOMPARE(childrenSpy.count(), ++childrenSignals);
- QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals);
+ QCOMPARE(countSpy.size(), ++countSignals);
+ QCOMPARE(childrenSpy.size(), ++childrenSignals);
+ QCOMPARE(modelUpdateSpy.size(), ++modelUpdateSignals);
QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 0, 1, false));
// clear() -> []
model.clear(); items.clear();
QCOMPARE(model.count(), 0);
QVERIFY(compareItems(&model, items));
- QCOMPARE(countSpy.count(), ++countSignals);
- QCOMPARE(childrenSpy.count(), ++childrenSignals);
- QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals);
+ QCOMPARE(countSpy.size(), ++countSignals);
+ QCOMPARE(childrenSpy.size(), ++childrenSignals);
+ QCOMPARE(modelUpdateSpy.size(), ++modelUpdateSignals);
QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 0, 2, false));
}
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
index f0a3c19d16..14a1fa13f8 100644
--- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -550,7 +550,7 @@ void tst_qqmlparser::typeAnnotations_data()
QStringList files;
files << findFiles(QDir(tests));
- for (const QString &file: qAsConst(files))
+ for (const QString &file: std::as_const(files))
QTest::newRow(qPrintable(file)) << file;
}
@@ -590,7 +590,7 @@ void tst_qqmlparser::disallowedTypeAnnotations_data()
QStringList files;
files << findFiles(QDir(tests));
- for (const QString &file: qAsConst(files))
+ for (const QString &file: std::as_const(files))
QTest::newRow(qPrintable(file)) << file;
}
@@ -679,7 +679,7 @@ void tst_qqmlparser::annotations_data()
QStringList refFiles;
refFiles << findFiles(QDir(compare));
- for (const QString &file: qAsConst(files)) {
+ for (const QString &file: std::as_const(files)) {
auto fileNameStart = file.lastIndexOf(QDir::separator());
auto fileName = QStringView(file).mid(fileNameStart, file.length()-fileNameStart);
auto ref=std::find_if(refFiles.constBegin(),refFiles.constEnd(), [fileName](const QString &s){ return s.endsWith(fileName); });
diff --git a/tests/auto/qml/qqmlproperty/data/assignVariantList.qml b/tests/auto/qml/qqmlproperty/data/assignVariantList.qml
new file mode 100644
index 0000000000..78565b64b9
--- /dev/null
+++ b/tests/auto/qml/qqmlproperty/data/assignVariantList.qml
@@ -0,0 +1,6 @@
+import Test
+import QtQml
+
+ListHolder {
+ doubleList: varList
+}
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index 7d2dc302ea..e432c548d3 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -116,6 +116,35 @@ public:
QML_DECLARE_TYPE(MyAlwaysReplaceBehaviorContainer);
+class ListHolder : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QVariantList varList READ varList NOTIFY varListChanged)
+ Q_PROPERTY(QList<double> doubleList READ doubleList WRITE setDoubleList NOTIFY doubleListChanged)
+public:
+ explicit ListHolder(QObject *parent = nullptr) : QObject(parent) {}
+
+ QVariantList varList() const { return {1.1, 2.2, 3.3, 11, 5.25f, QStringLiteral("11")}; }
+
+ QList<double> doubleList() const { return m_doubleList; }
+
+ void setDoubleList(const QList<double> &newDoubleList)
+ {
+ if (m_doubleList == newDoubleList)
+ return;
+ m_doubleList = newDoubleList;
+ emit doubleListChanged();
+ }
+
+signals:
+ void varListChanged();
+ void doubleListChanged();
+
+private:
+ QList<double> m_doubleList;
+};
+
+
class tst_qqmlproperty : public QQmlDataTest
{
Q_OBJECT
@@ -187,6 +216,7 @@ private slots:
void constructFromPlainMetaObject();
void bindToNonQObjectTarget();
+ void assignVariantList();
private:
QQmlEngine engine;
};
@@ -2103,7 +2133,7 @@ void tst_qqmlproperty::assignEmptyVariantMap()
QVariantMap map;
map.insert("key", "value");
o.setVariantMap(map);
- QCOMPARE(o.variantMap().count(), 1);
+ QCOMPARE(o.variantMap().size(), 1);
QCOMPARE(o.variantMap().isEmpty(), false);
@@ -2111,7 +2141,7 @@ void tst_qqmlproperty::assignEmptyVariantMap()
QObject *obj = component.createWithInitialProperties({{"o", QVariant::fromValue(&o)}});
QVERIFY(obj);
- QCOMPARE(o.variantMap().count(), 0);
+ QCOMPARE(o.variantMap().size(), 0);
QCOMPARE(o.variantMap().isEmpty(), true);
delete obj;
@@ -2267,6 +2297,7 @@ void tst_qqmlproperty::initTestCase()
qmlRegisterType<MyContainer>("Test",1,0,"MyContainer");
qmlRegisterType<MyReplaceIfNotDefaultBehaviorContainer>("Test",1,0,"MyReplaceIfNotDefaultBehaviorContainer");
qmlRegisterType<MyAlwaysReplaceBehaviorContainer>("Test",1,0,"MyAlwaysReplaceBehaviorContainer");
+ qmlRegisterType<ListHolder>("Test", 1, 0, "ListHolder");
}
// QTBUG-60908
@@ -2513,6 +2544,18 @@ void tst_qqmlproperty::bindToNonQObjectTarget()
QVERIFY(!o.isNull());
}
+void tst_qqmlproperty::assignVariantList()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("assignVariantList.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o.isNull());
+ ListHolder *holder = qobject_cast<ListHolder *>(o.data());
+ const QList<double> doubleList = {1.1, 2.2, 3.3, 11, 5.25, 11};
+ QCOMPARE(holder->doubleList(), doubleList);
+}
+
QTEST_MAIN(tst_qqmlproperty)
#include "tst_qqmlproperty.moc"
diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
index aac9c5229f..3c3e0ba1e9 100644
--- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
+++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
@@ -90,7 +90,7 @@ void tst_QQmlPropertyMap::insert()
QQmlPropertyMap map;
map.insert(QLatin1String("key1"),100);
map.insert(QLatin1String("key2"),200);
- QCOMPARE(map.keys().count(), 2);
+ QCOMPARE(map.keys().size(), 2);
QVERIFY(map.contains(QLatin1String("key1")));
QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
@@ -103,33 +103,33 @@ void tst_QQmlPropertyMap::insert()
//QQmlPropertyMap has an invokable keys() method
QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols.");
map.insert(QLatin1String("keys"), 1);
- QCOMPARE(map.keys().count(), 2);
+ QCOMPARE(map.keys().size(), 2);
QVERIFY(!map.contains(QLatin1String("keys")));
QVERIFY(map.value(QLatin1String("keys")).isNull());
//QQmlPropertyMap has a deleteLater() slot
QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols.");
map.insert(QLatin1String("deleteLater"), 1);
- QCOMPARE(map.keys().count(), 2);
+ QCOMPARE(map.keys().size(), 2);
QVERIFY(!map.contains(QLatin1String("deleteLater")));
QVERIFY(map.value(QLatin1String("deleteLater")).isNull());
//QQmlPropertyMap has an valueChanged() signal
QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols.");
map.insert(QLatin1String("valueChanged"), 1);
- QCOMPARE(map.keys().count(), 2);
+ QCOMPARE(map.keys().size(), 2);
QVERIFY(!map.contains(QLatin1String("valueChanged")));
QVERIFY(map.value(QLatin1String("valueChanged")).isNull());
//but 'valueChange' should be ok
map.insert(QLatin1String("valueChange"), 1);
- QCOMPARE(map.keys().count(), 3);
+ QCOMPARE(map.keys().size(), 3);
QVERIFY(map.contains(QLatin1String("valueChange")));
QCOMPARE(map.value(QLatin1String("valueChange")), QVariant(1));
//'valueCHANGED' should be ok, too
map.insert(QLatin1String("valueCHANGED"), 1);
- QCOMPARE(map.keys().count(), 4);
+ QCOMPARE(map.keys().size(), 4);
QVERIFY(map.contains(QLatin1String("valueCHANGED")));
QCOMPARE(map.value(QLatin1String("valueCHANGED")), QVariant(1));
}
@@ -144,7 +144,7 @@ void tst_QQmlPropertyMap::insertMany()
QQmlPropertyMap map;
map.insert(values);
- QCOMPARE(map.keys().count(), 4);
+ QCOMPARE(map.keys().size(), 4);
QVERIFY(map.contains(QLatin1String("key1")));
QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
@@ -162,7 +162,7 @@ void tst_QQmlPropertyMap::insertMany()
//QQmlPropertyMap has an invokable keys() method
QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols.");
map.insert(values);
- QCOMPARE(map.keys().count(), 4);
+ QCOMPARE(map.keys().size(), 4);
QVERIFY(!map.contains(QLatin1String("keys")));
QVERIFY(map.value(QLatin1String("keys")).isNull());
@@ -171,7 +171,7 @@ void tst_QQmlPropertyMap::insertMany()
//QQmlPropertyMap has a deleteLater() slot
QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols.");
map.insert(values);
- QCOMPARE(map.keys().count(), 4);
+ QCOMPARE(map.keys().size(), 4);
QVERIFY(!map.contains(QLatin1String("deleteLater")));
QVERIFY(map.value(QLatin1String("deleteLater")).isNull());
@@ -180,13 +180,13 @@ void tst_QQmlPropertyMap::insertMany()
//QQmlPropertyMap has an valueChanged() signal
QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols.");
map.insert(values);
- QCOMPARE(map.keys().count(), 4);
+ QCOMPARE(map.keys().size(), 4);
QVERIFY(!map.contains(QLatin1String("valueChanged")));
QVERIFY(map.value(QLatin1String("valueChanged")).isNull());
values.remove(QStringLiteral("valueChanged"));
map.insert(values); // Adds "foobar" and changes "key1"
- QCOMPARE(map.keys().count(), 5);
+ QCOMPARE(map.keys().size(), 5);
QCOMPARE(map.value(QStringLiteral("foobar")).toInt(), 12);
QCOMPARE(map.value(QStringLiteral("key1")).toInt(), 100);
}
@@ -196,7 +196,7 @@ void tst_QQmlPropertyMap::operatorInsert()
QQmlPropertyMap map;
map[QLatin1String("key1")] = 100;
map[QLatin1String("key2")] = 200;
- QCOMPARE(map.keys().count(), 2);
+ QCOMPARE(map.keys().size(), 2);
QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
@@ -225,12 +225,12 @@ void tst_QQmlPropertyMap::clear()
{
QQmlPropertyMap map;
map.insert(QLatin1String("key1"),100);
- QCOMPARE(map.keys().count(), 1);
+ QCOMPARE(map.keys().size(), 1);
QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
map.clear(QLatin1String("key1"));
- QCOMPARE(map.keys().count(), 1);
+ QCOMPARE(map.keys().size(), 1);
QVERIFY(map.contains(QLatin1String("key1")));
QCOMPARE(map.value(QLatin1String("key1")), QVariant());
}
@@ -241,10 +241,10 @@ void tst_QQmlPropertyMap::changed()
QSignalSpy spy(&map, SIGNAL(valueChanged(QString,QVariant)));
map.insert(QLatin1String("key1"),100);
map.insert(QLatin1String("key2"),200);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
map.clear(QLatin1String("key1"));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
//make changes in QML
QQmlEngine engine;
@@ -257,9 +257,9 @@ void tst_QQmlPropertyMap::changed()
QScopedPointer<QQuickText> txt(qobject_cast<QQuickText*>(component.create()));
QVERIFY(txt);
QCOMPARE(txt->text(), QString('X'));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
- QCOMPARE(arguments.count(), 2);
+ QCOMPARE(arguments.size(), 2);
QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
QCOMPARE(arguments.at(1).value<QVariant>(),QVariant("Hello World"));
QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
@@ -485,7 +485,7 @@ void tst_QQmlPropertyMap::disallowExtending()
"}\n", QUrl());
obj.reset(component.create());
QVERIFY(obj.isNull());
- QCOMPARE(component.errors().count(), 1);
+ QCOMPARE(component.errors().size(), 1);
QCOMPARE(component.errors().at(0).toString(), QStringLiteral("<Unknown File>:3:1: Fully dynamic types cannot declare new properties."));
}
@@ -524,24 +524,24 @@ void tst_QQmlPropertyMap::QTBUG_48136()
QSignalSpy notifySpy(&map, QByteArray::number(QSIGNAL_CODE) + prop.notifySignal().methodSignature());
map.insert(key, 42);
- QCOMPARE(notifySpy.count(), 1);
+ QCOMPARE(notifySpy.size(), 1);
map.insert(key, 43);
- QCOMPARE(notifySpy.count(), 2);
+ QCOMPARE(notifySpy.size(), 2);
map.insert(key, 43);
- QCOMPARE(notifySpy.count(), 2);
+ QCOMPARE(notifySpy.size(), 2);
map.insert(key, 44);
- QCOMPARE(notifySpy.count(), 3);
+ QCOMPARE(notifySpy.size(), 3);
//
// Test that the valueChanged signal is emitted correctly
//
QSignalSpy valueChangedSpy(&map, &QQmlPropertyMap::valueChanged);
map.setProperty(key, 44);
- QCOMPARE(valueChangedSpy.count(), 0);
+ QCOMPARE(valueChangedSpy.size(), 0);
map.setProperty(key, 45);
- QCOMPARE(valueChangedSpy.count(), 1);
+ QCOMPARE(valueChangedSpy.size(), 1);
map.setProperty(key, 45);
- QCOMPARE(valueChangedSpy.count(), 1);
+ QCOMPARE(valueChangedSpy.size(), 1);
}
void tst_QQmlPropertyMap::lookupsInSubTypes()
@@ -560,14 +560,14 @@ void tst_QQmlPropertyMap::freeze()
map.insert(QLatin1String("key1"),100);
map.insert(QLatin1String("key2"),200);
- QCOMPARE(map.keys().count(), 2);
+ QCOMPARE(map.keys().size(), 2);
QVERIFY(map.contains(QLatin1String("key1")));
QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
map.freeze();
map.insert(QLatin1String("key3"), 32);
- QCOMPARE(map.keys().count(), 2);
+ QCOMPARE(map.keys().size(), 2);
QVERIFY(!map.contains("key3"));
map.insert(QLatin1String("key1"), QStringLiteral("Hello World"));
@@ -652,7 +652,7 @@ void tst_QQmlPropertyMap::signalIndices()
QSignalSpy spy(&map, method);
map.insert(QLatin1String("key1"), 200);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
QTEST_MAIN(tst_QQmlPropertyMap)
diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
index 595adf5f67..220f449dfc 100644
--- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
+++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
@@ -733,7 +733,7 @@ void tst_qqmlqt::createQmlObject()
QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
QVERIFY(item != nullptr);
- QCOMPARE(item->childItems().count(), 1);
+ QCOMPARE(item->childItems().size(), 1);
}
@@ -825,7 +825,7 @@ void tst_qqmlqt::dateTimeFormatting()
QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
QVERIFY(object != nullptr);
- QVERIFY(inputProperties.count() > 0);
+ QVERIFY(inputProperties.size() > 0);
QVariant result;
foreach(const QString &prop, inputProperties) {
QVERIFY(QMetaObject::invokeMethod(object.data(), method.toUtf8().constData(),
@@ -833,7 +833,7 @@ void tst_qqmlqt::dateTimeFormatting()
Q_ARG(QVariant, prop)));
QStringList output = result.toStringList();
QCOMPARE(output.size(), expectedResults.size());
- for (int i=0; i<output.count(); i++)
+ for (int i=0; i<output.size(); i++)
QCOMPARE(output[i], expectedResults[i]);
}
}
@@ -885,7 +885,7 @@ void tst_qqmlqt::dateTimeFormattingVariants()
<< component.url().toString() + ":40: TypeError: Passing incompatible arguments to C++ functions from JavaScript is not allowed."
<< component.url().toString() + ":43: TypeError: Passing incompatible arguments to C++ functions from JavaScript is not allowed.";
- for (const QString &warning : qAsConst(warnings))
+ for (const QString &warning : std::as_const(warnings))
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
warnings.clear();
@@ -899,7 +899,7 @@ void tst_qqmlqt::dateTimeFormattingVariants()
<< "Could not convert argument 1 at"
<< "expression for err_dateTime2@";
- for (const QString &warning : qAsConst(warnings))
+ for (const QString &warning : std::as_const(warnings))
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(warning));
warnings.clear();
@@ -1136,7 +1136,7 @@ void tst_qqmlqt::quit()
QSignalSpy spy(&engine, SIGNAL(quit()));
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_qqmlqt::exit()
@@ -1146,7 +1146,7 @@ void tst_qqmlqt::exit()
QSignalSpy spy(&engine, &QQmlEngine::exit);
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QVERIFY(arguments.at(0).toInt() == object->property("returnCode").toInt());
}
diff --git a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
index 296b5ef0ff..67c44684a4 100644
--- a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
+++ b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
@@ -52,7 +52,7 @@ void removeRecursive(const QString& dirname)
{
QDir dir(dirname);
QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
- for (int i = 0; i < entries.count(); ++i)
+ for (int i = 0; i < entries.size(); ++i)
if (entries[i].isDir())
removeRecursive(entries[i].filePath());
else
@@ -174,7 +174,7 @@ void tst_qqmlsqldatabase::totalDatabases()
if (engine->offlineStoragePath().isEmpty())
QSKIP("offlineStoragePath is empty, skip this test.");
- QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2);
+ QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).size(), total_databases_created_by_tests*2);
}
void tst_qqmlsqldatabase::upgradeDatabase()
diff --git a/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp b/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
index a8be2d0f99..a01a72c167 100644
--- a/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
+++ b/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
@@ -69,8 +69,8 @@ void tst_QQmlTableModel::appendRemoveRow()
QVERIFY(QMetaObject::invokeMethod(model, "removeRow", Q_ARG(int, -1)));
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Call remove() with an rowIndex that is too large.
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(
@@ -78,16 +78,16 @@ void tst_QQmlTableModel::appendRemoveRow()
QVERIFY(QMetaObject::invokeMethod(model, "removeRow", Q_ARG(int, 2)));
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Call remove() with a valid rowIndex but negative rows.
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*removeRow\\(\\): \"rows\" is less than or equal to zero"));
QVERIFY(QMetaObject::invokeMethod(model, "removeRow", Q_ARG(int, 0), Q_ARG(int, -1)));
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Call remove() with a valid rowIndex but excessive rows.
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(
@@ -95,8 +95,8 @@ void tst_QQmlTableModel::appendRemoveRow()
QVERIFY(QMetaObject::invokeMethod(model, "removeRow", Q_ARG(int, 0), Q_ARG(int, 3)));
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Call remove() without specifying the number of rows to remove; it should remove one row.
QVERIFY(QMetaObject::invokeMethod(model, "removeRow", Q_ARG(int, 0)));
@@ -104,8 +104,8 @@ void tst_QQmlTableModel::appendRemoveRow()
QCOMPARE(model->columnCount(), 2);
QCOMPARE(model->data(model->index(0, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), ++rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), ++rowCountSignalEmissions);
// Call append() with a row that has an unexpected role; the row should be added and the extra data ignored.
QVERIFY(QMetaObject::invokeMethod(view.rootObject(), "appendRowExtraData"));
@@ -116,8 +116,8 @@ void tst_QQmlTableModel::appendRemoveRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Foo"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 99);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), ++rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), ++rowCountSignalEmissions);
// Call append() with a row that is an int.
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(
@@ -130,8 +130,8 @@ void tst_QQmlTableModel::appendRemoveRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Foo"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 99);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Call append() with a row with a role of the wrong type.
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(
@@ -144,8 +144,8 @@ void tst_QQmlTableModel::appendRemoveRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Foo"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 99);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Call append() with a row that is an array instead of a simple object.
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(
@@ -156,8 +156,8 @@ void tst_QQmlTableModel::appendRemoveRow()
QCOMPARE(model->columnCount(), 2);
QCOMPARE(model->data(model->index(0, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Call append() to insert one row.
QVERIFY(QMetaObject::invokeMethod(view.rootObject(), "appendRow", Q_ARG(QVariant, QLatin1String("Max")), Q_ARG(QVariant, 40)));
@@ -169,8 +169,8 @@ void tst_QQmlTableModel::appendRemoveRow()
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 99);
QCOMPARE(model->data(model->index(2, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Max"));
QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleNames.key("display")).toInt(), 40);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), ++rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), ++rowCountSignalEmissions);
// Call remove() and specify rowIndex and rows, removing all remaining rows.
QVERIFY(QMetaObject::invokeMethod(model, "removeRow", Q_ARG(int, 0), Q_ARG(int, 3)));
@@ -178,8 +178,8 @@ void tst_QQmlTableModel::appendRemoveRow()
QCOMPARE(model->columnCount(), 2);
QCOMPARE(model->data(model->index(0, 0, QModelIndex()), roleNames.key("display")), QVariant());
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")), QVariant());
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), ++rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), ++rowCountSignalEmissions);
}
void tst_QQmlTableModel::appendRowToEmptyModel()
@@ -211,8 +211,8 @@ void tst_QQmlTableModel::appendRowToEmptyModel()
const QHash<int, QByteArray> roleNames = model->roleNames();
QCOMPARE(model->data(model->index(0, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("John"));
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 1);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 1);
QTRY_COMPARE(tableView->rows(), 1);
QCOMPARE(tableView->columns(), 2);
}
@@ -249,8 +249,8 @@ void tst_QQmlTableModel::clear()
QCOMPARE(model->columnCount(), 2);
QCOMPARE(model->data(model->index(0, 0, QModelIndex()), roleNames.key("display")), QVariant());
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")), QVariant());
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 1);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 1);
// Wait until updatePolish() gets called, which is where the size is recalculated.
QTRY_COMPARE(tableView->rows(), 0);
QCOMPARE(tableView->columns(), 2);
@@ -323,8 +323,8 @@ void tst_QQmlTableModel::insertRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -339,8 +339,8 @@ void tst_QQmlTableModel::insertRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -354,8 +354,8 @@ void tst_QQmlTableModel::insertRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -369,8 +369,8 @@ void tst_QQmlTableModel::insertRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -384,8 +384,8 @@ void tst_QQmlTableModel::insertRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -399,8 +399,8 @@ void tst_QQmlTableModel::insertRow()
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
QCOMPARE(model->data(model->index(2, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), ++rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), ++rowCountSignalEmissions);
QTRY_COMPARE(tableView->rows(), 3);
QCOMPARE(tableView->columns(), 2);
@@ -417,8 +417,8 @@ void tst_QQmlTableModel::insertRow()
QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
QCOMPARE(model->data(model->index(3, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Max"));
QCOMPARE(model->data(model->index(3, 1, QModelIndex()), roleNames.key("display")).toInt(), 40);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), ++rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), ++rowCountSignalEmissions);
QTRY_COMPARE(tableView->rows(), 4);
QCOMPARE(tableView->columns(), 2);
@@ -437,8 +437,8 @@ void tst_QQmlTableModel::insertRow()
QCOMPARE(model->data(model->index(3, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
QCOMPARE(model->data(model->index(4, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Max"));
QCOMPARE(model->data(model->index(4, 1, QModelIndex()), roleNames.key("display")).toInt(), 40);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), ++rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), ++rowCountSignalEmissions);
QTRY_COMPARE(tableView->rows(), 5);
QCOMPARE(tableView->columns(), 2);
}
@@ -481,8 +481,8 @@ void tst_QQmlTableModel::moveRow()
QCOMPARE(model->data(model->index(4, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Trev"));
QCOMPARE(model->data(model->index(4, 1, QModelIndex()), roleNames.key("display")).toInt(), 48);
rowCountSignalEmissions = 3;
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Try to move with a fromRowIndex that is negative.
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*moveRow\\(\\): \"fromRowIndex\" cannot be negative"));
@@ -490,16 +490,16 @@ void tst_QQmlTableModel::moveRow()
// Shouldn't have changed.
QCOMPARE(model->data(model->index(4, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Trev"));
QCOMPARE(model->data(model->index(4, 1, QModelIndex()), roleNames.key("display")).toInt(), 48);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Try to move with a fromRowIndex that is too large.
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*moveRow\\(\\): \"fromRowIndex\" 5 is greater than or equal to rowCount\\(\\)"));
QVERIFY(QMetaObject::invokeMethod(model, "moveRow", Q_ARG(int, 5), Q_ARG(int, 1)));
QCOMPARE(model->data(model->index(4, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Trev"));
QCOMPARE(model->data(model->index(4, 1, QModelIndex()), roleNames.key("display")).toInt(), 48);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Try to move with a toRowIndex that is negative.
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*moveRow\\(\\): \"toRowIndex\" cannot be negative"));
@@ -507,16 +507,16 @@ void tst_QQmlTableModel::moveRow()
// Shouldn't have changed.
QCOMPARE(model->data(model->index(4, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Trev"));
QCOMPARE(model->data(model->index(4, 1, QModelIndex()), roleNames.key("display")).toInt(), 48);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Try to move with a toRowIndex that is too large.
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*moveRow\\(\\): \"toRowIndex\" 5 is greater than or equal to rowCount\\(\\)"));
QVERIFY(QMetaObject::invokeMethod(model, "moveRow", Q_ARG(int, 0), Q_ARG(int, 5)));
QCOMPARE(model->data(model->index(4, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Trev"));
QCOMPARE(model->data(model->index(4, 1, QModelIndex()), roleNames.key("display")).toInt(), 48);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Move the first row to the end.
QVERIFY(QMetaObject::invokeMethod(model, "moveRow", Q_ARG(int, 0), Q_ARG(int, 4)));
@@ -533,8 +533,8 @@ void tst_QQmlTableModel::moveRow()
QCOMPARE(model->data(model->index(3, 1, QModelIndex()), roleNames.key("display")).toInt(), 48);
QCOMPARE(model->data(model->index(4, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("John"));
QCOMPARE(model->data(model->index(4, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Move it back again.
QVERIFY(QMetaObject::invokeMethod(model, "moveRow", Q_ARG(int, 4), Q_ARG(int, 0)));
@@ -550,8 +550,8 @@ void tst_QQmlTableModel::moveRow()
QCOMPARE(model->data(model->index(3, 1, QModelIndex()), roleNames.key("display")).toInt(), 30);
QCOMPARE(model->data(model->index(4, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Trev"));
QCOMPARE(model->data(model->index(4, 1, QModelIndex()), roleNames.key("display")).toInt(), 48);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
// Move the first row down one by one row.
QVERIFY(QMetaObject::invokeMethod(model, "moveRow", Q_ARG(int, 0), Q_ARG(int, 1)));
@@ -567,8 +567,8 @@ void tst_QQmlTableModel::moveRow()
QCOMPARE(model->data(model->index(3, 1, QModelIndex()), roleNames.key("display")).toInt(), 30);
QCOMPARE(model->data(model->index(4, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Trev"));
QCOMPARE(model->data(model->index(4, 1, QModelIndex()), roleNames.key("display")).toInt(), 48);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
}
void tst_QQmlTableModel::setRow()
@@ -607,8 +607,8 @@ void tst_QQmlTableModel::setRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -623,8 +623,8 @@ void tst_QQmlTableModel::setRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -636,8 +636,8 @@ void tst_QQmlTableModel::setRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 99);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -651,8 +651,8 @@ void tst_QQmlTableModel::setRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 99);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -666,8 +666,8 @@ void tst_QQmlTableModel::setRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 99);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -681,8 +681,8 @@ void tst_QQmlTableModel::setRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 99);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -695,8 +695,8 @@ void tst_QQmlTableModel::setRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 40);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -709,8 +709,8 @@ void tst_QQmlTableModel::setRow()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 40);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Daisy"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 30);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), rowCountSignalEmissions);
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
@@ -725,8 +725,8 @@ void tst_QQmlTableModel::setRow()
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 30);
QCOMPARE(model->data(model->index(2, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Wot"));
QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleNames.key("display")).toInt(), 99);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), ++rowCountSignalEmissions);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), ++rowCountSignalEmissions);
QTRY_COMPARE(tableView->rows(), 3);
QCOMPARE(tableView->columns(), 2);
}
@@ -756,16 +756,16 @@ void tst_QQmlTableModel::setDataThroughDelegate()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 0);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 0);
QVERIFY(QMetaObject::invokeMethod(view.rootObject(), "modify"));
QCOMPARE(model->data(model->index(0, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("John"));
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 18);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 18);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 0);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 0);
// Test setting a role that doesn't exist for a certain column.
QVERIFY(QMetaObject::invokeMethod(view.rootObject(), "modifyInvalidRole"));
@@ -774,8 +774,8 @@ void tst_QQmlTableModel::setDataThroughDelegate()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 18);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 18);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 0);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 0);
// Test setting a role with a value of the wrong type.
// There are two rows, so two delegates respond to the signal, which means we need to ignore two warnings.
@@ -789,8 +789,8 @@ void tst_QQmlTableModel::setDataThroughDelegate()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 18);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 18);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 0);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 0);
}
// Start off with empty rows and then set them to test rowCountChanged().
@@ -825,8 +825,8 @@ void tst_QQmlTableModel::setRowsImperatively()
QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleNames.key("display")).toInt(), 22);
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Oliver"));
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 1);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 1);
QTRY_COMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
}
@@ -865,8 +865,8 @@ void tst_QQmlTableModel::setRowsMultipleTimes()
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 41);
QCOMPARE(model->data(model->index(2, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Power"));
QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleNames.key("display")).toInt(), 89);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 1);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 1);
QTRY_COMPARE(tableView->rows(), 3);
QCOMPARE(tableView->columns(), 2);
@@ -882,8 +882,8 @@ void tst_QQmlTableModel::setRowsMultipleTimes()
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 41);
QCOMPARE(model->data(model->index(2, 0, QModelIndex()), roleNames.key("display")).toString(), QLatin1String("Power"));
QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleNames.key("display")).toInt(), 89);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 1);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 1);
QCOMPARE(tableView->rows(), 3);
QCOMPARE(tableView->columns(), 2);
}
@@ -986,8 +986,8 @@ void tst_QQmlTableModel::appendRowWithDouble()
QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleKey).toDouble(), 3.5);
QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleKey).toString(),
QLatin1String("3.5"));
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 1);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 1);
QTRY_COMPARE(tableView->rows(), 3);
QCOMPARE(tableView->columns(), 2);
@@ -1001,8 +1001,8 @@ void tst_QQmlTableModel::appendRowWithDouble()
QCOMPARE(model->data(model->index(3, 1, QModelIndex()), roleKey).toDouble(), 5);
QCOMPARE(model->data(model->index(3, 1, QModelIndex()), roleKey).toString(),
QLatin1String("5"));
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 1);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 1);
QTRY_COMPARE(tableView->rows(), 4);
QCOMPARE(tableView->columns(), 2);
@@ -1015,8 +1015,8 @@ void tst_QQmlTableModel::appendRowWithDouble()
// Nothing should change
QCOMPARE(model->rowCount(), 4);
QCOMPARE(model->columnCount(), 2);
- QCOMPARE(columnCountSpy.count(), 0);
- QCOMPARE(rowCountSpy.count(), 0);
+ QCOMPARE(columnCountSpy.size(), 0);
+ QCOMPARE(rowCountSpy.size(), 0);
QCOMPARE(tableView->rows(), 4);
QCOMPARE(tableView->columns(), 2);
}
diff --git a/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp b/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp
index f572016142..736907d5f0 100644
--- a/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp
+++ b/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp
@@ -142,13 +142,13 @@ void tst_qqmltimer::repeat()
timer->setRepeating(false);
QVERIFY(!timer->isRepeating());
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
timer->setRepeating(false);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
timer->setRepeating(true);
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
delete timer;
}
@@ -176,13 +176,13 @@ void tst_qqmltimer::triggeredOnStart()
timer->setTriggeredOnStart(false);
QVERIFY(!timer->triggeredOnStart());
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
timer->setTriggeredOnStart(false);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
timer->setTriggeredOnStart(true);
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
delete timer;
}
@@ -254,13 +254,13 @@ void tst_qqmltimer::changeDuration()
timer->setInterval(200);
QCOMPARE(timer->interval(), 200);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
timer->setInterval(200);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
timer->setInterval(300);
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
delete timer;
}
diff --git a/tests/auto/qml/qqmltranslation/CMakeLists.txt b/tests/auto/qml/qqmltranslation/CMakeLists.txt
index 396eed518e..67047ff604 100644
--- a/tests/auto/qml/qqmltranslation/CMakeLists.txt
+++ b/tests/auto/qml/qqmltranslation/CMakeLists.txt
@@ -18,6 +18,7 @@ qt_internal_add_test(tst_qqmltranslation
Qt::Gui
Qt::GuiPrivate
Qt::QmlPrivate
+ Qt::QmlModelsPrivate
Qt::Quick
Qt::QuickTestUtilsPrivate
TESTDATA ${test_data}
diff --git a/tests/auto/qml/qqmltranslation/data/translatedElements.qml b/tests/auto/qml/qqmltranslation/data/translatedElements.qml
new file mode 100644
index 0000000000..c2edfe8c78
--- /dev/null
+++ b/tests/auto/qml/qqmltranslation/data/translatedElements.qml
@@ -0,0 +1,15 @@
+import QtQml
+import QtQml.Models
+
+DelegateModel {
+ model: ListModel {
+ ListElement { dish: qsTr("soup"); price: 60 }
+ ListElement { dish: qsTr("fish"); price: 100 }
+ ListElement { dish: qsTr("meat"); price: 230 }
+ ListElement { dish: qsTr("bread"); price: 10 }
+ }
+
+ delegate: QtObject {
+ required property string dish
+ }
+}
diff --git a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
index 20d81b352d..e6719e7303 100644
--- a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
+++ b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
@@ -9,6 +9,7 @@
#include <QQuickItem>
#include <private/qqmlengine_p.h>
#include <private/qqmltypedata_p.h>
+#include <private/qqmldelegatemodel_p.h>
#include <QtQuickTestUtils/private/qmlutils_p.h>
class tst_qqmltranslation : public QQmlDataTest
@@ -23,6 +24,7 @@ private slots:
void idTranslation();
void translationChange();
void preferJSContext();
+ void listModel();
};
void tst_qqmltranslation::translation_data()
@@ -170,6 +172,14 @@ class DummyTranslator : public QTranslator
return QString::fromUtf8("Deutsch in mylibrary");
if (!qstrcmp(sourceText, "English in translation") && !qstrcmp(context, "nested_js_translation"))
return QString::fromUtf8("Deutsch in Setzung");
+ if (!qstrcmp(sourceText, "soup"))
+ return QString::fromUtf8("Suppe");
+ if (!qstrcmp(sourceText, "fish"))
+ return QString::fromUtf8("Fisch");
+ if (!qstrcmp(sourceText, "meat"))
+ return QString::fromUtf8("Fleisch");
+ if (!qstrcmp(sourceText, "bread"))
+ return QString::fromUtf8("Brot");
return QString();
}
@@ -231,6 +241,35 @@ void tst_qqmltranslation::preferJSContext()
QCoreApplication::removeTranslator(&translator);
}
+void tst_qqmltranslation::listModel()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("translatedElements.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(o);
+
+ QQmlDelegateModel *model = qobject_cast<QQmlDelegateModel *>(o.data());
+ QVERIFY(model);
+
+ QCOMPARE(model->count(), 4);
+
+ QCOMPARE(model->object(0)->property("dish").toString(), QStringLiteral("soup"));
+ QCOMPARE(model->object(1)->property("dish").toString(), QStringLiteral("fish"));
+ QCOMPARE(model->object(2)->property("dish").toString(), QStringLiteral("meat"));
+ QCOMPARE(model->object(3)->property("dish").toString(), QStringLiteral("bread"));
+
+ DummyTranslator translator;
+ QCoreApplication::installTranslator(&translator);
+ engine.setUiLanguage(QStringLiteral("xxx"));
+ engine.retranslate();
+
+ QCOMPARE(model->object(0)->property("dish").toString(), QStringLiteral("Suppe"));
+ QCOMPARE(model->object(1)->property("dish").toString(), QStringLiteral("Fisch"));
+ QCOMPARE(model->object(2)->property("dish").toString(), QStringLiteral("Fleisch"));
+ QCOMPARE(model->object(3)->property("dish").toString(), QStringLiteral("Brot"));
+}
+
QTEST_MAIN(tst_qqmltranslation)
#include "tst_qqmltranslation.moc"
diff --git a/tests/auto/qml/qqmltreemodeltotablemodel/testmodel.cpp b/tests/auto/qml/qqmltreemodeltotablemodel/testmodel.cpp
index 8bf9561316..58587da79c 100644
--- a/tests/auto/qml/qqmltreemodeltotablemodel/testmodel.cpp
+++ b/tests/auto/qml/qqmltreemodeltotablemodel/testmodel.cpp
@@ -52,7 +52,7 @@ int TestModel::rowCount(const QModelIndex &parent) const
if (!parent.isValid())
return 1; // root of the tree
if (parent.column() == 0)
- return treeItem(parent)->m_childItems.count();
+ return treeItem(parent)->m_childItems.size();
return 0;
}
diff --git a/tests/auto/qml/qqmltreemodeltotablemodel/tst_qqmltreemodeltotablemodel.cpp b/tests/auto/qml/qqmltreemodeltotablemodel/tst_qqmltreemodeltotablemodel.cpp
index 3efc369b57..cd9aed4b30 100644
--- a/tests/auto/qml/qqmltreemodeltotablemodel/tst_qqmltreemodeltotablemodel.cpp
+++ b/tests/auto/qml/qqmltreemodeltotablemodel/tst_qqmltreemodeltotablemodel.cpp
@@ -8,6 +8,10 @@
#include "testmodel.h"
+/*
+ * Note: Out of practical reasons, QQmlTreeModelToTableModel is by and large
+ * tested from tst_qquicktreeview.cpp, where TreeView is available.
+ */
class tst_QQmlTreeModelToTableModel : public QObject {
Q_OBJECT
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
index d28035b266..89e208f441 100644
--- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
+++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
@@ -129,10 +129,10 @@ void tst_QQMLTypeLoader::trimCache()
// The cache is free to keep the others.
}
- for (auto *data : qAsConst(releaseCompilationUnitLater))
+ for (auto *data : std::as_const(releaseCompilationUnitLater))
data->release();
- for (auto *data : qAsConst(releaseLater))
+ for (auto *data : std::as_const(releaseLater))
data->release();
}
@@ -275,8 +275,8 @@ public:
qint64 readData(char *data, qint64 maxlen) override
{
- if (m_buffer.length() < maxlen)
- maxlen = m_buffer.length();
+ if (m_buffer.size() < maxlen)
+ maxlen = m_buffer.size();
std::memcpy(data, m_buffer.data(), maxlen);
m_buffer.remove(0, maxlen);
return maxlen;
@@ -351,9 +351,9 @@ public:
segments.removeFirst();
}
if (segments.startsWith("plugin")) {
- if (segments.length() == 2) {
+ if (segments.size() == 2) {
segments.append(path);
- } else if (segments.length() == 3) {
+ } else if (segments.size() == 3) {
if (!segments[2].startsWith('/'))
segments[2] = path + segments[2];
} else {
@@ -446,7 +446,7 @@ void tst_QQMLTypeLoader::intercept()
QTRY_COMPARE(o->property("created").toInt(), 2);
QTRY_COMPARE(o->property("loaded").toInt(), 2);
- QVERIFY(factory.loadedFiles.length() >= 6);
+ QVERIFY(factory.loadedFiles.size() >= 6);
QVERIFY(factory.loadedFiles.contains(dataDirectory() + "/test_intercept.qml"));
QVERIFY(factory.loadedFiles.contains(dataDirectory() + "/Intercept.qml"));
QVERIFY(factory.loadedFiles.contains(dataDirectory() + "/Fast/qmldir"));
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index f3f9d29b5c..8701fe5696 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -1160,7 +1160,7 @@ static void checkNoErrors(QQmlComponent& component)
QList<QQmlError> errors = component.errors();
if (errors.isEmpty())
return;
- for (int ii = 0; ii < errors.count(); ++ii) {
+ for (int ii = 0; ii < errors.size(); ++ii) {
const QQmlError &error = errors.at(ii);
qWarning("%d:%d:%s",error.line(),error.column(),error.description().toUtf8().constData());
}
@@ -1690,8 +1690,8 @@ void tst_qqmlvaluetypes::sequences()
{
QList<BaseGadget> gadgetList{1, 4, 7, 8, 15};
QJSValue value = engine.toScriptValue(gadgetList);
- QCOMPARE(value.property("length").toInt(), gadgetList.length());
- for (int i = 0; i < gadgetList.length(); ++i)
+ QCOMPARE(value.property("length").toInt(), gadgetList.size());
+ for (int i = 0; i < gadgetList.size(); ++i)
QCOMPARE(value.property(i).property("baseProperty").toInt(), gadgetList.at(i).baseProperty());
}
{
@@ -1704,8 +1704,8 @@ void tst_qqmlvaluetypes::sequences()
{
QVector<QChar> qcharVector{QChar(1), QChar(4), QChar(42), QChar(8), QChar(15)};
QJSValue value = engine.toScriptValue(qcharVector);
- QCOMPARE(value.property("length").toInt(), qcharVector.length());
- for (int i = 0; i < qcharVector.length(); ++i)
+ QCOMPARE(value.property("length").toInt(), qcharVector.size());
+ for (int i = 0; i < qcharVector.size(); ++i)
QCOMPARE(value.property(i).toString(), qcharVector.at(i));
}
{
@@ -1767,7 +1767,7 @@ void tst_qqmlvaluetypes::enumerableProperties()
names.insert(name);
}
- QCOMPARE(names.count(), 2);
+ QCOMPARE(names.size(), 2);
QVERIFY(names.contains(QStringLiteral("baseProperty")));
QVERIFY(names.contains(QStringLiteral("derivedProperty")));
}
diff --git a/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp b/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp
index ae4dcbef02..05b8ce605d 100644
--- a/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp
+++ b/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp
@@ -79,7 +79,7 @@ private:
const QStringList fields = item.split(QLatin1Char(','));
for (const QString &field : fields) {
QStringList values = field.split(QLatin1Char('='));
- if (values.count() != 2) {
+ if (values.size() != 2) {
qWarning() << "makeItemXmlAndData: invalid field:" << field;
continue;
}
@@ -235,7 +235,7 @@ void tst_QQmlXmlListModel::roles()
QTRY_COMPARE(model->rowCount(), 9);
QHash<int, QByteArray> roleNames = model->roleNames();
- QCOMPARE(roleNames.count(), 4);
+ QCOMPARE(roleNames.size(), 4);
QVERIFY(roleNames.key("name", -1) >= 0);
QVERIFY(roleNames.key("type", -1) >= 0);
QVERIFY(roleNames.key("age", -1) >= 0);
@@ -246,7 +246,7 @@ void tst_QQmlXmlListModel::roles()
roles.insert(roleNames.key("type"));
roles.insert(roleNames.key("age"));
roles.insert(roleNames.key("size"));
- QCOMPARE(roles.count(), 4);
+ QCOMPARE(roles.size(), 4);
}
void tst_QQmlXmlListModel::elementErrors()
@@ -294,7 +294,7 @@ void tst_QQmlXmlListModel::uniqueRoleNames()
QTRY_COMPARE(model->rowCount(), 9);
QHash<int, QByteArray> roleNames = model->roleNames();
- QCOMPARE(roleNames.count(), 1);
+ QCOMPARE(roleNames.size(), 1);
}
void tst_QQmlXmlListModel::headers()
@@ -313,7 +313,7 @@ void tst_QQmlXmlListModel::headers()
QQmlXmlListModel::Ready);
// It doesn't do a network request for a local file
- QCOMPARE(factory.lastSentHeaders.count(), 0);
+ QCOMPARE(factory.lastSentHeaders.size(), 0);
model->setProperty("source", QUrl("http://localhost/filethatdoesnotexist.xml"));
QTRY_COMPARE_WITH_TIMEOUT(qvariant_cast<QQmlXmlListModel::Status>(model->property("status")),
@@ -322,7 +322,7 @@ void tst_QQmlXmlListModel::headers()
QVariantMap expectedHeaders;
expectedHeaders["Accept"] = "application/xml,*/*";
- QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count());
+ QCOMPARE(factory.lastSentHeaders.size(), expectedHeaders.size());
for (auto it = expectedHeaders.cbegin(), end = expectedHeaders.cend(); it != end; ++it) {
QVERIFY(factory.lastSentHeaders.contains(it.key()));
QCOMPARE(factory.lastSentHeaders[it.key()].toString(), it.value().toString());
@@ -345,7 +345,7 @@ void tst_QQmlXmlListModel::source()
QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
QCOMPARE(qvariant_cast<QQmlXmlListModel::Status>(model->property("status")),
QQmlXmlListModel::Loading);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
spy.clear();
QCOMPARE(qvariant_cast<QQmlXmlListModel::Status>(model->property("status")),
QQmlXmlListModel::Ready);
@@ -359,7 +359,7 @@ void tst_QQmlXmlListModel::source()
QQmlXmlListModel::Null);
qreal expectedProgress = (source.isLocalFile() || (source.scheme() == "qrc"_L1)) ? 1.0 : 0.0;
QCOMPARE(model->property("progress").toDouble(), expectedProgress);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
spy.clear();
QCOMPARE(qvariant_cast<QQmlXmlListModel::Status>(model->property("status")),
QQmlXmlListModel::Loading);
@@ -373,10 +373,10 @@ void tst_QQmlXmlListModel::source()
timer.start(20000);
loop.exec();
- if (spy.count() == 0 && status != QQmlXmlListModel::Ready) {
+ if (spy.size() == 0 && status != QQmlXmlListModel::Ready) {
qWarning("QQmlXmlListModel invalid source test timed out");
} else {
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
}
@@ -415,7 +415,7 @@ void tst_QQmlXmlListModel::data()
for (int i = 0; i < 9; i++) {
QModelIndex index = model->index(i, 0);
- for (int j = 0; j < model->roleNames().count(); j++) {
+ for (int j = 0; j < model->roleNames().size(); j++) {
QCOMPARE(model->data(index, j), QVariant());
}
}
@@ -442,9 +442,9 @@ void tst_QQmlXmlListModel::reload()
QCoreApplication::processEvents();
QMetaObject::invokeMethod(model.get(), "reload");
QMetaObject::invokeMethod(model.get(), "reload");
- QTRY_COMPARE(spyCount.count(), 0);
- QTRY_COMPARE(spyInsert.count(), 1);
- QTRY_COMPARE(spyRemove.count(), 1);
+ QTRY_COMPARE(spyCount.size(), 0);
+ QTRY_COMPARE(spyInsert.size(), 1);
+ QTRY_COMPARE(spyRemove.size(), 1);
QCOMPARE(spyInsert[0][1].toInt(), 0);
QCOMPARE(spyInsert[0][2].toInt(), 8);
@@ -557,14 +557,14 @@ void tst_QQmlXmlListModel::propertyChanges()
QCOMPARE(role->property("name").toString(), QString("size"));
QCOMPARE(role->property("elementName").toString(), QString("size"));
- QCOMPARE(nameSpy.count(), 1);
- QCOMPARE(elementSpy.count(), 1);
+ QCOMPARE(nameSpy.size(), 1);
+ QCOMPARE(elementSpy.size(), 1);
role->setProperty("name", "size");
role->setProperty("elementName", "size");
- QCOMPARE(nameSpy.count(), 1);
- QCOMPARE(elementSpy.count(), 1);
+ QCOMPARE(nameSpy.size(), 1);
+ QCOMPARE(elementSpy.size(), 1);
QSignalSpy sourceSpy(model.get(), SIGNAL(sourceChanged()));
QSignalSpy modelQuerySpy(model.get(), SIGNAL(queryChanged()));
@@ -577,14 +577,14 @@ void tst_QQmlXmlListModel::propertyChanges()
QTRY_COMPARE(model->rowCount(), 1);
- QCOMPARE(sourceSpy.count(), 1);
- QCOMPARE(modelQuerySpy.count(), 1);
+ QCOMPARE(sourceSpy.size(), 1);
+ QCOMPARE(modelQuerySpy.size(), 1);
model->setProperty("source", QUrl("model2.xml"));
model->setProperty("query", "/Pets");
- QCOMPARE(sourceSpy.count(), 1);
- QCOMPARE(modelQuerySpy.count(), 1);
+ QCOMPARE(sourceSpy.size(), 1);
+ QCOMPARE(modelQuerySpy.size(), 1);
QTRY_COMPARE(model->rowCount(), 1);
}
diff --git a/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp b/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp
index b98e1e9da3..7e9e070fa6 100644
--- a/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp
+++ b/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp
@@ -76,7 +76,7 @@ void tst_QV4Assembler::perfMapFile()
const QByteArray contents = file.readLine();
QVERIFY(contents.endsWith('\n'));
QList<QByteArray> fields = contents.split(' ');
- QCOMPARE(fields.length(), 3);
+ QCOMPARE(fields.size(), 3);
bool ok = false;
const qulonglong address = fields[0].toULongLong(&ok, 16);
QVERIFY(ok);
diff --git a/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp b/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp
index d994783e1f..a3f5c4bb70 100644
--- a/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp
+++ b/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp
@@ -341,7 +341,7 @@ void tst_qv4identifiertable::insertNumericStringPopulatesIdentifier()
QV4::ExecutionEngine engine;
const QString numeric = QStringLiteral("1");
uint subtype;
- const uint hash = QV4::String::createHashValue(numeric.constData(), numeric.length(), &subtype);
+ const uint hash = QV4::String::createHashValue(numeric.constData(), numeric.size(), &subtype);
QCOMPARE(subtype, QV4::Heap::String::StringType_ArrayIndex);
QCOMPARE(engine.identifierTable->insertString(numeric)->identifier,
QV4::PropertyKey::fromArrayIndex(hash));
diff --git a/tests/auto/qmldom/domdata/domitem/test1.qml b/tests/auto/qmldom/domdata/domitem/test1.qml
index 36c1284978..4a28129ee9 100644
--- a/tests/auto/qmldom/domdata/domitem/test1.qml
+++ b/tests/auto/qmldom/domdata/domitem/test1.qml
@@ -1,4 +1,5 @@
-import QtQuick 2.15
+import QtQuick
+import QtQuick as QQ
Window {
visible: true
diff --git a/tests/auto/qmldom/domdata/reformatter/typeAnnotations.qml b/tests/auto/qmldom/domdata/reformatter/typeAnnotations.qml
new file mode 100644
index 0000000000..63c4f5471c
--- /dev/null
+++ b/tests/auto/qmldom/domdata/reformatter/typeAnnotations.qml
@@ -0,0 +1,12 @@
+import QtQuick
+
+Item {
+function calculateWidth(object: Item<a>): list<Item> {
+var w = object.width / 3
+// ...
+// more javascript code
+// ...
+console.debug(w)
+return w
+}
+}
diff --git a/tests/auto/qmldom/domdata/reformatter/typeAnnotationsReformatted.qml b/tests/auto/qmldom/domdata/reformatter/typeAnnotationsReformatted.qml
new file mode 100644
index 0000000000..3b304176fb
--- /dev/null
+++ b/tests/auto/qmldom/domdata/reformatter/typeAnnotationsReformatted.qml
@@ -0,0 +1,12 @@
+import QtQuick
+
+Item {
+ function calculateWidth(object: Item<a>): list<Item> {
+ var w = object.width / 3;
+ // ...
+ // more javascript code
+ // ...
+ console.debug(w);
+ return w;
+ }
+}
diff --git a/tests/auto/qmldom/domitem/tst_qmldomitem.h b/tests/auto/qmldom/domitem/tst_qmldomitem.h
index fab95c4e1e..433a92a2b2 100644
--- a/tests/auto/qmldom/domitem/tst_qmldomitem.h
+++ b/tests/auto/qmldom/domitem/tst_qmldomitem.h
@@ -292,7 +292,7 @@ private slots:
QVERIFY(didAdd2);
RefCacheEntry e2 = RefCacheEntry::forPath(env, refPath);
QCOMPARE(e2.cached, RefCacheEntry::Cached::First);
- QCOMPARE(e2.canonicalPaths.length(), 1);
+ QCOMPARE(e2.canonicalPaths.size(), 1);
QCOMPARE(e2.canonicalPaths.first().toString(), env.canonicalPath().toString());
bool didAdd3 = RefCacheEntry::addForPath(
env, refPath,
@@ -302,7 +302,7 @@ private slots:
QVERIFY(didAdd3);
RefCacheEntry e3 = RefCacheEntry::forPath(env, refPath);
QCOMPARE(e3.cached, RefCacheEntry::Cached::All);
- QCOMPARE(e3.canonicalPaths.length(), 2);
+ QCOMPARE(e3.canonicalPaths.size(), 2);
QCOMPARE(e3.canonicalPaths.first().toString(), env.canonicalPath().toString());
QCOMPARE(e3.canonicalPaths.last().toString(), tOwner.canonicalPath().toString());
}
@@ -457,18 +457,18 @@ private slots:
const PropertyInfo *p1 =
reinterpret_cast<const PropertyInfo *>(wrappedPInfoPtr->m_value.data());
PropertyInfo p2 = wrappedPInfoPtr->m_value.value<PropertyInfo>();
- QCOMPARE(mPInfo.bindings.length(), 1);
- QCOMPARE(mPInfo.propertyDefs.length(), 1);
+ QCOMPARE(mPInfo.bindings.size(), 1);
+ QCOMPARE(mPInfo.propertyDefs.size(), 1);
QCOMPARE(mPInfo.bindings.first().toString(), mPInfo.bindings.first().toString());
QCOMPARE(mPInfo.propertyDefs.first().toString(),
mPInfo.propertyDefs.first().toString());
- QCOMPARE(p2.bindings.length(), 1);
- QCOMPARE(p2.propertyDefs.length(), 1);
+ QCOMPARE(p2.bindings.size(), 1);
+ QCOMPARE(p2.propertyDefs.size(), 1);
QCOMPARE(p2.bindings.first().toString(), mPInfo.bindings.first().toString());
QCOMPARE(p2.propertyDefs.first().toString(), mPInfo.propertyDefs.first().toString());
- QCOMPARE(p1->bindings.length(), 1);
- QCOMPARE(p1->propertyDefs.length(), 1);
+ QCOMPARE(p1->bindings.size(), 1);
+ QCOMPARE(p1->propertyDefs.size(), 1);
QCOMPARE(p1->bindings.first().toString(), mPInfo.bindings.first().toString());
QCOMPARE(p1->propertyDefs.first().toString(), mPInfo.propertyDefs.first().toString());
}
@@ -517,10 +517,15 @@ private slots:
obj1.lookup(u"Rectangle"_s, LookupType::Type, LookupOption::Normal);
QList<DomItem> rect2 =
obj1.lookup(u"Rectangle"_s, LookupType::Symbol, LookupOption::Normal);
- QVERIFY(rect.length() == 1);
- QVERIFY(rect2.length() == 1);
+ QList<DomItem> rectAs =
+ obj1.lookup(u"QQ.Rectangle"_s, LookupType::Symbol, LookupOption::Normal);
+
+ QVERIFY(rect.size() == 1);
+ QVERIFY(rect2.size() == 1);
+ QVERIFY(rectAs.size() == 1);
QCOMPARE(rect.first().internalKind(), DomType::Export);
QCOMPARE(rect.first(), rect2.first());
+ QCOMPARE(rect.first(), rectAs.first());
DomItem rect3 = rect.first().proceedToScope();
QCOMPARE(rect3.internalKind(), DomType::QmlObject);
QList<DomItem> rects;
@@ -531,7 +536,7 @@ private slots:
return true;
},
{});
- QVERIFY(rects.length() == 1);
+ QVERIFY(rects.size() == 1);
for (DomItem &el : rects) {
QCOMPARE(rect.first(), el);
}
diff --git a/tests/auto/qmldom/path/tst_qmldompath.h b/tests/auto/qmldom/path/tst_qmldompath.h
index 565bab713e..24d8c30bcf 100644
--- a/tests/auto/qmldom/path/tst_qmldompath.h
+++ b/tests/auto/qmldom/path/tst_qmldompath.h
@@ -28,9 +28,9 @@ public:
QCOMPARE(p11, p2);
QCOMPARE(p11, p3);
QVERIFY(p11.m_data->strData.isEmpty());
- QCOMPARE(p2.m_data->strData.length(), 1);
+ QCOMPARE(p2.m_data->strData.size(), 1);
QCOMPARE(p2.m_data->strData.first(), s);
- QCOMPARE(p3.m_data->strData.length(), 1);
+ QCOMPARE(p3.m_data->strData.size(), 1);
QCOMPARE(p3.m_data->strData.first(), s);
}
diff --git a/tests/auto/qmldom/reformatter/tst_reformatter.h b/tests/auto/qmldom/reformatter/tst_reformatter.h
index 1fc18e0452..0b43d24763 100644
--- a/tests/auto/qmldom/reformatter/tst_reformatter.h
+++ b/tests/auto/qmldom/reformatter/tst_reformatter.h
@@ -57,6 +57,10 @@ private slots:
QTest::newRow("template") << QStringLiteral(u"template.qml")
<< QStringLiteral(u"templateReformatted.qml") << defaultOptions;
+ QTest::newRow("typeAnnotations")
+ << QStringLiteral(u"typeAnnotations.qml")
+ << QStringLiteral(u"typeAnnotationsReformatted.qml") << defaultOptions;
+
QTest::newRow("arrowFunctions")
<< QStringLiteral(u"arrowFunctions.qml")
<< QStringLiteral(u"arrowFunctionsReformatted.qml") << defaultOptions;
diff --git a/tests/auto/qmlls/completions/data/completions/Yyy.qml b/tests/auto/qmlls/completions/data/completions/Yyy.qml
index b07fb9822e..dc1125c6ad 100644
--- a/tests/auto/qmlls/completions/data/completions/Yyy.qml
+++ b/tests/auto/qmlls/completions/data/completions/Yyy.qml
@@ -1,4 +1,5 @@
import QtQuick 2.0
+import QtQuick as QQ
Zzz {
id: root
@@ -13,4 +14,8 @@ Zzz {
function lala() {}
property Rectangle foo: Rectangle{ height: 200 }
+
+ QQ.Rectangle {
+ color:"red"
+ }
}
diff --git a/tests/auto/qmlls/completions/tst_qmllscompletions.cpp b/tests/auto/qmlls/completions/tst_qmllscompletions.cpp
index e10b400887..03746589dc 100644
--- a/tests/auto/qmlls/completions/tst_qmllscompletions.cpp
+++ b/tests/auto/qmlls/completions/tst_qmllscompletions.cpp
@@ -128,7 +128,7 @@ void tst_QmllsCompletions::completions_data()
QByteArray uri = testFileUrl("completions/Yyy.qml").toString().toUtf8();
- QTest::newRow("objEmptyLine") << uri << 7 << 0
+ QTest::newRow("objEmptyLine") << uri << 8 << 0
<< ExpectedCompletions({
{ u"Rectangle"_s, CompletionItemKind::Class },
{ u"property"_s, CompletionItemKind::Keyword },
@@ -137,7 +137,7 @@ void tst_QmllsCompletions::completions_data()
})
<< QStringList({ u"QtQuick"_s, u"vector4d"_s });
- QTest::newRow("inBindingLabel") << uri << 4 << 9
+ QTest::newRow("inBindingLabel") << uri << 5 << 9
<< ExpectedCompletions({
{ u"Rectangle"_s, CompletionItemKind::Class },
{ u"property"_s, CompletionItemKind::Keyword },
@@ -145,7 +145,7 @@ void tst_QmllsCompletions::completions_data()
})
<< QStringList({ u"QtQuick"_s, u"vector4d"_s });
- QTest::newRow("afterBinding") << uri << 4 << 10
+ QTest::newRow("afterBinding") << uri << 5 << 10
<< ExpectedCompletions({
{ u"Rectangle"_s, CompletionItemKind::Field },
{ u"width"_s, CompletionItemKind::Field },
@@ -154,7 +154,7 @@ void tst_QmllsCompletions::completions_data()
<< QStringList({ u"QtQuick"_s, u"property"_s });
// suppress?
- QTest::newRow("afterId") << uri << 3 << 7
+ QTest::newRow("afterId") << uri << 4 << 7
<< ExpectedCompletions({
{ u"import"_s, CompletionItemKind::Keyword },
})
@@ -197,7 +197,7 @@ void tst_QmllsCompletions::completions_data()
// })
// << QStringList({ u"as"_s, u"Rectangle"_s, u"import"_s, u"vector4d"_s, u"width"_s });
- QTest::newRow("inScript") << uri << 5 << 14
+ QTest::newRow("inScript") << uri << 6 << 14
<< ExpectedCompletions({
{ u"Rectangle"_s, CompletionItemKind::Field },
{ u"vector4d"_s, CompletionItemKind::Field },
@@ -206,19 +206,26 @@ void tst_QmllsCompletions::completions_data()
})
<< QStringList({ u"import"_s });
- QTest::newRow("expandBase1") << uri << 8 << 23
+ QTest::newRow("expandBase1") << uri << 9 << 23
<< ExpectedCompletions({
{ u"width"_s, CompletionItemKind::Field },
{ u"foo"_s, CompletionItemKind::Field },
})
<< QStringList({ u"import"_s, u"Rectangle"_s });
- QTest::newRow("expandBase2") << uri << 9 << 29
+ QTest::newRow("expandBase2") << uri << 10 << 29
<< ExpectedCompletions({
{ u"width"_s, CompletionItemKind::Field },
{ u"color"_s, CompletionItemKind::Field },
})
<< QStringList({ u"foo"_s, u"import"_s, u"Rectangle"_s });
+
+ QTest::newRow("asCompletions")
+ << uri << 17 << 8
+ << ExpectedCompletions({
+ { u"Rectangle"_s, CompletionItemKind::Field },
+ })
+ << QStringList({ u"foo"_s, u"import"_s, u"lala()"_s, u"width"_s });
}
void tst_QmllsCompletions::checkCompletions(QByteArray uri, int lineNr, int character,
diff --git a/tests/auto/qmlls/lifecycle/qiopipe.cpp b/tests/auto/qmlls/lifecycle/qiopipe.cpp
index a3ca36ae24..416fe8257d 100644
--- a/tests/auto/qmlls/lifecycle/qiopipe.cpp
+++ b/tests/auto/qmlls/lifecycle/qiopipe.cpp
@@ -87,7 +87,7 @@ bool QPipeEndPoint::isSequential() const
qint64 QPipeEndPoint::bytesAvailable() const
{
- return m_buffer.length() + QIODevice::bytesAvailable();
+ return m_buffer.size() + QIODevice::bytesAvailable();
}
void QPipeEndPoint::setRemoteEndPoint(QPipeEndPoint *other)
@@ -97,7 +97,7 @@ void QPipeEndPoint::setRemoteEndPoint(QPipeEndPoint *other)
qint64 QPipeEndPoint::readData(char *data, qint64 maxlen)
{
- maxlen = qMin(maxlen, static_cast<qint64>(m_buffer.length()));
+ maxlen = qMin(maxlen, static_cast<qint64>(m_buffer.size()));
if (maxlen <= 0)
return 0;
@@ -116,7 +116,7 @@ qint64 QPipeEndPoint::writeData(const char *data, qint64 len)
return 0;
QByteArray &buffer = m_remoteEndPoint->m_buffer;
- const qint64 prevLen = buffer.length();
+ const qint64 prevLen = buffer.size();
Q_ASSERT(prevLen >= 0);
len = qMin(len, std::numeric_limits<int>::max() - prevLen);
diff --git a/tests/auto/qmlls/qmlls/tst_qmlls.cpp b/tests/auto/qmlls/qmlls/tst_qmlls.cpp
index 1cfa734018..2c7a76626d 100644
--- a/tests/auto/qmlls/qmlls/tst_qmlls.cpp
+++ b/tests/auto/qmlls/qmlls/tst_qmlls.cpp
@@ -43,7 +43,7 @@ public:
int num = 0;
for (const auto &params : m_received) {
if (params.uri == uri)
- num += params.diagnostics.length();
+ num += params.diagnostics.size();
}
return num;
}
diff --git a/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml b/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml
index ec3387a38b..a54e5f1e7b 100644
--- a/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml
+++ b/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml
@@ -25,6 +25,8 @@ TestCase {
}
function init() {
+ failOnWarning(/.?/)
+
// The items are destroyed after cleanup(), so we check here after every test,
// and once for the last test in cleanupTestCase().
verifyNoChildren();
@@ -125,7 +127,8 @@ TestCase {
{ tag: "omit", expectedParent: null },
{ tag: "undefined", parent: undefined, expectedParent: null },
{ tag: "null", parent: null, expectedParent: null },
- { tag: "1", parent: 1, expectedParent: null },
+ { tag: "1", parent: 1, expectedParent: null,
+ ignoreWarning: /.*Unsuitable arguments passed to createObject.*/ },
{ tag: "testCase", parent: testCase, expectedParent: testCase }
];
}
@@ -133,6 +136,10 @@ TestCase {
// Tests that an invalid or missing parent argument results in a parentless object.
// This is the same behavior as displayed by component.createObject().
function test_fromComponentParent(data) {
+ // ignoreWarning takes precedence over failOnWarning (which we call in init()).
+ if (data.hasOwnProperty("ignoreWarning"))
+ ignoreWarning(data.ignoreWarning)
+
var object = data.hasOwnProperty("parent")
? createTemporaryObject(itemComponent, data.parent)
: createTemporaryObject(itemComponent);
diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp
index c56cad7d90..3127784f6a 100644
--- a/tests/auto/quick/examples/tst_examples.cpp
+++ b/tests/auto/quick/examples/tst_examples.cpp
@@ -62,6 +62,7 @@ tst_examples::tst_examples()
excludedDirs << "snippets/qml/imports";
excludedDirs << "examples/quickcontrols2/imagine";
excludedDirs << "examples/quickcontrols2/texteditor";
+ excludedDirs << "examples/quickcontrols2/ios/todolist"; // Must be run via executable.
excludedFiles << "snippets/qml/image-ext.qml";
excludedFiles << "examples/quick/shapes/content/main.qml"; // relies on resources
excludedFiles << "examples/quick/shapes/content/interactive.qml"; // relies on resources
@@ -102,7 +103,7 @@ to have them tested by the examples() test.
*/
void tst_examples::namingConvention(const QDir &d)
{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
+ for (int ii = 0; ii < excludedDirs.size(); ++ii) {
QString s = excludedDirs.at(ii);
if (d.absolutePath().endsWith(s))
return;
@@ -156,7 +157,7 @@ void tst_examples::namingConvention()
QStringList tst_examples::findQmlFiles(const QDir &d)
{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
+ for (int ii = 0; ii < excludedDirs.size(); ++ii) {
QString s = excludedDirs.at(ii);
if (d.absolutePath().endsWith(s))
return QStringList();
@@ -171,7 +172,7 @@ QStringList tst_examples::findQmlFiles(const QDir &d)
foreach (const QString &file, files) {
if (file.at(0).isLower()) {
bool superContinue = false;
- for (int ii = 0; ii < excludedFiles.count(); ++ii) {
+ for (int ii = 0; ii < excludedFiles.size(); ++ii) {
QString e = excludedFiles.at(ii);
if (d.absoluteFilePath(file).endsWith(e)) {
superContinue = true;
@@ -222,7 +223,7 @@ void tst_examples::sgexamples_data()
QStringList files;
files << findQmlFiles(examplesDir);
- for (const QString &file : qAsConst(files))
+ for (const QString &file : std::as_const(files))
QTest::newRow(qPrintable(repoSourceDir.relativeFilePath(file))) << file;
}
@@ -272,7 +273,7 @@ void tst_examples::sgsnippets_data()
QStringList files;
files << findQmlFiles(snippetsDir);
- for (const QString &file : qAsConst(files))
+ for (const QString &file : std::as_const(files))
QTest::newRow(qPrintable(repoSourceDir.relativeFilePath(file))) << file;
// Add Quick snippets.
@@ -282,7 +283,7 @@ void tst_examples::sgsnippets_data()
files.clear();
files << findQmlFiles(snippetsDir);
- for (const QString &file : qAsConst(files))
+ for (const QString &file : std::as_const(files))
QTest::newRow(qPrintable(repoSourceDir.relativeFilePath(file))) << file;
}
diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/BLACKLIST b/tests/auto/quick/pointerhandlers/flickableinterop/BLACKLIST
index 5c5f2c9ed9..4e54331470 100644
--- a/tests/auto/quick/pointerhandlers/flickableinterop/BLACKLIST
+++ b/tests/auto/quick/pointerhandlers/flickableinterop/BLACKLIST
@@ -26,3 +26,6 @@ android
android
[touchAndDragHandlerOnFlickable]
android
+# QTBUG-113226
+[pinchHandlerOnFlickable]
+*
diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp
index 84cfe0e7fd..7a0206c04f 100644
--- a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp
+++ b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp
@@ -103,7 +103,7 @@ void tst_FlickableInterop::touchTapButton()
QTest::touchEvent(window, touchDevice).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!button->property("pressed").toBool());
- QCOMPARE(tappedSpy.count(), 1);
+ QCOMPARE(tappedSpy.size(), 1);
// We can drag <= dragThreshold and the button still acts normal, Flickable doesn't grab
p1 = button->mapToScene(QPointF(20, 20)).toPoint();
@@ -117,7 +117,7 @@ void tst_FlickableInterop::touchTapButton()
QTest::touchEvent(window, touchDevice).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!button->property("pressed").toBool());
- QCOMPARE(tappedSpy.count(), 2);
+ QCOMPARE(tappedSpy.size(), 2);
}
void tst_FlickableInterop::touchDragFlickableBehindButton_data()
@@ -167,7 +167,7 @@ void tst_FlickableInterop::touchDragFlickableBehindButton()
QTest::touchEvent(window, touchDevice).release(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(!button->property("pressed").toBool());
- QCOMPARE(tappedSpy.count(), 0);
+ QCOMPARE(tappedSpy.size(), 0);
}
void tst_FlickableInterop::mouseClickButton_data()
@@ -197,7 +197,7 @@ void tst_FlickableInterop::mouseClickButton()
QTRY_VERIFY(button->property("pressed").toBool());
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
QTRY_VERIFY(!button->property("pressed").toBool());
- QCOMPARE(tappedSpy.count(), 1);
+ QCOMPARE(tappedSpy.size(), 1);
// We can drag <= dragThreshold and the button still acts normal, Flickable doesn't grab
p1 = button->mapToScene(QPointF(20, 20)).toPoint();
@@ -208,7 +208,7 @@ void tst_FlickableInterop::mouseClickButton()
QVERIFY(button->property("pressed").toBool());
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
QTRY_VERIFY(!button->property("pressed").toBool());
- QCOMPARE(tappedSpy.count(), 2);
+ QCOMPARE(tappedSpy.size(), 2);
}
void tst_FlickableInterop::mouseDragFlickableBehindButton_data()
@@ -254,7 +254,7 @@ void tst_FlickableInterop::mouseDragFlickableBehindButton()
QVERIFY(!button->property("pressed").toBool());
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
QVERIFY(!button->property("pressed").toBool());
- QCOMPARE(tappedSpy.count(), 0);
+ QCOMPARE(tappedSpy.size(), 0);
}
void tst_FlickableInterop::touchDragSlider()
@@ -306,8 +306,8 @@ void tst_FlickableInterop::touchDragSlider()
// Release, and do not expect the tapped signal
QTest::touchEvent(window, touchDevice).release(1, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(tappedSpy.count(), 0);
- QCOMPARE(translationChangedSpy.count(), 1);
+ QCOMPARE(tappedSpy.size(), 0);
+ QCOMPARE(translationChangedSpy.size(), 1);
}
void tst_FlickableInterop::mouseDragSlider_data()
@@ -391,8 +391,8 @@ void tst_FlickableInterop::mouseDragSlider()
// Release, and do not expect the tapped signal
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
- QCOMPARE(tappedSpy.count(), 0);
- QCOMPARE(translationChangedSpy.count(), expectedDragHandlerActive ? 1 : 0);
+ QCOMPARE(tappedSpy.size(), 0);
+ QCOMPARE(translationChangedSpy.size(), expectedDragHandlerActive ? 1 : 0);
}
void tst_FlickableInterop::touchDragFlickableBehindSlider()
@@ -437,8 +437,8 @@ void tst_FlickableInterop::touchDragFlickableBehindSlider()
QTest::touchEvent(window, touchDevice).release(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(!slider->property("pressed").toBool());
- QCOMPARE(tappedSpy.count(), 0);
- QCOMPARE(translationChangedSpy.count(), 0);
+ QCOMPARE(tappedSpy.size(), 0);
+ QCOMPARE(translationChangedSpy.size(), 0);
}
void tst_FlickableInterop::mouseDragFlickableBehindSlider()
@@ -479,8 +479,8 @@ void tst_FlickableInterop::mouseDragFlickableBehindSlider()
QCOMPARE(i, 2);
QVERIFY(!slider->property("pressed").toBool());
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
- QCOMPARE(tappedSpy.count(), 0);
- QCOMPARE(translationChangedSpy.count(), 0);
+ QCOMPARE(tappedSpy.size(), 0);
+ QCOMPARE(translationChangedSpy.size(), 0);
}
void tst_FlickableInterop::touchDragFlickableBehindItemWithHandlers_data()
diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp b/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
index c4059a1fbd..723ad0b63e 100644
--- a/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
+++ b/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
@@ -178,11 +178,11 @@ void tst_MouseAreaInterop::hoverHandlerDoesntHoverOnPress() // QTBUG-72843
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p);
QTRY_COMPARE(ma->pressed(), true);
QCOMPARE(handler->isHovered(), true);
- QCOMPARE(hoveredChangedSpy.count(), 0);
+ QCOMPARE(hoveredChangedSpy.size(), 0);
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p);
QTRY_COMPARE(ma->pressed(), false);
QCOMPARE(handler->isHovered(), true);
- QCOMPARE(hoveredChangedSpy.count(), 0);
+ QCOMPARE(hoveredChangedSpy.size(), 0);
}
void tst_MouseAreaInterop::doubleClickInMouseAreaWithDragHandlerInGrandparent()
@@ -199,8 +199,8 @@ void tst_MouseAreaInterop::doubleClickInMouseAreaWithDragHandlerInGrandparent()
QPoint p = ma->mapToScene(ma->boundingRect().center()).toPoint();
QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p);
- QCOMPARE(dClickSpy.count(), 1);
- QCOMPARE(dragActiveSpy.count(), 0);
+ QCOMPARE(dClickSpy.size(), 1);
+ QCOMPARE(dragActiveSpy.size(), 0);
}
QTEST_MAIN(tst_MouseAreaInterop)
diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
index f2c6ce5ee6..0aa96b6c59 100644
--- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
+++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
@@ -145,7 +145,7 @@ void tst_MptaInterop::touchesThenPinch()
QQuickTouchUtils::flush(window);
QVERIFY(tp.at(0)->property("pressed").toBool());
QTRY_VERIFY(tp.at(1)->property("pressed").toBool());
- QCOMPARE(mptaPressedSpy.count(), 2);
+ QCOMPARE(mptaPressedSpy.size(), 2);
// Press a third touchpoint: MPTA grabs it too
QPoint p3 = mpta->mapToScene(QPointF(110, 200)).toPoint();
@@ -154,8 +154,8 @@ void tst_MptaInterop::touchesThenPinch()
QCOMPARE(tp.at(0)->property("pressed").toBool(), true);
QCOMPARE(tp.at(1)->property("pressed").toBool(), true);
QCOMPARE(tp.at(2)->property("pressed").toBool(), true);
- QCOMPARE(mptaPressedSpy.count(), 3);
- QCOMPARE(mptaCanceledSpy.count(), 0);
+ QCOMPARE(mptaPressedSpy.size(), 3);
+ QCOMPARE(mptaCanceledSpy.size(), 0);
QCOMPARE(devPriv->pointById(1)->exclusiveGrabber, mpta);
QCOMPARE(devPriv->pointById(2)->exclusiveGrabber, mpta);
QCOMPARE(devPriv->pointById(3)->exclusiveGrabber, mpta);
@@ -254,7 +254,7 @@ void tst_MptaInterop::touchesThenPinch()
touch.release(2, p2).commit();
QQuickTouchUtils::flush(window);
- QTRY_COMPARE(mptaReleasedSpy.count(), 1);
+ QTRY_COMPARE(mptaReleasedSpy.size(), 1);
}
void tst_MptaInterop::unloadHandlerWithPassiveGrab()
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
index 1f8b73a919..b6e4cec3af 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
@@ -153,21 +153,21 @@ void tst_DragHandler::touchDrag()
QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos);
QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
QCOMPARE(dragHandler->centroid().velocity(), QVector2D());
- QCOMPARE(centroidChangedSpy.count(), 1);
+ QCOMPARE(centroidChangedSpy.size(), 1);
p1 += QPoint(dragThreshold, 0);
QTest::touchEvent(window, touchDevice).move(1, p1, window);
QQuickTouchUtils::flush(window);
qCDebug(lcPointerTests) << "velocity after drag" << dragHandler->centroid().velocity();
if (dragThreshold > 0)
QTRY_VERIFY(!qFuzzyIsNull(dragHandler->centroid().velocity().x()));
- QCOMPARE(centroidChangedSpy.count(), 2);
+ QCOMPARE(centroidChangedSpy.size(), 2);
QVERIFY(!dragHandler->active());
p1 += QPoint(1, 0);
QTest::touchEvent(window, touchDevice).move(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(dragHandler->active());
- QCOMPARE(translationChangedSpy.count(), 0);
- QCOMPARE(centroidChangedSpy.count(), 3);
+ QCOMPARE(translationChangedSpy.size(), 0);
+ QCOMPARE(centroidChangedSpy.size(), 3);
QCOMPARE(dragHandler->persistentTranslation().x(), 0);
QCOMPARE(dragHandler->activeTranslation().x(), 0);
QPointF sceneGrabPos = p1;
@@ -186,15 +186,15 @@ void tst_DragHandler::touchDrag()
QCOMPARE(dragHandler->persistentTranslation().y(), 0);
QCOMPARE(dragHandler->activeTranslation().y(), 0);
QVERIFY(dragHandler->centroid().velocity().x() > 0);
- QCOMPARE(centroidChangedSpy.count(), 4);
+ QCOMPARE(centroidChangedSpy.size(), 4);
QTest::touchEvent(window, touchDevice).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!dragHandler->active());
QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton);
QCOMPARE(dragHandler->centroid().velocity(), QVector2D());
QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1);
- QCOMPARE(translationChangedSpy.count(), 1);
- QCOMPARE(centroidChangedSpy.count(), 5);
+ QCOMPARE(translationChangedSpy.size(), 1);
+ QCOMPARE(centroidChangedSpy.size(), 5);
QCOMPARE(dragHandler->persistentTranslation().x(), dragThreshold + 20);
// Drag again: activeTranslation starts over, while persistentTranslation accumulates
@@ -290,13 +290,13 @@ void tst_DragHandler::mouseDrag()
QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos);
QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
QCOMPARE(dragHandler->centroid().velocity(), QVector2D());
- QCOMPARE(centroidChangedSpy.count(), 1);
+ QCOMPARE(centroidChangedSpy.size(), 1);
}
p1 += QPoint(dragThreshold, 0);
QTest::mouseMove(window, p1);
if (shouldDrag) {
-// QTRY_VERIFY(dragHandler->centroid().velocity().x() > 0); // TODO QTBUG-33891
- QCOMPARE(centroidChangedSpy.count(), 2);
+ QVERIFY(dragHandler->centroid().velocity().x() > 0);
+ QCOMPARE(centroidChangedSpy.size(), 2);
QVERIFY(!dragHandler->active());
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);
@@ -308,9 +308,9 @@ void tst_DragHandler::mouseDrag()
QTRY_VERIFY(dragHandler->active());
else
QVERIFY(!dragHandler->active());
- QCOMPARE(translationChangedSpy.count(), 0);
+ QCOMPARE(translationChangedSpy.size(), 0);
if (shouldDrag)
- QCOMPARE(centroidChangedSpy.count(), 3);
+ QCOMPARE(centroidChangedSpy.size(), 3);
QCOMPARE(dragHandler->persistentTranslation().x(), 0.0);
QCOMPARE(dragHandler->activeTranslation().x(), 0.0);
QPointF sceneGrabPos = p1;
@@ -329,8 +329,8 @@ void tst_DragHandler::mouseDrag()
QCOMPARE(dragHandler->activeTranslation().x(), dragThreshold + 20.0);
QCOMPARE(dragHandler->persistentTranslation().y(), 0.0);
QCOMPARE(dragHandler->activeTranslation().y(), 0.0);
-// QVERIFY(dragHandler->centroid().velocity().x() > 0); // TODO QTBUG-33891
- QCOMPARE(centroidChangedSpy.count(), 4);
+ QVERIFY(dragHandler->centroid().velocity().x() > 0);
+ QCOMPARE(centroidChangedSpy.size(), 4);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ClosedHandCursor);
#endif
@@ -340,8 +340,8 @@ void tst_DragHandler::mouseDrag()
QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton);
if (shouldDrag)
QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1);
- QCOMPARE(translationChangedSpy.count(), shouldDrag ? 1 : 0);
- QCOMPARE(centroidChangedSpy.count(), shouldDrag ? 5 : 0);
+ QCOMPARE(translationChangedSpy.size(), shouldDrag ? 1 : 0);
+ QCOMPARE(centroidChangedSpy.size(), shouldDrag ? 5 : 0);
#if QT_CONFIG(cursor)
QTest::mouseMove(window, p1 + QPoint(1, 0)); // TODO after fixing QTBUG-53987, don't send mouseMove
QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);
@@ -388,19 +388,19 @@ void tst_DragHandler::mouseDragThreshold()
QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos);
QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
QCOMPARE(dragHandler->centroid().velocity(), QVector2D());
- QCOMPARE(centroidChangedSpy.count(), 1);
+ QCOMPARE(centroidChangedSpy.size(), 1);
p1 += QPoint(qMax(1, dragThreshold), 0); // QTBUG-85431: zero-distance mouse moves are not delivered
QTest::mouseMove(window, p1);
if (dragThreshold > 0)
QTRY_VERIFY(dragHandler->centroid().velocity().x() > 0);
- QCOMPARE(centroidChangedSpy.count(), 2);
+ QCOMPARE(centroidChangedSpy.size(), 2);
// the handler is not yet active, unless the drag threshold was already exceeded
QCOMPARE(dragHandler->active(), dragThreshold == 0);
p1 += QPoint(1, 0);
QTest::mouseMove(window, p1);
QTRY_VERIFY(dragHandler->active());
- QCOMPARE(translationChangedSpy.count(), dragThreshold ? 0 : 1);
- QCOMPARE(centroidChangedSpy.count(), 3);
+ QCOMPARE(translationChangedSpy.size(), dragThreshold ? 0 : 1);
+ QCOMPARE(centroidChangedSpy.size(), 3);
QCOMPARE(dragHandler->translation().x(), dragThreshold ? 0 : 2);
QPointF sceneGrabPos = dragThreshold ? p1 : p1 - QPoint(1, 0);
QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos);
@@ -415,13 +415,13 @@ void tst_DragHandler::mouseDragThreshold()
QCOMPARE(dragHandler->translation().x(), dragThreshold + (dragThreshold ? 20 : 21));
QCOMPARE(dragHandler->translation().y(), 0.0);
QVERIFY(dragHandler->centroid().velocity().x() > 0);
- QCOMPARE(centroidChangedSpy.count(), 4);
+ QCOMPARE(centroidChangedSpy.size(), 4);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
QTRY_VERIFY(!dragHandler->active());
QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton);
QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1);
- QCOMPARE(translationChangedSpy.count(), dragThreshold ? 1 : 2);
- QCOMPARE(centroidChangedSpy.count(), 5);
+ QCOMPARE(translationChangedSpy.size(), dragThreshold ? 1 : 2);
+ QCOMPARE(centroidChangedSpy.size(), 5);
}
void tst_DragHandler::dragFromMargin() // QTBUG-74966
@@ -574,13 +574,13 @@ void tst_DragHandler::touchDragMulti()
touchSeq.stationary(1).press(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QVERIFY(!dragHandler1->active());
- QCOMPARE(centroidChangedSpy1.count(), 2);
+ QCOMPARE(centroidChangedSpy1.size(), 2);
QCOMPARE(dragHandler1->centroid().position(), ball1Center);
QCOMPARE(dragHandler1->centroid().pressPosition(), ball1Center);
QCOMPARE(dragHandler1->centroid().scenePosition(), scenePressPos1);
QCOMPARE(dragHandler1->centroid().scenePressPosition(), scenePressPos1);
QVERIFY(!dragHandler2->active());
- QCOMPARE(centroidChangedSpy2.count(), 2);
+ QCOMPARE(centroidChangedSpy2.size(), 2);
QCOMPARE(dragHandler2->centroid().position(), ball2Center);
QCOMPARE(dragHandler2->centroid().pressPosition(), ball2Center);
QCOMPARE(dragHandler2->centroid().scenePosition(), scenePressPos2);
@@ -590,13 +590,13 @@ void tst_DragHandler::touchDragMulti()
touchSeq.move(1, p1, window).move(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QVERIFY(!dragHandler1->active());
- QCOMPARE(centroidChangedSpy1.count(), 3);
+ QCOMPARE(centroidChangedSpy1.size(), 3);
QCOMPARE(dragHandler1->centroid().position(), ball1Center + QPointF(dragThreshold, 0));
QCOMPARE(dragHandler1->centroid().pressPosition(), ball1Center);
QCOMPARE(dragHandler1->centroid().scenePosition().toPoint(), p1);
QCOMPARE(dragHandler1->centroid().scenePressPosition(), scenePressPos1);
QVERIFY(!dragHandler2->active());
- QCOMPARE(centroidChangedSpy2.count(), 3);
+ QCOMPARE(centroidChangedSpy2.size(), 3);
QCOMPARE(dragHandler2->centroid().position(), ball2Center + QPointF(0, dragThreshold));
QCOMPARE(dragHandler2->centroid().pressPosition(), ball2Center);
QCOMPARE(dragHandler2->centroid().scenePosition().toPoint(), p2);
@@ -607,7 +607,7 @@ void tst_DragHandler::touchDragMulti()
QQuickTouchUtils::flush(window);
QTRY_VERIFY(dragHandler1->active());
QVERIFY(dragHandler2->active());
- QCOMPARE(translationChangedSpy1.count(), 0);
+ QCOMPARE(translationChangedSpy1.size(), 0);
QCOMPARE(dragHandler1->translation().x(), 0.0);
QPointF sceneGrabPos1 = p1;
QPointF sceneGrabPos2 = p2;
@@ -616,7 +616,7 @@ void tst_DragHandler::touchDragMulti()
p1 += QPoint(19, 0);
p2 += QPoint(0, 19);
QVERIFY(dragHandler2->active());
- QCOMPARE(translationChangedSpy2.count(), 0);
+ QCOMPARE(translationChangedSpy2.size(), 0);
QCOMPARE(dragHandler2->translation().x(), 0.0);
QCOMPARE(dragHandler2->centroid().sceneGrabPosition(), sceneGrabPos2);
touchSeq.move(1, p1, window).move(2, p2, window).commit();
@@ -643,12 +643,12 @@ void tst_DragHandler::touchDragMulti()
QVERIFY(dragHandler2->active());
QCOMPARE(dragHandler1->centroid().pressedButtons(), Qt::NoButton);
QCOMPARE(ball1->mapToScene(ball1Center).toPoint(), p1);
- QCOMPARE(translationChangedSpy1.count(), 1);
+ QCOMPARE(translationChangedSpy1.size(), 1);
touchSeq.release(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!dragHandler2->active());
QCOMPARE(ball2->mapToScene(ball2Center).toPoint(), p2);
- QCOMPARE(translationChangedSpy2.count(), 1);
+ QCOMPARE(translationChangedSpy2.size(), 1);
}
void tst_DragHandler::touchDragMultiSliders_data()
@@ -854,7 +854,7 @@ void tst_DragHandler::touchPinchAndMouseMove()
for (int i = 0; i < 10; ++i) {
p1 += delta;
QTest::mouseMove(window, p1);
- QCOMPARE(rectMovedSpy.count(), 0);
+ QCOMPARE(rectMovedSpy.size(), 0);
}
}
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/BLACKLIST b/tests/auto/quick/pointerhandlers/qquickhoverhandler/BLACKLIST
index 51e1876a88..1c4499753a 100644
--- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/BLACKLIST
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/BLACKLIST
@@ -3,6 +3,3 @@ macos # Can't move cursor (QTBUG-76312)
# QTBUG-103065
[movingItemWithHoverHandler]
android
-
-[hoverHandlerAndUnderlyingHoverHandler]
-macos ci # QTBUG-89933
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/hoverDeviceCursors.qml b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/hoverDeviceCursors.qml
new file mode 100644
index 0000000000..edb56ffdc6
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/hoverDeviceCursors.qml
@@ -0,0 +1,49 @@
+import QtQuick
+
+Item {
+ width: 200; height: 200
+
+ HoverHandler {
+ objectName: "stylus"
+ acceptedDevices: PointerDevice.Stylus
+ acceptedPointerTypes: PointerDevice.Pen
+ cursorShape: Qt.CrossCursor
+ }
+
+ HoverHandler {
+ objectName: "stylus eraser"
+ acceptedDevices: PointerDevice.Stylus
+ acceptedPointerTypes: PointerDevice.Eraser
+ cursorShape: Qt.PointingHandCursor
+ }
+
+ HoverHandler {
+ objectName: "airbrush"
+ acceptedDevices: PointerDevice.Airbrush
+ acceptedPointerTypes: PointerDevice.Pen
+ cursorShape: Qt.BusyCursor
+ }
+
+ HoverHandler {
+ objectName: "airbrush eraser"
+ acceptedDevices: PointerDevice.Airbrush
+ acceptedPointerTypes: PointerDevice.Eraser
+ cursorShape: Qt.OpenHandCursor
+ }
+
+ HoverHandler {
+ objectName: "mouse"
+ acceptedDevices: PointerDevice.Mouse
+ // acceptedPointerTypes can be omitted because Mouse is not ambiguous.
+ // When a genuine mouse move is sent, there's a conflict, and this one should win.
+ cursorShape: Qt.IBeamCursor
+ }
+
+ HoverHandler {
+ objectName: "conflictingMouse"
+ acceptedDevices: PointerDevice.Mouse
+ // acceptedPointerTypes can be omitted because Mouse is not ambiguous.
+ // When a genuine mouse move is sent, there's a conflict, and this one should lose.
+ cursorShape: Qt.ClosedHandCursor
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/nohandler.qml b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/nohandler.qml
new file mode 100644
index 0000000000..ed3728e278
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/nohandler.qml
@@ -0,0 +1,15 @@
+import QtQuick 2.15
+import QtQuick.Window 2.15
+
+Window {
+ width: 320
+ height: 240
+ visible: true
+
+ Rectangle {
+ objectName: "childItem"
+ width: 100
+ height: 100
+ color: "lightblue"
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
index fcd2c5c49b..e488c0486f 100644
--- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
@@ -6,6 +6,7 @@
#include <QtQuick/qquickview.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/private/qquickhoverhandler_p.h>
+#include <QtQuick/private/qquickpointerhandler_p_p.h>
#include <QtQuick/private/qquickmousearea_p.h>
#include <qpa/qwindowsysteminterface.h>
@@ -38,9 +39,15 @@ private slots:
void hoverHandlerAndUnderlyingHoverHandler();
void mouseAreaAndUnderlyingHoverHandler();
void hoverHandlerAndUnderlyingMouseArea();
+ void disabledHoverHandlerAndUnderlyingMouseArea();
+ void hoverHandlerOnDisabledItem();
void movingItemWithHoverHandler();
void margin();
void window();
+ void deviceCursor_data();
+ void deviceCursor();
+ void addHandlerFromCpp();
+ void ensureHoverHandlerWorksWhenItemHasHoverDisabled();
private:
void createView(QScopedPointer<QQuickView> &window, const char *fileName);
@@ -94,45 +101,45 @@ void tst_HoverHandler::hoverHandlerAndUnderlyingHoverHandler()
QTest::mouseMove(window, outOfSidebar);
QCOMPARE(topSidebarHH->isHovered(), false);
- QCOMPARE(sidebarHoveredSpy.count(), 0);
+ QCOMPARE(sidebarHoveredSpy.size(), 0);
QCOMPARE(buttonHH->isHovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 0);
+ QCOMPARE(buttonHoveredSpy.size(), 0);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);
#endif
QTest::mouseMove(window, rightOfButton);
QCOMPARE(topSidebarHH->isHovered(), true);
- QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(sidebarHoveredSpy.size(), 1);
QCOMPARE(buttonHH->isHovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 0);
+ QCOMPARE(buttonHoveredSpy.size(), 0);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor);
#endif
QTest::mouseMove(window, buttonCenter);
QCOMPARE(topSidebarHH->isHovered(), !blocking);
- QCOMPARE(sidebarHoveredSpy.count(), blocking ? 2 : 1);
+ QCOMPARE(sidebarHoveredSpy.size(), blocking ? 2 : 1);
QCOMPARE(buttonHH->isHovered(), true);
- QCOMPARE(buttonHoveredSpy.count(), 1);
+ QCOMPARE(buttonHoveredSpy.size(), 1);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::PointingHandCursor);
#endif
QTest::mouseMove(window, rightOfButton);
QCOMPARE(topSidebarHH->isHovered(), true);
- QCOMPARE(sidebarHoveredSpy.count(), blocking ? 3 : 1);
+ QCOMPARE(sidebarHoveredSpy.size(), blocking ? 3 : 1);
QCOMPARE(buttonHH->isHovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 2);
+ QCOMPARE(buttonHoveredSpy.size(), 2);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor);
#endif
QTest::mouseMove(window, outOfSidebar);
QCOMPARE(topSidebarHH->isHovered(), false);
- QCOMPARE(sidebarHoveredSpy.count(), blocking ? 4 : 2);
+ QCOMPARE(sidebarHoveredSpy.size(), blocking ? 4 : 2);
QCOMPARE(buttonHH->isHovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 2);
+ QCOMPARE(buttonHoveredSpy.size(), 2);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);
#endif
@@ -165,45 +172,45 @@ void tst_HoverHandler::mouseAreaAndUnderlyingHoverHandler()
QTest::mouseMove(window, outOfSidebar);
QCOMPARE(topSidebarHH->isHovered(), false);
- QCOMPARE(sidebarHoveredSpy.count(), 0);
+ QCOMPARE(sidebarHoveredSpy.size(), 0);
QCOMPARE(buttonMA->hovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 0);
+ QCOMPARE(buttonHoveredSpy.size(), 0);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);
#endif
QTest::mouseMove(window, rightOfButton);
QCOMPARE(topSidebarHH->isHovered(), true);
- QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(sidebarHoveredSpy.size(), 1);
QCOMPARE(buttonMA->hovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 0);
+ QCOMPARE(buttonHoveredSpy.size(), 0);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor);
#endif
QTest::mouseMove(window, buttonCenter);
QCOMPARE(topSidebarHH->isHovered(), true);
- QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(sidebarHoveredSpy.size(), 1);
QCOMPARE(buttonMA->hovered(), true);
- QCOMPARE(buttonHoveredSpy.count(), 1);
+ QCOMPARE(buttonHoveredSpy.size(), 1);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::UpArrowCursor);
#endif
QTest::mouseMove(window, rightOfButton);
QCOMPARE(topSidebarHH->isHovered(), true);
- QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(sidebarHoveredSpy.size(), 1);
QCOMPARE(buttonMA->hovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 2);
+ QCOMPARE(buttonHoveredSpy.size(), 2);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor);
#endif
QTest::mouseMove(window, outOfSidebar);
QCOMPARE(topSidebarHH->isHovered(), false);
- QCOMPARE(sidebarHoveredSpy.count(), 2);
+ QCOMPARE(sidebarHoveredSpy.size(), 2);
QCOMPARE(buttonMA->hovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 2);
+ QCOMPARE(buttonHoveredSpy.size(), 2);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);
#endif
@@ -231,50 +238,131 @@ void tst_HoverHandler::hoverHandlerAndUnderlyingMouseArea()
QTest::mouseMove(window, outOfSidebar);
QCOMPARE(bottomSidebarMA->hovered(), false);
- QCOMPARE(sidebarHoveredSpy.count(), 0);
+ QCOMPARE(sidebarHoveredSpy.size(), 0);
QCOMPARE(buttonHH->isHovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 0);
+ QCOMPARE(buttonHoveredSpy.size(), 0);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);
#endif
QTest::mouseMove(window, rightOfButton);
QCOMPARE(bottomSidebarMA->hovered(), true);
- QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(sidebarHoveredSpy.size(), 1);
QCOMPARE(buttonHH->isHovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 0);
+ QCOMPARE(buttonHoveredSpy.size(), 0);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ClosedHandCursor);
#endif
QTest::mouseMove(window, buttonCenter);
QCOMPARE(bottomSidebarMA->hovered(), false);
- QCOMPARE(sidebarHoveredSpy.count(), 2);
+ QCOMPARE(sidebarHoveredSpy.size(), 2);
QCOMPARE(buttonHH->isHovered(), true);
- QCOMPARE(buttonHoveredSpy.count(), 1);
+ QCOMPARE(buttonHoveredSpy.size(), 1);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::PointingHandCursor);
#endif
QTest::mouseMove(window, rightOfButton);
QCOMPARE(bottomSidebarMA->hovered(), true);
- QCOMPARE(sidebarHoveredSpy.count(), 3);
+ QCOMPARE(sidebarHoveredSpy.size(), 3);
QCOMPARE(buttonHH->isHovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 2);
+ QCOMPARE(buttonHoveredSpy.size(), 2);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ClosedHandCursor);
#endif
QTest::mouseMove(window, outOfSidebar);
QCOMPARE(bottomSidebarMA->hovered(), false);
- QCOMPARE(sidebarHoveredSpy.count(), 4);
+ QCOMPARE(sidebarHoveredSpy.size(), 4);
QCOMPARE(buttonHH->isHovered(), false);
- QCOMPARE(buttonHoveredSpy.count(), 2);
+ QCOMPARE(buttonHoveredSpy.size(), 2);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);
#endif
}
+void tst_HoverHandler::disabledHoverHandlerAndUnderlyingMouseArea()
+{
+ // Check that if a disabled HoverHandler is installed on an item, it
+ // will not participate in hover event delivery, and as such, also
+ // not block propagation to siblings.
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "lesHoverables.qml");
+ QQuickView * window = windowPtr.data();
+ QQuickItem * bottomSidebar = window->rootObject()->findChild<QQuickItem *>("bottomSidebar");
+ QVERIFY(bottomSidebar);
+ QQuickMouseArea *bottomSidebarMA = bottomSidebar->findChild<QQuickMouseArea *>("bottomSidebarMA");
+ QVERIFY(bottomSidebarMA);
+ QQuickItem * button = bottomSidebar->findChild<QQuickItem *>("buttonWithHH");
+ QVERIFY(button);
+ QQuickHoverHandler *buttonHH = button->findChild<QQuickHoverHandler *>("buttonHH");
+ QVERIFY(buttonHH);
+
+ // By disabling the HoverHandler, it should no longer
+ // block the sibling MouseArea underneath from receiving hover events.
+ buttonHH->setEnabled(false);
+
+ QPoint buttonCenter(button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
+ QPoint rightOfButton(button->mapToScene(QPointF(button->width() + 2, button->height() / 2)).toPoint());
+ QPoint outOfSidebar(bottomSidebar->mapToScene(QPointF(bottomSidebar->width() + 2, bottomSidebar->height() / 2)).toPoint());
+ QSignalSpy sidebarHoveredSpy(bottomSidebarMA, SIGNAL(hoveredChanged()));
+ QSignalSpy buttonHoveredSpy(buttonHH, SIGNAL(hoveredChanged()));
+
+ QTest::mouseMove(window, outOfSidebar);
+ QCOMPARE(bottomSidebarMA->hovered(), false);
+ QCOMPARE(sidebarHoveredSpy.size(), 0);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.size(), 0);
+
+ QTest::mouseMove(window, buttonCenter);
+ QCOMPARE(bottomSidebarMA->hovered(), true);
+ QCOMPARE(sidebarHoveredSpy.size(), 1);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.size(), 0);
+
+ QTest::mouseMove(window, rightOfButton);
+ QCOMPARE(bottomSidebarMA->hovered(), true);
+ QCOMPARE(sidebarHoveredSpy.size(), 1);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.size(), 0);
+}
+
+void tst_HoverHandler::hoverHandlerOnDisabledItem()
+{
+ // Check that if HoverHandler on a disabled item will
+ // continue to receive hover events (QTBUG-30801)
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "lesHoverables.qml");
+ QQuickView * window = windowPtr.data();
+ QQuickItem * bottomSidebar = window->rootObject()->findChild<QQuickItem *>("bottomSidebar");
+ QVERIFY(bottomSidebar);
+ QQuickItem * button = bottomSidebar->findChild<QQuickItem *>("buttonWithHH");
+ QVERIFY(button);
+ QQuickHoverHandler *buttonHH = button->findChild<QQuickHoverHandler *>("buttonHH");
+ QVERIFY(buttonHH);
+
+ // Disable the button/rectangle item. This should not
+ // block its HoverHandler from being hovered
+ button->setEnabled(false);
+
+ QPoint buttonCenter(button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
+ QPoint rightOfButton(button->mapToScene(QPointF(button->width() + 2, button->height() / 2)).toPoint());
+ QSignalSpy buttonHoveredSpy(buttonHH, SIGNAL(hoveredChanged()));
+
+ QTest::mouseMove(window, rightOfButton);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.size(), 0);
+
+ QTest::mouseMove(window, buttonCenter);
+ QCOMPARE(buttonHH->isHovered(), true);
+ QCOMPARE(buttonHoveredSpy.size(), 1);
+
+ QTest::mouseMove(window, rightOfButton);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.size(), 2);
+}
+
void tst_HoverHandler::movingItemWithHoverHandler()
{
if (isPlatformWayland())
@@ -328,21 +416,21 @@ void tst_HoverHandler::margin() // QTBUG-85303
QTest::mouseMove(window, {10, 10});
QCOMPARE(hh->isHovered(), false);
- QCOMPARE(hoveredSpy.count(), 0);
+ QCOMPARE(hoveredSpy.size(), 0);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);
#endif
QTest::mouseMove(window, leftMargin);
QCOMPARE(hh->isHovered(), true);
- QCOMPARE(hoveredSpy.count(), 1);
+ QCOMPARE(hoveredSpy.size(), 1);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor);
#endif
QTest::mouseMove(window, itemCenter);
QCOMPARE(hh->isHovered(), true);
- QCOMPARE(hoveredSpy.count(), 1);
+ QCOMPARE(hoveredSpy.size(), 1);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor);
#endif
@@ -383,6 +471,206 @@ void tst_HoverHandler::window() // QTBUG-98717
#endif
}
+void tst_HoverHandler::deviceCursor_data()
+{
+ QTest::addColumn<bool>("synthMouseForTabletEvents");
+ QTest::addColumn<bool>("earlierTabletBeforeMouse");
+
+ QTest::newRow("nosynth, tablet wins") << false << false;
+ QTest::newRow("synth, tablet wins") << true << false;
+ QTest::newRow("synth, mouse wins") << true << true;
+}
+
+void tst_HoverHandler::deviceCursor()
+{
+#if !QT_CONFIG(tabletevent)
+ QSKIP("This test depends on QTabletEvent delivery.");
+#endif
+ QFETCH(bool, synthMouseForTabletEvents);
+ QFETCH(bool, earlierTabletBeforeMouse);
+ qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTabletEvents, synthMouseForTabletEvents);
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("hoverDeviceCursors.qml")));
+ // Ensure that we don't get extra hover events delivered on the side
+ QQuickWindowPrivate::get(&window)->deliveryAgentPrivate()->frameSynchronousHoverEnabled = false;
+ // And flush out any mouse events that might be queued up in QPA, since QTest::mouseMove() calls processEvents.
+ qGuiApp->processEvents();
+ const QQuickItem *root = window.rootObject();
+ QQuickHoverHandler *stylusHandler = root->findChild<QQuickHoverHandler *>("stylus");
+ QVERIFY(stylusHandler);
+ QQuickHoverHandler *eraserHandler = root->findChild<QQuickHoverHandler *>("stylus eraser");
+ QVERIFY(eraserHandler);
+ QQuickHoverHandler *aibrushHandler = root->findChild<QQuickHoverHandler *>("airbrush");
+ QVERIFY(aibrushHandler);
+ QQuickHoverHandler *airbrushEraserHandler = root->findChild<QQuickHoverHandler *>("airbrush eraser");
+ QVERIFY(airbrushEraserHandler);
+ QQuickHoverHandler *mouseHandler = root->findChild<QQuickHoverHandler *>("mouse");
+ QVERIFY(mouseHandler);
+
+ QPoint point(100, 100);
+
+ const qint64 stylusId = 1234567890;
+ QElapsedTimer timer;
+ timer.start();
+ auto testStylusDevice = [&](QInputDevice::DeviceType dt, QPointingDevice::PointerType pt,
+ Qt::CursorShape expectedCursor, QQuickHoverHandler* expectedActiveHandler) {
+ // We will follow up with a mouse event afterwards, and we want to simulate that the tablet events occur
+ // either slightly before (earlierTabletBeforeMouse == true) or some time before.
+ // It turns out that the first mouse move happens at timestamp 501 (simulated).
+ const ulong timestamp = (earlierTabletBeforeMouse ? 0 : 400) + timer.elapsed();
+ qCDebug(lcPointerTests) << "@" << timestamp << "sending" << dt << pt << "expecting" << expectedCursor << expectedActiveHandler->objectName();
+ QWindowSystemInterface::handleTabletEvent(&window, timestamp, point, window.mapToGlobal(point),
+ int(dt), int(pt), Qt::NoButton, 0, 0, 0, 0, 0, 0, stylusId, Qt::NoModifier);
+ point += QPoint(1, 0);
+#if QT_CONFIG(cursor)
+ // QQuickItem::setCursor() doesn't get called: we only have HoverHandlers in this test
+ QCOMPARE(root->cursor().shape(), Qt::ArrowCursor);
+ QTRY_COMPARE(window.cursor().shape(), expectedCursor);
+#endif
+ QCOMPARE(stylusHandler->isHovered(), stylusHandler == expectedActiveHandler);
+ QCOMPARE(eraserHandler->isHovered(), eraserHandler == expectedActiveHandler);
+ QCOMPARE(aibrushHandler->isHovered(), aibrushHandler == expectedActiveHandler);
+ QCOMPARE(airbrushEraserHandler->isHovered(), airbrushEraserHandler == expectedActiveHandler);
+ };
+
+ // simulate move events from various tablet stylus types
+ testStylusDevice(QInputDevice::DeviceType::Stylus, QPointingDevice::PointerType::Pen,
+ Qt::CrossCursor, stylusHandler);
+ testStylusDevice(QInputDevice::DeviceType::Stylus, QPointingDevice::PointerType::Eraser,
+ Qt::PointingHandCursor, eraserHandler);
+ testStylusDevice(QInputDevice::DeviceType::Airbrush, QPointingDevice::PointerType::Pen,
+ Qt::BusyCursor, aibrushHandler);
+ testStylusDevice(QInputDevice::DeviceType::Airbrush, QPointingDevice::PointerType::Eraser,
+ Qt::OpenHandCursor, airbrushEraserHandler);
+
+ qCDebug(lcPointerTests) << "---- no more tablet events, now we send a mouse move";
+
+ // move the mouse: the mouse-specific HoverHandler gets to set the cursor only if
+ // more than kCursorOverrideTimeout ms have elapsed (100ms)
+ QTest::mouseMove(&window, point, 100);
+ QTRY_IMPL(mouseHandler->isHovered() == true, 500);
+ const bool afterTimeout =
+ QQuickPointerHandlerPrivate::get(airbrushEraserHandler)->lastEventTime + 100 <
+ QQuickPointerHandlerPrivate::get(mouseHandler)->lastEventTime;
+ qCDebug(lcPointerTests) << "airbrush handler reacted last time:" << QQuickPointerHandlerPrivate::get(airbrushEraserHandler)->lastEventTime
+ << "and the mouse handler reacted at time:" << QQuickPointerHandlerPrivate::get(mouseHandler)->lastEventTime
+ << "so > 100 ms have elapsed?" << afterTimeout;
+ if (afterTimeout)
+ QCOMPARE(mouseHandler->isHovered(), true);
+ else
+ QSKIP("Failed to delay mouse move 100ms after the previous tablet event");
+
+#if QT_CONFIG(cursor)
+ QCOMPARE(window.cursor().shape(), afterTimeout ? Qt::IBeamCursor : Qt::OpenHandCursor);
+#endif
+ QCOMPARE(stylusHandler->isHovered(), false);
+ QCOMPARE(eraserHandler->isHovered(), false);
+ QCOMPARE(aibrushHandler->isHovered(), false);
+ QCOMPARE(airbrushEraserHandler->isHovered(), true); // there was no fresh QTabletEvent to tell it not to be hovered
+}
+
+void tst_HoverHandler::addHandlerFromCpp()
+{
+ // Check that you can create a hover handler from c++, and add it
+ // as a child of an existing item. Continue to check that you can
+ // also change the parent item at runtime.
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("nohandler.qml"));
+ QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(component.create()));
+ QVERIFY(!window.isNull());
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickItem *childItem = window->findChild<QQuickItem *>("childItem");
+ QVERIFY(childItem);
+
+ // Move mouse outside child
+ const QPoint outside(200, 200);
+ const QPoint inside(50, 50);
+ QTest::mouseMove(window.data(), outside);
+
+ QQuickHoverHandler *handler = new QQuickHoverHandler(childItem);
+ QSignalSpy spy(handler, &QQuickHoverHandler::hoveredChanged);
+
+ // Move mouse inside child
+ QTest::mouseMove(window.data(), inside);
+ QVERIFY(handler->isHovered());
+ QCOMPARE(spy.size(), 1);
+
+ // Move mouse outside child
+ QTest::mouseMove(window.data(), outside);
+ QVERIFY(!handler->isHovered());
+ QCOMPARE(spy.size(), 2);
+
+ // Remove the parent item from the handler
+ spy.clear();
+ handler->setParentItem(nullptr);
+
+ // Move mouse inside child
+ QTest::mouseMove(window.data(), inside);
+ QVERIFY(!handler->isHovered());
+ QCOMPARE(spy.size(), 0);
+
+ // Move mouse outside child
+ QTest::mouseMove(window.data(), outside);
+ QVERIFY(!handler->isHovered());
+ QCOMPARE(spy.size(), 0);
+
+ // Reparent back the item to the handler
+ spy.clear();
+ handler->setParentItem(childItem);
+
+ // Move mouse inside child
+ QTest::mouseMove(window.data(), inside);
+ QVERIFY(handler->isHovered());
+ QCOMPARE(spy.size(), 1);
+
+ // Move mouse outside child
+ QTest::mouseMove(window.data(), outside);
+ QVERIFY(!handler->isHovered());
+ QCOMPARE(spy.size(), 2);
+}
+
+void tst_HoverHandler::ensureHoverHandlerWorksWhenItemHasHoverDisabled()
+{
+ // Check that a hover handler with a leaf item as parent, continues to
+ // receive hover, even if the item itself stops listening for hover.
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("nohandler.qml"));
+ QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(component.create()));
+ QVERIFY(!window.isNull());
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickItem *childItem = window->findChild<QQuickItem *>("childItem");
+ QVERIFY(childItem);
+
+ // Move mouse outside child
+ const QPoint outside(200, 200);
+ const QPoint inside(50, 50);
+ QTest::mouseMove(window.data(), outside);
+
+ QQuickHoverHandler *handler = new QQuickHoverHandler(childItem);
+
+ // Toggle hover on the item. This should not clear subtreeHoverEnabled
+ // on the item as a whole, since it still has a hover handler.
+ childItem->setAcceptHoverEvents(true);
+ childItem->setAcceptHoverEvents(false);
+ QSignalSpy spy(handler, &QQuickHoverHandler::hoveredChanged);
+
+ // Move mouse inside child
+ QTest::mouseMove(window.data(), inside);
+ QVERIFY(handler->isHovered());
+ QCOMPARE(spy.size(), 1);
+
+ // Move mouse outside child
+ QTest::mouseMove(window.data(), outside);
+ QVERIFY(!handler->isHovered());
+ QCOMPARE(spy.size(), 2);
+}
+
QTEST_MAIN(tst_HoverHandler)
#include "tst_qquickhoverhandler.moc"
diff --git a/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/nullTarget.qml b/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/nullTarget.qml
new file mode 100644
index 0000000000..a348938aca
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/nullTarget.qml
@@ -0,0 +1,33 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick 2.15
+
+Item {
+ width: 320; height: 320
+ property alias pinchScale: pinch.scale
+
+ Rectangle {
+ objectName: "blackrect"
+ width: 200; height: 200
+ color: "black"
+ antialiasing: true
+ scale: pinch.scale
+ rotation: pinch.rotation
+ x: pinch.translation.x
+ y: pinch.translation.y
+
+ PinchHandler {
+ id: pinch
+ target: null
+ minimumScale: 0.5
+ maximumScale: 4
+ }
+
+ Text {
+ color: "cyan"
+ anchors.centerIn: parent
+ text: "scale " + pinch.scale.toFixed(2) + " activeScale " + pinch.activeScale.toFixed(2)
+ }
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/pinchproperties.qml b/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/pinchproperties.qml
index 0e0c949c91..3f1a2556cd 100644
--- a/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/pinchproperties.qml
+++ b/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/pinchproperties.qml
@@ -5,11 +5,38 @@ import QtQuick 2.12
Rectangle {
id: whiteRect
- property real scale: -1.0
+ property real pinchScale: -1.0
property int activeCount : 0
property int deactiveCount : 0
width: 320; height: 320
color: "white"
+
+ PointHandler {
+ id: ph1
+ acceptedDevices: PointerDevice.TouchScreen
+ target: Rectangle {
+ parent: whiteRect
+ color: "cyan"
+ x: ph1.point.position.x - 3
+ y: ph1.point.position.y - 3
+ width: 6; height: 6; radius: 3
+ }
+ }
+
+ PointHandler {
+ id: ph2
+ acceptedDevices: PointerDevice.TouchScreen
+ target: Rectangle {
+ parent: whiteRect
+ color: "lightgreen"
+ x: ph2.point.position.x - 3
+ y: ph2.point.position.y - 3
+ width: 6; height: 6; radius: 3
+ }
+ }
+
+ Text { color: "magenta"; z: 1; text: "scale: " + blackRect.scale}
+
Rectangle {
id: blackRect
objectName: "blackrect"
@@ -18,8 +45,7 @@ Rectangle {
x: 50
width: 100
height: 100
- opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200
- Text { color: "white"; text: "opacity: " + blackRect.opacity + "\nscale: " + blackRect.scale}
+
Rectangle {
color: "red"
width: 6; height: 6; radius: 3
@@ -31,20 +57,20 @@ Rectangle {
PinchHandler {
id: pincharea
objectName: "pinchHandler"
- minimumScale: 1.0
+ minimumScale: 0.5
maximumScale: 4.0
minimumRotation: 0.0
maximumRotation: 90.0
xAxis.maximum: 140
yAxis.maximum: 170
onActiveChanged: {
- whiteRect.scale = pincharea.scale
+ whiteRect.pinchScale = pincharea.scale
if (active) ++activeCount
else ++deactiveCount;
}
onUpdated: {
- whiteRect.scale = pincharea.scale
+ whiteRect.pinchScale = pincharea.scale
//whiteRect.pointCount = pincharea.pointCount
}
}
diff --git a/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp
index 32f5b4a365..526d1c6941 100644
--- a/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp
@@ -29,6 +29,7 @@ public:
private slots:
void cleanupTestCase();
void pinchProperties();
+ void scale_data();
void scale();
void scaleThreeFingers();
void scaleNativeGesture_data();
@@ -42,8 +43,8 @@ private slots:
void transformedpinchHandler();
private:
- QPointingDevice *touchscreen = QTest::createTouchDevice();
- QPointingDevice *touchpad = QTest::createTouchDevice(QInputDevice::DeviceType::TouchPad);
+ QScopedPointer<QPointingDevice> touchscreen = QScopedPointer<QPointingDevice>(QTest::createTouchDevice());
+ QScopedPointer<QPointingDevice> touchpad = QScopedPointer<QPointingDevice>(QTest::createTouchDevice(QInputDevice::DeviceType::TouchPad));
};
void tst_QQuickPinchHandler::cleanupTestCase()
@@ -74,9 +75,9 @@ void tst_QQuickPinchHandler::pinchProperties()
QVERIFY(rootItem != nullptr);
QSignalSpy targetSpy(pinchHandler, SIGNAL(targetChanged()));
pinchHandler->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
+ QCOMPARE(targetSpy.size(),1);
pinchHandler->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
+ QCOMPARE(targetSpy.size(),1);
// axis
/*
@@ -129,23 +130,23 @@ void tst_QQuickPinchHandler::pinchProperties()
QSignalSpy scaleMinSpy(pinchHandler, SIGNAL(minimumScaleChanged()));
QSignalSpy scaleMaxSpy(pinchHandler, SIGNAL(maximumScaleChanged()));
- QCOMPARE(pinchHandler->minimumScale(), 1.0);
+ QCOMPARE(pinchHandler->minimumScale(), 0.5);
QCOMPARE(pinchHandler->maximumScale(), 4.0);
- pinchHandler->setMinimumScale(0.5);
+ pinchHandler->setMinimumScale(0.25);
pinchHandler->setMaximumScale(1.5);
- QCOMPARE(pinchHandler->minimumScale(), 0.5);
+ QCOMPARE(pinchHandler->minimumScale(), 0.25);
QCOMPARE(pinchHandler->maximumScale(), 1.5);
- QCOMPARE(scaleMinSpy.count(),1);
- QCOMPARE(scaleMaxSpy.count(),1);
+ QCOMPARE(scaleMinSpy.size(),1);
+ QCOMPARE(scaleMaxSpy.size(),1);
- pinchHandler->setMinimumScale(0.5);
+ pinchHandler->setMinimumScale(0.25);
pinchHandler->setMaximumScale(1.5);
- QCOMPARE(scaleMinSpy.count(),1);
- QCOMPARE(scaleMaxSpy.count(),1);
+ QCOMPARE(scaleMinSpy.size(),1);
+ QCOMPARE(scaleMaxSpy.size(),1);
// minimum and maximum rotation properties
QSignalSpy rotMinSpy(pinchHandler, SIGNAL(minimumRotationChanged()));
@@ -160,14 +161,14 @@ void tst_QQuickPinchHandler::pinchProperties()
QCOMPARE(pinchHandler->minimumRotation(), -90.0);
QCOMPARE(pinchHandler->maximumRotation(), 45.0);
- QCOMPARE(rotMinSpy.count(),1);
- QCOMPARE(rotMaxSpy.count(),1);
+ QCOMPARE(rotMinSpy.size(),1);
+ QCOMPARE(rotMaxSpy.size(),1);
pinchHandler->setMinimumRotation(-90.0);
pinchHandler->setMaximumRotation(45.0);
- QCOMPARE(rotMinSpy.count(),1);
- QCOMPARE(rotMaxSpy.count(),1);
+ QCOMPARE(rotMinSpy.size(),1);
+ QCOMPARE(rotMaxSpy.size(),1);
}
QEventPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickItem *i)
@@ -179,91 +180,120 @@ QEventPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickItem *i)
return touchPoint;
}
-void tst_QQuickPinchHandler::scale()
+void tst_QQuickPinchHandler::scale_data()
{
- QQuickView *window = QQuickViewTestUtils::createView();
- QScopedPointer<QQuickView> scope(window);
- window->setSource(testFileUrl("pinchproperties.qml"));
- window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
- QVERIFY(window->rootObject() != nullptr);
- qApp->processEvents();
+ QTest::addColumn<QUrl>("qmlfile");
+ QTest::addColumn<bool>("hasTarget");
+ QTest::newRow("targetModifying") << testFileUrl("pinchproperties.qml") << true;
+ QTest::newRow("nullTarget") << testFileUrl("nullTarget.qml") << false;
+}
- auto *pinchHandler = static_cast<PinchHandler *>(window->rootObject()->findChild<QQuickPinchHandler*>("pinchHandler"));
- QVERIFY(pinchHandler != nullptr);
- QSignalSpy grabChangedSpy(pinchHandler, SIGNAL(grabChanged(QPointingDevice::GrabTransition, QEventPoint)));
+void tst_QQuickPinchHandler::scale()
+{
+ QFETCH(QUrl, qmlfile);
+ QFETCH(bool, hasTarget);
- QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, qmlfile));
+ QQuickItem *root = qobject_cast<QQuickItem*>(window.rootObject());
QVERIFY(root != nullptr);
-
- // target
- QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ auto *pinchHandler = static_cast<PinchHandler *>(root->findChild<QQuickPinchHandler*>());
+ QVERIFY(pinchHandler != nullptr);
+ QQuickItem *blackRect = (hasTarget ? pinchHandler->target() : pinchHandler->parentItem());
QVERIFY(blackRect != nullptr);
+ QSignalSpy grabChangedSpy(pinchHandler, SIGNAL(grabChanged(QPointingDevice::GrabTransition, QEventPoint)));
QPoint p0(80, 80);
QPoint p1(100, 100);
- {
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen);
- pinchSequence.press(0, p0, window).commit();
- QQuickTouchUtils::flush(window);
- // In order for the stationary point to remember its previous position,
- // we have to reuse the same pinchSequence object. Otherwise if we let it
- // be destroyed and then start a new sequence, point 0 will default to being
- // stationary at 0, 0, and pinchHandler will filter out that touchpoint because
- // it is outside its bounds.
- pinchSequence.stationary(0).press(1, p1, window).commit();
- QQuickTouchUtils::flush(window);
- QTRY_COMPARE(grabChangedSpy.count(), 1); // passive grab
-
- QPoint pd(10, 10);
- // move one point until PinchHandler activates
- for (int pi = 0; pi < 10 && !pinchHandler->active(); ++pi) {
- p1 += pd;
- pinchSequence.stationary(0).move(1, p1, window).commit();
- QQuickTouchUtils::flush(window);
- }
- QCOMPARE(pinchHandler->active(), true);
- // grabs occur when the handler becomes active; at that time, QQuickHandlerPoint.sceneGrabPosition should be correct
- QVERIFY(pinchHandler->firstPoint().sceneGrabPosition() != QPointF());
- QVERIFY(pinchHandler->lastPoint().sceneGrabPosition() != QPointF());
- QCOMPARE(pinchHandler->firstPoint().sceneGrabPosition(), pinchHandler->firstPoint().scenePosition());
- QCOMPARE(pinchHandler->lastPoint().sceneGrabPosition(), pinchHandler->lastPoint().scenePosition());
- // first point got a passive grab; both points got exclusive grabs
- QCOMPARE(grabChangedSpy.count(), 3);
- QLineF line(p0, p1);
- const qreal startLength = line.length();
-
- p1+=pd;
- pinchSequence.stationary(0).move(1, p1, window).commit();
- QQuickTouchUtils::flush(window);
- line.setP2(p1);
- qreal scale = line.length() / startLength;
- QVERIFY(qFloatDistance(root->property("scale").toReal(), scale) < 10);
- QVERIFY(qFloatDistance(blackRect->scale(), scale) < 10);
-
- p1+=pd;
- pinchSequence.stationary(0).move(1, p1, window).commit();
- QQuickTouchUtils::flush(window);
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&window, touchscreen.get());
+ pinchSequence.press(0, p0, &window).commit();
+ QQuickTouchUtils::flush(&window);
+ // In order for the stationary point to remember its previous position,
+ // we have to reuse the same pinchSequence object. Otherwise if we let it
+ // be destroyed and then start a new sequence, point 0 will default to being
+ // stationary at 0, 0, and pinchHandler will filter out that touchpoint because
+ // it is outside its bounds.
+ pinchSequence.stationary(0).press(1, p1, &window).commit();
+ QQuickTouchUtils::flush(&window);
+ QCOMPARE(grabChangedSpy.size(), 1); // passive grab
+
+ QPoint pd(10, 10);
+ // move one point until PinchHandler activates
+ for (int pi = 0; pi < 10 && !pinchHandler->active(); ++pi) {
+ p1 += pd;
+ pinchSequence.stationary(0).move(1, p1, &window).commit();
+ QQuickTouchUtils::flush(&window);
+ }
+ QCOMPARE(pinchHandler->active(), true);
+ // grabs occur when the handler becomes active; at that time, QQuickHandlerPoint.sceneGrabPosition should be correct
+ QVERIFY(pinchHandler->firstPoint().sceneGrabPosition() != QPointF());
+ QVERIFY(pinchHandler->lastPoint().sceneGrabPosition() != QPointF());
+ QCOMPARE(pinchHandler->firstPoint().sceneGrabPosition(), pinchHandler->firstPoint().scenePosition());
+ QCOMPARE(pinchHandler->lastPoint().sceneGrabPosition(), pinchHandler->lastPoint().scenePosition());
+ // first point got a passive grab; both points got exclusive grabs
+ QCOMPARE(grabChangedSpy.size(), 3);
+ QLineF line(p0, p1);
+ const qreal startLength = line.length();
+
+ // move the same point even further and observe the change in scale
+ for (int i = 0; i < 2; ++i) {
+ p1 += pd;
+ pinchSequence.stationary(0).move(1, p1, &window).commit();
+ QQuickTouchUtils::flush(&window);
+ if (lcPointerTests().isDebugEnabled()) QTest::qWait(500);
line.setP2(p1);
- scale = line.length() / startLength;
-
- QVERIFY(qFloatDistance(root->property("scale").toReal(), scale) < 10);
- QVERIFY(qFloatDistance(blackRect->scale(), scale) < 10);
-
- QPointF expectedCentroid = p0 + (p1 - p0)/2;
+ qreal expectedScale = line.length() / startLength;
+ QVERIFY(qFloatDistance(root->property("pinchScale").toReal(), expectedScale) < 10);
+ QVERIFY(qFloatDistance(blackRect->scale(), expectedScale) < 10);
+ QCOMPARE(pinchHandler->scale(), root->property("pinchScale").toReal());
+ QCOMPARE(pinchHandler->scale(), pinchHandler->activeScale()); // in sync for the first gesture
+ QPointF expectedCentroid = p0 + (p1 - p0) / 2;
QCOMPARE(pinchHandler->centroid().scenePosition(), expectedCentroid);
}
- // scale beyond bound
- p1 += QPoint(20, 20);
- {
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen);
- pinchSequence.stationary(0).move(1, p1, window).commit();
- QQuickTouchUtils::flush(window);
- QCOMPARE(blackRect->scale(), qreal(4)); // qquickpinchhandler does not manipulate scale property
- pinchSequence.release(0, p0, window).release(1, p1, window).commit();
- QQuickTouchUtils::flush(window);
+ qreal lastScale = pinchHandler->scale();
+ pinchSequence.release(0, p0, &window).release(1, p1, &window).commit();
+ QQuickTouchUtils::flush(&window);
+ if (lcPointerTests().isDebugEnabled()) QTest::qWait(500);
+ // scale property is persistent after release
+ QCOMPARE(pinchHandler->scale(), lastScale);
+
+ // pinch a second time: scale picks up where we left off
+ p0 = QPoint(80, 80);
+ p1 = QPoint(100, 100);
+ pinchSequence.press(0, p0, &window).press(1, p1, &window).commit();
+ // move one point until PinchHandler activates
+ for (int pi = 0; pi < 10 && !pinchHandler->active(); ++pi) {
+ p1 += pd;
+ pinchSequence.stationary(0).move(1, p1, &window).commit();
+ QQuickTouchUtils::flush(&window);
+ }
+ if (lcPointerTests().isDebugEnabled()) QTest::qWait(500);
+ QCOMPARE(pinchHandler->active(), true);
+ QCOMPARE(pinchHandler->scale(), lastScale); // just activated, not scaling further yet
+ for (int i = 0; i < 2; ++i) {
+ lastScale = pinchHandler->scale();
+ p1 += pd;
+ pinchSequence.stationary(0).move(1, p1, &window).commit();
+ QQuickTouchUtils::flush(&window);
+ if (lcPointerTests().isDebugEnabled()) QTest::qWait(500);
+ QCOMPARE_GT(pinchHandler->scale(), lastScale);
+ line.setP2(p1);
+ qreal expectedActiveScale = line.length() / startLength;
+ QVERIFY(qFloatDistance(pinchHandler->activeScale(), expectedActiveScale) < 10);
+ QCOMPARE(pinchHandler->scale(), root->property("pinchScale").toReal());
+ QCOMPARE_NE(pinchHandler->scale(), pinchHandler->activeScale()); // not in sync anymore
}
+
+ // scale beyond maximumScale
+ p1 = QPoint(310, 310);
+ pinchSequence.stationary(0).move(1, p1, &window).commit();
+ QQuickTouchUtils::flush(&window);
+ if (lcPointerTests().isDebugEnabled()) QTest::qWait(500);
+ QCOMPARE(blackRect->scale(), qreal(4));
+ QCOMPARE(pinchHandler->scale(), qreal(4)); // limited by maximumScale
+ pinchSequence.release(0, p0, &window).release(1, p1, &window).commit();
+ QQuickTouchUtils::flush(&window);
QCOMPARE(pinchHandler->active(), false);
}
@@ -292,7 +322,7 @@ void tst_QQuickPinchHandler::scaleThreeFingers()
QPoint p1(220, 80);
QPoint p2(150, 220);
{
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen);
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen.get());
pinchSequence.press(0, p0, window).commit();
QQuickTouchUtils::flush(window);
// In order for the stationary point to remember its previous position,
@@ -348,14 +378,18 @@ void tst_QQuickPinchHandler::scaleThreeFingers()
void tst_QQuickPinchHandler::scaleNativeGesture_data()
{
QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<qreal>("scale");
- QTest::newRow("just pinch") << "pinchproperties.qml";
- QTest::newRow("pinch & drag") << "pinchAndDrag.qml";
+ QTest::newRow("just pinch") << "pinchproperties.qml" << 1.1;
+ QTest::newRow("pinch & drag") << "pinchAndDrag.qml" << 1.1;
+ QTest::newRow("bigger than limit") << "pinchproperties.qml" << 5.0;
+ QTest::newRow("smaller than limit") << "pinchproperties.qml" << 0.25;
}
void tst_QQuickPinchHandler::scaleNativeGesture()
{
QFETCH(QString, qmlfile);
+ QFETCH(qreal, scale);
QQuickView *window = QQuickViewTestUtils::createView();
QScopedPointer<QQuickView> scope(window);
@@ -375,29 +409,30 @@ void tst_QQuickPinchHandler::scaleNativeGesture()
QPointF targetPos = target->position();
ulong ts = 1;
- // first pinch: scale it up
- const qreal expectedScale = 1.1;
+ // first pinch: scale it
+ const qreal expectedScale = qBound(qreal(0.5), scale, qreal(4));
QPointF pinchPos(75, 75);
QPointF pinchLocalPos = target->mapFromScene(pinchPos);
// target position is adjusted in QQuickItemPrivate::adjustedPosForTransform()
// so as to compensate for the change in size, to hold the centroid in place
const QPointF expectedPos = targetPos + QPointF( (pinchPos.x() - target->x()) * (expectedScale - 1),
(pinchPos.y() - target->y()) * (expectedScale - 1) );
- QWindowSystemInterface::handleGestureEvent(window, ts++, touchpad,
+ QWindowSystemInterface::handleGestureEvent(window, ts++, touchpad.get(),
Qt::BeginNativeGesture, pinchPos, pinchPos);
- QWindowSystemInterface::handleGestureEventWithRealValue(window, ts++, touchpad,
- Qt::ZoomNativeGesture, expectedScale - 1, pinchPos, pinchPos);
+ if (lcPointerTests().isDebugEnabled()) QTest::qWait(500);
+ QWindowSystemInterface::handleGestureEventWithRealValue(window, ts++, touchpad.get(),
+ Qt::ZoomNativeGesture, scale - 1, pinchPos, pinchPos);
QTRY_COMPARE(target->scale(), expectedScale);
QCOMPARE(pinchHandler->active(), true);
- QCOMPARE(pinchHandler->centroid().position(), pinchLocalPos);
- QCOMPARE(pinchHandler->centroid().scenePosition(), pinchPos);
+ QCOMPARE(pinchHandler->centroid().position().toPoint(), pinchLocalPos.toPoint());
+ QCOMPARE(pinchHandler->centroid().scenePosition().toPoint(), pinchPos.toPoint());
QVERIFY(qAbs(target->position().x() - expectedPos.x()) < 0.001);
QVERIFY(qAbs(target->position().y() - expectedPos.y()) < 0.001);
QCOMPARE(pinchHandler->scale(), expectedScale);
QCOMPARE(pinchHandler->activeScale(), expectedScale);
QCOMPARE(pinchHandler->translation(), QVector2D());
QCOMPARE(pinchHandler->rotation(), 0);
- QWindowSystemInterface::handleGestureEvent(window, ts++, touchpad,
+ QWindowSystemInterface::handleGestureEvent(window, ts++, touchpad.get(),
Qt::EndNativeGesture, pinchPos, pinchPos);
QTRY_COMPARE(pinchHandler->active(), false);
QCOMPARE(target->scale(), expectedScale);
@@ -406,21 +441,24 @@ void tst_QQuickPinchHandler::scaleNativeGesture()
QCOMPARE(pinchHandler->translation(), QVector2D());
QCOMPARE(pinchHandler->rotation(), 0);
- // second pinch at a different position: scale it down to original size again
+ // second pinch at a different position: scale it back to original size again
+ // but remove the limits first, so that we can scale arbitrarily
+ pinchHandler->setMaximumScale(qInf());
+ pinchHandler->setMinimumScale(-qInf());
const qreal reverseScale = (1 / expectedScale);
- pinchPos = QPointF(125, 125);
+ pinchPos = QPointF(110, 110);
pinchLocalPos = target->mapFromScene(pinchPos);
- QWindowSystemInterface::handleGestureEvent(window, ts++, touchpad,
+ QWindowSystemInterface::handleGestureEvent(window, ts++, touchpad.get(),
Qt::BeginNativeGesture, pinchPos, pinchPos);
- QWindowSystemInterface::handleGestureEventWithRealValue(window, ts++, touchpad,
+ QWindowSystemInterface::handleGestureEventWithRealValue(window, ts++, touchpad.get(),
Qt::ZoomNativeGesture, reverseScale - 1, pinchPos, pinchPos);
QTRY_COMPARE(target->scale(), 1);
QCOMPARE(pinchHandler->active(), true);
- QCOMPARE(pinchHandler->centroid().position(), pinchLocalPos);
- QCOMPARE(pinchHandler->centroid().scenePosition(), pinchPos);
+ QCOMPARE(pinchHandler->centroid().position().toPoint(), pinchLocalPos.toPoint());
+ QCOMPARE(pinchHandler->centroid().scenePosition().toPoint(), pinchPos.toPoint());
QCOMPARE(pinchHandler->scale(), 1);
QCOMPARE(pinchHandler->activeScale(), reverseScale);
- QWindowSystemInterface::handleGestureEvent(window, ts++, touchpad,
+ QWindowSystemInterface::handleGestureEvent(window, ts++, touchpad.get(),
Qt::EndNativeGesture, pinchPos, pinchPos);
QTRY_COMPARE(pinchHandler->active(), false);
QCOMPARE(target->scale(), 1);
@@ -452,7 +490,7 @@ void tst_QQuickPinchHandler::pan()
QPoint p1(100, 100);
{
const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen);
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen.get());
pinchSequence.press(0, p0, window).commit();
QQuickTouchUtils::flush(window);
// In order for the stationary point to remember its previous position,
@@ -460,7 +498,7 @@ void tst_QQuickPinchHandler::pan()
pinchSequence.stationary(0).press(1, p1, window).commit();
QQuickTouchUtils::flush(window);
QVERIFY(!root->property("pinchActive").toBool());
- QCOMPARE(root->property("scale").toReal(), -1.0);
+ QCOMPARE(root->property("pinchScale").toReal(), -1.0);
p0 += QPoint(dragThreshold, 0);
p1 += QPoint(dragThreshold, 0);
@@ -468,7 +506,7 @@ void tst_QQuickPinchHandler::pan()
QQuickTouchUtils::flush(window);
// movement < dragThreshold: pinchHandler not yet active
QVERIFY(!root->property("pinchActive").toBool());
- QCOMPARE(root->property("scale").toReal(), -1.0);
+ QCOMPARE(root->property("pinchScale").toReal(), -1.0);
// just above the dragThreshold: pinchHandler starts
p0 += QPoint(1, 0);
@@ -476,7 +514,7 @@ void tst_QQuickPinchHandler::pan()
pinchSequence.move(0, p0, window).move(1, p1, window).commit();
QQuickTouchUtils::flush(window);
QCOMPARE(pinchHandler->active(), true);
- QCOMPARE(root->property("scale").toReal(), 1.0);
+ QCOMPARE(root->property("pinchScale").toReal(), 1.0);
// Calculation of the center point is tricky at first:
// center point of the two touch points in item coordinates:
@@ -518,13 +556,13 @@ void tst_QQuickPinchHandler::pan()
// pan x beyond bound
p0 += QPoint(100,100);
p1 += QPoint(100,100);
- QTest::touchEvent(window, touchscreen).move(0, p0, window).move(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).move(0, p0, window).move(1, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(blackRect->x(), 140.0);
QCOMPARE(blackRect->y(), 170.0);
- QTest::touchEvent(window, touchscreen).release(0, p0, window).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, p0, window).release(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(!root->property("pinchActive").toBool());
}
@@ -564,7 +602,7 @@ void tst_QQuickPinchHandler::dragAxesEnabled()
QPoint blackRectPos = blackRect->position().toPoint();
// press two points, one above the rectangle's center and one below
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen);
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen.get());
pinchSequence.press(0, p0, window).press(1, p1, window).commit();
QQuickTouchUtils::flush(window);
@@ -601,7 +639,7 @@ void tst_QQuickPinchHandler::dragAxesEnabled()
QCOMPARE(blackRect->position().toPoint().x(), xEnabled ? 140 : blackRectPos.x()); // because of xAxis.maximum
QCOMPARE(blackRect->position().toPoint().y(), yEnabled ? 170 : blackRectPos.y()); // because of yAxis.maximum
- QTest::touchEvent(window, touchscreen).release(0, p0, window).release(1, p1, window);
+ QTest::touchEvent(window, touchscreen.get()).release(0, p0, window).release(1, p1, window);
QQuickTouchUtils::flush(window);
}
@@ -630,7 +668,7 @@ void tst_QQuickPinchHandler::retouch()
QPoint p0(80, 80);
QPoint p1(100, 100);
{
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen);
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen.get());
pinchSequence.press(0, p0, window).commit();
QQuickTouchUtils::flush(window);
// In order for the stationary point to remember its previous position,
@@ -643,7 +681,7 @@ void tst_QQuickPinchHandler::retouch()
pinchSequence.move(0, p0,window).move(1, p1,window).commit();
QQuickTouchUtils::flush(window);
- QCOMPARE(root->property("scale").toReal(), 1.0);
+ QCOMPARE(root->property("pinchScale").toReal(), 1.0);
QCOMPARE(pinchHandler->active(), true);
p0 -= delta;
@@ -654,8 +692,8 @@ void tst_QQuickPinchHandler::retouch()
QCOMPARE(pinchHandler->active(), true);
// accept some slack
- QVERIFY(withinBounds(1.4, root->property("scale").toReal(), 1.6));
- QCOMPARE(pinchHandler->centroid().position(), QPointF(40, 40)); // blackrect is at 50,50
+ QVERIFY(withinBounds(1.4, root->property("pinchScale").toReal(), 1.6));
+ QCOMPARE(pinchHandler->centroid().position().toPoint(), QPoint(40, 40)); // blackrect is at 50,50
QVERIFY(withinBounds(1.4, blackRect->scale(), 1.6));
QCOMPARE(root->property("activeCount").toInt(), 1);
@@ -713,7 +751,7 @@ void tst_QQuickPinchHandler::cancel()
QPoint p0(80, 80);
QPoint p1(100, 100);
{
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen);
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, touchscreen.get());
pinchSequence.press(0, p0, window).commit();
QQuickTouchUtils::flush(window);
// In order for the stationary point to remember its previous position,
@@ -729,7 +767,7 @@ void tst_QQuickPinchHandler::cancel()
pinchSequence.move(0, p0,window).move(1, p1,window).commit();
QQuickTouchUtils::flush(window);
- QCOMPARE(root->property("scale").toReal(), 1.0);
+ QCOMPARE(root->property("pinchScale").toReal(), 1.0);
QCOMPARE(pinchHandler->active(), true);
p0 -= delta;
@@ -737,18 +775,18 @@ void tst_QQuickPinchHandler::cancel()
pinchSequence.move(0, p0,window).move(1, p1,window).commit();
QQuickTouchUtils::flush(window);
- QVERIFY(withinBounds(1.4, root->property("scale").toReal(), 1.6));
- QCOMPARE(pinchHandler->centroid().position(), QPointF(40, 40)); // blackrect is at 50,50
+ QVERIFY(withinBounds(1.4, root->property("pinchScale").toReal(), 1.6));
+ QCOMPARE(pinchHandler->centroid().position().toPoint(), QPoint(40, 40)); // blackrect is at 50,50
QVERIFY(withinBounds(1.4, blackRect->scale(), 1.6));
QSKIP("cancel is not supported atm");
- QTouchEvent cancelEvent(QEvent::TouchCancel, touchscreen);
+ QTouchEvent cancelEvent(QEvent::TouchCancel, touchscreen.get());
QCoreApplication::sendEvent(window, &cancelEvent);
QQuickTouchUtils::flush(window);
- QCOMPARE(root->property("scale").toReal(), 1.0);
- QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
+ QCOMPARE(root->property("pinchScale").toReal(), 1.0);
+ QCOMPARE(root->property("center").toPoint(), QPoint(40, 40)); // blackrect is at 50,50
QCOMPARE(blackRect->scale(), 1.0);
QVERIFY(!root->property("pinchActive").toBool());
}
@@ -799,7 +837,7 @@ void tst_QQuickPinchHandler::transformedpinchHandler()
const int threshold = qApp->styleHints()->startDragDistance();
{
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(view, touchscreen);
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(view, touchscreen.get());
// start pinchHandler
pinchSequence.press(0, p0, view).commit();
QQuickTouchUtils::flush(view);
diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
index eea1946316..1a32a25bd8 100644
--- a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
@@ -37,6 +37,7 @@ private slots:
void simultaneousMultiTouch();
void pressedMultipleButtons_data();
void pressedMultipleButtons();
+ void ignoreSystemSynthMouse();
private:
void createView(QScopedPointer<QQuickView> &window, const char *fileName);
@@ -82,20 +83,20 @@ void tst_PointHandler::singleTouch()
QTest::touchEvent(window, touchDevice).press(1, point, window);
QQuickTouchUtils::flush(window);
QTRY_COMPARE(handler->active(), true);
- QCOMPARE(activeSpy.count(), 1);
- QCOMPARE(pointSpy.count(), 1);
+ QCOMPARE(activeSpy.size(), 1);
+ QCOMPARE(pointSpy.size(), 1);
QCOMPARE(handler->point().position().toPoint(), point);
QCOMPARE(handler->point().scenePosition().toPoint(), point);
QCOMPARE(handler->point().pressedButtons(), Qt::NoButton);
QCOMPARE(handler->translation(), QVector2D());
- QCOMPARE(translationSpy.count(), 1);
+ QCOMPARE(translationSpy.size(), 1);
point += QPoint(10, 10);
QTest::touchEvent(window, touchDevice).move(1, point, window);
QQuickTouchUtils::flush(window);
QCOMPARE(handler->active(), true);
- QCOMPARE(activeSpy.count(), 1);
- QCOMPARE(pointSpy.count(), 2);
+ QCOMPARE(activeSpy.size(), 1);
+ QCOMPARE(pointSpy.size(), 2);
QCOMPARE(handler->point().position().toPoint(), point);
QCOMPARE(handler->point().scenePosition().toPoint(), point);
QCOMPARE(handler->point().pressPosition().toPoint(), QPoint(100, 100));
@@ -104,15 +105,15 @@ void tst_PointHandler::singleTouch()
QVERIFY(handler->point().velocity().x() > 0);
QVERIFY(handler->point().velocity().y() > 0);
QCOMPARE(handler->translation(), QVector2D(10, 10));
- QCOMPARE(translationSpy.count(), 2);
+ QCOMPARE(translationSpy.size(), 2);
QTest::touchEvent(window, touchDevice).release(1, point, window);
QQuickTouchUtils::flush(window);
QTRY_COMPARE(handler->active(), false);
- QCOMPARE(activeSpy.count(), 2);
- QCOMPARE(pointSpy.count(), 3);
+ QCOMPARE(activeSpy.size(), 2);
+ QCOMPARE(pointSpy.size(), 3);
QCOMPARE(handler->translation(), QVector2D());
- QCOMPARE(translationSpy.count(), 3);
+ QCOMPARE(translationSpy.size(), 3);
}
void tst_PointHandler::tabletStylus()
@@ -138,8 +139,8 @@ void tst_PointHandler::tabletStylus()
QWindowSystemInterface::handleTabletEvent(window, point, window->mapToGlobal(point),
int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::LeftButton, 0.5, 25, 35, 0.6, 12.3, 3, stylusId, Qt::NoModifier);
QTRY_COMPARE(handler->active(), true);
- QCOMPARE(activeSpy.count(), 1);
- QCOMPARE(pointSpy.count(), 1);
+ QCOMPARE(activeSpy.size(), 1);
+ QCOMPARE(pointSpy.size(), 1);
QCOMPARE(handler->point().position().toPoint(), pointLocalDPI);
QCOMPARE(handler->point().scenePosition().toPoint(), pointLocalDPI);
QCOMPARE(handler->point().pressedButtons(), Qt::LeftButton);
@@ -147,16 +148,16 @@ void tst_PointHandler::tabletStylus()
QCOMPARE(handler->point().rotation(), 12.3);
QCOMPARE(handler->point().uniqueId().numericId(), stylusId);
QCOMPARE(handler->translation(), QVector2D());
- QCOMPARE(translationSpy.count(), 1);
+ QCOMPARE(translationSpy.size(), 1);
QPoint delta(10, 10);
QPoint deltaLocalDPI = QHighDpi::fromNativeLocalPosition(delta, window);
point += delta;
QWindowSystemInterface::handleTabletEvent(window, point, window->mapToGlobal(point),
int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::LeftButton, 0.45, 23, 33, 0.57, 15.6, 3, stylusId, Qt::NoModifier);
- QTRY_COMPARE(pointSpy.count(), 2);
+ QTRY_COMPARE(pointSpy.size(), 2);
QCOMPARE(handler->active(), true);
- QCOMPARE(activeSpy.count(), 1);
+ QCOMPARE(activeSpy.size(), 1);
QCOMPARE(handler->point().position().toPoint(), pointLocalDPI + deltaLocalDPI);
QCOMPARE(handler->point().scenePosition().toPoint(), pointLocalDPI + deltaLocalDPI);
QCOMPARE(handler->point().pressPosition().toPoint(), pointLocalDPI);
@@ -168,15 +169,15 @@ void tst_PointHandler::tabletStylus()
QVERIFY(handler->point().velocity().x() > 0);
QVERIFY(handler->point().velocity().y() > 0);
QCOMPARE(handler->translation(), QVector2D(deltaLocalDPI));
- QCOMPARE(translationSpy.count(), 2);
+ QCOMPARE(translationSpy.size(), 2);
QWindowSystemInterface::handleTabletEvent(window, point, window->mapToGlobal(point),
int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::NoButton, 0, 0, 0, 0, 0, 0, stylusId, Qt::NoModifier);
QTRY_COMPARE(handler->active(), false);
- QCOMPARE(activeSpy.count(), 2);
- QCOMPARE(pointSpy.count(), 3);
+ QCOMPARE(activeSpy.size(), 2);
+ QCOMPARE(pointSpy.size(), 3);
QCOMPARE(handler->translation(), QVector2D());
- QCOMPARE(translationSpy.count(), 3);
+ QCOMPARE(translationSpy.size(), 3);
}
void tst_PointHandler::simultaneousMultiTouch()
@@ -185,7 +186,7 @@ void tst_PointHandler::simultaneousMultiTouch()
createView(windowPtr, "multiPointTracker.qml");
QQuickView * window = windowPtr.data();
QList<QQuickPointHandler *> handlers = window->rootObject()->findChildren<QQuickPointHandler *>();
- QCOMPARE(handlers.count(), 3);
+ QCOMPARE(handlers.size(), 3);
QVector<QSignalSpy*> activeSpies;
QVector<QSignalSpy*> pointSpies;
@@ -204,8 +205,8 @@ void tst_PointHandler::simultaneousMultiTouch()
int i = 0;
for (auto h : handlers) {
QTRY_COMPARE(h->active(), true);
- QCOMPARE(activeSpies[i]->count(), 1);
- QCOMPARE(pointSpies[i]->count(), 1);
+ QCOMPARE(activeSpies[i]->size(), 1);
+ QCOMPARE(pointSpies[i]->size(), 1);
int chosenPointIndex = points.indexOf(h->point().position().toPoint());
QVERIFY(chosenPointIndex != -1);
// Verify that each handler chose a unique point
@@ -215,7 +216,7 @@ void tst_PointHandler::simultaneousMultiTouch()
QCOMPARE(h->point().scenePosition().toPoint(), point);
QCOMPARE(h->point().pressedButtons(), Qt::NoButton);
QCOMPARE(h->translation(), QVector2D());
- QCOMPARE(translationSpies[i]->count(), 1);
+ QCOMPARE(translationSpies[i]->size(), 1);
++i;
}
@@ -226,8 +227,8 @@ void tst_PointHandler::simultaneousMultiTouch()
i = 0;
for (auto h : handlers) {
QCOMPARE(h->active(), true);
- QCOMPARE(activeSpies[i]->count(), 1);
- QCOMPARE(pointSpies[i]->count(), 2);
+ QCOMPARE(activeSpies[i]->size(), 1);
+ QCOMPARE(pointSpies[i]->size(), 2);
QCOMPARE(h->point().position().toPoint(), points[pointIndexPerHandler[i]]);
QCOMPARE(h->point().scenePosition().toPoint(), points[pointIndexPerHandler[i]]);
QCOMPARE(h->point().pressPosition().toPoint(), pressPoints[pointIndexPerHandler[i]]);
@@ -236,7 +237,7 @@ void tst_PointHandler::simultaneousMultiTouch()
QVERIFY(h->point().velocity().x() > 0);
QVERIFY(h->point().velocity().y() > 0);
QCOMPARE(h->translation(), QVector2D(10 + 10 * pointIndexPerHandler[i], 10 + 10 * pointIndexPerHandler[i] % 2));
- QCOMPARE(translationSpies[i]->count(), 2);
+ QCOMPARE(translationSpies[i]->size(), 2);
++i;
}
@@ -245,10 +246,10 @@ void tst_PointHandler::simultaneousMultiTouch()
i = 0;
for (auto h : handlers) {
QTRY_COMPARE(h->active(), false);
- QCOMPARE(activeSpies[i]->count(), 2);
- QCOMPARE(pointSpies[i]->count(), 3);
+ QCOMPARE(activeSpies[i]->size(), 2);
+ QCOMPARE(pointSpies[i]->size(), 3);
QCOMPARE(h->translation(), QVector2D());
- QCOMPARE(translationSpies[i]->count(), 3);
+ QCOMPARE(translationSpies[i]->size(), 3);
++i;
}
@@ -362,7 +363,7 @@ void tst_PointHandler::pressedMultipleButtons()
QPoint point(100,100);
- for (int i = 0; i < buttons.count(); ++i) {
+ for (int i = 0; i < buttons.size(); ++i) {
int btns = int(buttons.at(i));
int release = 0;
if (i > 0) {
@@ -382,8 +383,91 @@ void tst_PointHandler::pressedMultipleButtons()
QTest::mousePress(windowPtr.data(), Qt::NoButton, Qt::NoModifier, point);
QCOMPARE(handler->active(), false);
- QCOMPARE(activeSpy.count(), activeChangeCount);
- QCOMPARE(pointSpy.count(), changeCount);
+ QCOMPARE(activeSpy.size(), activeChangeCount);
+ QCOMPARE(pointSpy.size(), changeCount);
+}
+
+void tst_PointHandler::ignoreSystemSynthMouse() // QTBUG-104890
+{
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("pointTracker.qml")));
+ QQuickPointHandler *handler = window.rootObject()->findChild<QQuickPointHandler *>();
+ QVERIFY(handler);
+ auto devPriv = QPointingDevicePrivate::get(touchDevice);
+ QSignalSpy activeSpy(handler, SIGNAL(activeChanged()));
+ QSignalSpy pointSpy(handler, SIGNAL(pointChanged()));
+
+ // touch press
+ QPoint point(100,100);
+ QTest::touchEvent(&window, touchDevice).press(0, point, &window);
+ QQuickTouchUtils::flush(&window);
+
+ // touch move
+ point += QPoint(10, 10);
+ QTest::touchEvent(&window, touchDevice).move(0, point, &window);
+ QQuickTouchUtils::flush(&window);
+ QCOMPARE(handler->active(), true);
+ QCOMPARE(activeSpy.size(), 1);
+ QCOMPARE(pointSpy.size(), 2);
+ QVERIFY(devPriv->queryPointById(0)->passiveGrabbers.contains(handler));
+
+ // Windows begins to synthesize mouse events in parallel with the touch event stream: move to touchpoint position, then press
+ {
+ QMouseEvent move(QEvent::MouseMove, point, point, window.mapToGlobal(point),
+ Qt::NoButton, Qt::NoButton, Qt::NoModifier, Qt::MouseEventSynthesizedBySystem, touchDevice);
+ move.setTimestamp(235); // slightly after the last touch event
+ QGuiApplication::sendEvent(&window, &move);
+ }
+ QCOMPARE(handler->active(), true);
+ QCOMPARE(activeSpy.size(), 1);
+ QCOMPARE(pointSpy.size(), 2);
+ QVERIFY(devPriv->queryPointById(0)->passiveGrabbers.contains(handler));
+ {
+ QMouseEvent press(QEvent::MouseButtonPress, point, point, window.mapToGlobal(point),
+ Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedBySystem, touchDevice);
+ press.setTimestamp(235);
+ QGuiApplication::sendEvent(&window, &press);
+ }
+ QCOMPARE(handler->active(), true);
+ QCOMPARE(activeSpy.size(), 1);
+ QCOMPARE(pointSpy.size(), 2);
+ QVERIFY(devPriv->queryPointById(0)->passiveGrabbers.contains(handler));
+
+ // another touch move
+ point += QPoint(10, 10);
+ QTest::touchEvent(&window, touchDevice).move(0, point, &window);
+ QQuickTouchUtils::flush(&window);
+ QCOMPARE(handler->active(), true);
+ QCOMPARE(activeSpy.size(), 1);
+ QCOMPARE(pointSpy.size(), 3);
+ QCOMPARE(handler->point().position().toPoint(), point);
+ QCOMPARE(handler->point().scenePosition().toPoint(), point);
+ QCOMPARE(handler->point().pressPosition().toPoint(), QPoint(100, 100));
+ QCOMPARE(handler->point().scenePressPosition().toPoint(), QPoint(100, 100));
+ QVERIFY(devPriv->queryPointById(0)->passiveGrabbers.contains(handler));
+
+ // another fake mouse move
+ {
+ QMouseEvent move(QEvent::MouseMove, point, point, window.mapToGlobal(point),
+ Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedBySystem, touchDevice);
+ move.setTimestamp(240);
+ QGuiApplication::sendEvent(&window, &move);
+ }
+ QCOMPARE(handler->active(), true);
+ QCOMPARE(activeSpy.size(), 1);
+ QCOMPARE(pointSpy.size(), 3);
+ QCOMPARE(handler->point().position().toPoint(), point);
+ QCOMPARE(handler->point().scenePosition().toPoint(), point);
+ QCOMPARE(handler->point().pressPosition().toPoint(), QPoint(100, 100));
+ QCOMPARE(handler->point().scenePressPosition().toPoint(), QPoint(100, 100));
+ QVERIFY(devPriv->queryPointById(0)->passiveGrabbers.contains(handler));
+
+ // end with released state
+ QTest::touchEvent(&window, touchDevice).release(0, point, &window);
+ QMouseEvent release(QEvent::MouseButtonRelease, point, point, window.mapToGlobal(point),
+ Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedBySystem);
+ release.setTimestamp(280);
+ QGuiApplication::sendEvent(&window, &release);
}
QTEST_MAIN(tst_PointHandler)
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
index 3c016967ea..33d94a63e2 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
@@ -412,22 +412,22 @@ void tst_TapHandler::mouseGesturePolicyReleaseWithinBounds()
void tst_TapHandler::gesturePolicyDragWithinBounds_data()
{
- QTest::addColumn<QPointingDevice::DeviceType>("deviceType");
+ QTest::addColumn<const QPointingDevice *>("device");
QTest::addColumn<QPoint>("dragStart");
QTest::addColumn<QPoint>("dragDistance");
QTest::addColumn<QString>("expectedFeedback");
- QTest::newRow("mouse: click") << QPointingDevice::DeviceType::Mouse << QPoint(200, 200) << QPoint(0, 0) << "middle";
- QTest::newRow("touch: tap") << QPointingDevice::DeviceType::TouchScreen << QPoint(200, 200) << QPoint(0, 0) << "middle";
- QTest::newRow("mouse: drag up") << QPointingDevice::DeviceType::Mouse << QPoint(200, 200) << QPoint(0, -20) << "top";
- QTest::newRow("touch: drag up") << QPointingDevice::DeviceType::TouchScreen << QPoint(200, 200) << QPoint(0, -20) << "top";
- QTest::newRow("mouse: drag out to cancel") << QPointingDevice::DeviceType::Mouse << QPoint(435, 200) << QPoint(10, 0) << "canceled";
- QTest::newRow("touch: drag out to cancel") << QPointingDevice::DeviceType::TouchScreen << QPoint(435, 200) << QPoint(10, 0) << "canceled";
+ QTest::newRow("mouse: click") << QPointingDevice::primaryPointingDevice() << QPoint(200, 200) << QPoint(0, 0) << "middle";
+ QTest::newRow("touch: tap") << touchDevice << QPoint(200, 200) << QPoint(0, 0) << "middle";
+ QTest::newRow("mouse: drag up") << QPointingDevice::primaryPointingDevice() << QPoint(200, 200) << QPoint(0, -20) << "top";
+ QTest::newRow("touch: drag up") << touchDevice << QPoint(200, 200) << QPoint(0, -20) << "top";
+ QTest::newRow("mouse: drag out to cancel") << QPointingDevice::primaryPointingDevice() << QPoint(435, 200) << QPoint(10, 0) << "canceled";
+ QTest::newRow("touch: drag out to cancel") << touchDevice << QPoint(435, 200) << QPoint(10, 0) << "canceled";
}
void tst_TapHandler::gesturePolicyDragWithinBounds()
{
- QFETCH(QPointingDevice::DeviceType, deviceType);
+ QFETCH(const QPointingDevice *, device);
QFETCH(QPoint, dragStart);
QFETCH(QPoint, dragDistance);
QFETCH(QString, expectedFeedback);
@@ -439,33 +439,14 @@ void tst_TapHandler::gesturePolicyDragWithinBounds()
QVERIFY(tapHandler);
QSignalSpy canceledSpy(tapHandler, &QQuickTapHandler::canceled);
- switch (static_cast<QPointingDevice::DeviceType>(deviceType)) {
- case QPointingDevice::DeviceType::Mouse:
- QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, dragStart);
- QTRY_VERIFY(tapHandler->isPressed());
- QTest::mouseMove(&window, dragStart + dragDistance);
- if (expectedCanceled)
- QTRY_COMPARE(tapHandler->timeHeld(), -1);
- else
- QTRY_VERIFY(tapHandler->timeHeld() > 0.1);
- QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, dragStart + dragDistance);
- break;
- case QPointingDevice::DeviceType::TouchScreen:
- QTest::touchEvent(&window, touchDevice).press(0, dragStart, &window);
- QQuickTouchUtils::flush(&window);
- QTRY_VERIFY(tapHandler->isPressed());
- QTest::touchEvent(&window, touchDevice).move(0, dragStart + dragDistance, &window);
- QQuickTouchUtils::flush(&window);
- if (expectedCanceled)
- QTRY_COMPARE(tapHandler->timeHeld(), -1);
- else
- QTRY_VERIFY(tapHandler->timeHeld() > 0.1);
- QTest::touchEvent(&window, touchDevice).release(0, dragStart + dragDistance, &window);
- QQuickTouchUtils::flush(&window);
- break;
- default:
- break;
- }
+ QQuickTest::pointerPress(device, &window, 0, dragStart);
+ QTRY_VERIFY(tapHandler->isPressed());
+ QQuickTest::pointerMove(device, &window, 0, dragStart + dragDistance);
+ if (expectedCanceled)
+ QTRY_COMPARE(tapHandler->timeHeld(), -1);
+ else
+ QTRY_VERIFY(tapHandler->timeHeld() > 0.1);
+ QQuickTest::pointerRelease(device, &window, 0, dragStart + dragDistance);
QCOMPARE(window.rootObject()->property("feedbackText"), expectedFeedback);
if (expectedCanceled)
diff --git a/tests/auto/quick/pointerhandlers/qquickwheelhandler/tst_qquickwheelhandler.cpp b/tests/auto/quick/pointerhandlers/qquickwheelhandler/tst_qquickwheelhandler.cpp
index 3b9599e435..d87acc3200 100644
--- a/tests/auto/quick/pointerhandlers/qquickwheelhandler/tst_qquickwheelhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickwheelhandler/tst_qquickwheelhandler.cpp
@@ -165,13 +165,13 @@ void tst_QQuickWheelHandler::singleHandler()
sendWheelEvent(window, eventPos, eventAngleDelta, eventPixelDelta, eventModifiers, Qt::NoScrollPhase, eventInverted);
}
QCOMPARE(rect->position().toPoint(), expectedPosition);
- QCOMPARE(activeChangedSpy.count(), 1);
+ QCOMPARE(activeChangedSpy.size(), 1);
QCOMPARE(handler->active(), true);
QCOMPARE(rect->scale(), expectedScale);
QCOMPARE(rect->rotation(), expectedRotation);
if (!eventPhases) {
QTRY_COMPARE(handler->active(), false);
- QCOMPARE(activeChangedSpy.count(), 2);
+ QCOMPARE(activeChangedSpy.size(), 2);
}
// restore by rotating backwards
@@ -181,7 +181,7 @@ void tst_QQuickWheelHandler::singleHandler()
} else {
sendWheelEvent(window, eventPos, eventAngleDelta * -1, eventPixelDelta * -1, eventModifiers, Qt::NoScrollPhase, eventInverted);
}
- QCOMPARE(activeChangedSpy.count(), eventPhases ? 2 : 3);
+ QCOMPARE(activeChangedSpy.size(), eventPhases ? 2 : 3);
QCOMPARE(handler->active(), !eventPhases);
QCOMPARE(rect->position().toPoint(), QPoint(0, 0));
QCOMPARE(rect->scale(), 1);
@@ -306,13 +306,13 @@ void tst_QQuickWheelHandler::nestedHandler()
QCOMPARE(innerRect->scale(), innerScale);
QCOMPARE(innerRect->rotation(), innerRotation);
QCOMPARE(outerRect->position().toPoint(), outerPosition);
- QCOMPARE(outerActiveChangedSpy.count(), 1);
+ QCOMPARE(outerActiveChangedSpy.size(), 1);
QCOMPARE(outerHandler->active(), true);
QCOMPARE(outerRect->scale(), outerScale);
QCOMPARE(outerRect->rotation(), outerRotation);
if (!eventPhases) {
QTRY_COMPARE(outerHandler->active(), false);
- QCOMPARE(outerActiveChangedSpy.count(), 2);
+ QCOMPARE(outerActiveChangedSpy.size(), 2);
}
}
@@ -355,9 +355,9 @@ void tst_QQuickWheelHandler::blocking()
qreal outerPosWas = outerRect->position().x();
sendWheelEvent(window, eventPos, {0, 120}, {0, 0}, Qt::NoModifier, Qt::NoScrollPhase, false);
- QTRY_COMPARE(innerActiveChangedSpy.count(), 2);
+ QTRY_COMPARE(innerActiveChangedSpy.size(), 2);
QCOMPARE(innerRect->position().x(), innerPosWas + 15);
- QCOMPARE(outerActiveChangedSpy.count(), blocking ? 0 : 2);
+ QCOMPARE(outerActiveChangedSpy.size(), blocking ? 0 : 2);
QCOMPARE(outerRect->position().x(), outerPosWas + (blocking ? 0 : 15));
}
diff --git a/tests/auto/quick/propertyrequirements/tst_propertyrequirements.cpp b/tests/auto/quick/propertyrequirements/tst_propertyrequirements.cpp
index 4734382fc8..b8de922777 100644
--- a/tests/auto/quick/propertyrequirements/tst_propertyrequirements.cpp
+++ b/tests/auto/quick/propertyrequirements/tst_propertyrequirements.cpp
@@ -160,7 +160,7 @@ void tst_PropertyRequirements::testQmlType(TestDepth testDepth, const QQmlType &
inheritanceHierarchy.append(qmlType.metaObject());
}
- for (const QMetaObject *metaClass : qAsConst(inheritanceHierarchy)) {
+ for (const QMetaObject *metaClass : std::as_const(inheritanceHierarchy)) {
for (int idx = metaClass->propertyOffset(); idx < metaClass->propertyCount(); ++idx) {
const QMetaProperty property = metaClass->property(idx);
diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
index fa41dfd3d6..e7da38a5ce 100644
--- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
+++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
@@ -98,10 +98,10 @@ void tst_QQuickAccessible::cleanup()
{
const EventList list = QTestAccessibility::events();
if (!list.isEmpty()) {
- qWarning().noquote() << list.count()
+ qWarning().noquote() << list.size()
<< "accessibility event(s) were not handled in testfunction '"
<< QTest::currentTestFunction() << "':";
- for (int i = 0; i < list.count(); ++i) {
+ for (int i = 0; i < list.size(); ++i) {
auto object = list.at(i)->object();
QString objectInfo = object ? QDebug::toString(object)
: u"[deleted object]"_s;
diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
index 8be86cdec4..1a01a8aca5 100644
--- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
+++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
@@ -132,10 +132,10 @@ void tst_qquickanimatedimage::frameCount()
const QUrl origSource = anim->source();
anim->setSource(QUrl());
QCOMPARE(anim->frameCount(), 0);
- QCOMPARE(frameCountChangedSpy.count(), 1);
+ QCOMPARE(frameCountChangedSpy.size(), 1);
anim->setSource(origSource);
QCOMPARE(anim->frameCount(), 3);
- QCOMPARE(frameCountChangedSpy.count(), 2);
+ QCOMPARE(frameCountChangedSpy.size(), 2);
delete anim;
}
@@ -169,13 +169,13 @@ void tst_qquickanimatedimage::mirror_running()
QVERIFY(spy.isValid());
anim->setPlaying(true);
- QTRY_VERIFY(spy.count() == 1); spy.clear();
+ QTRY_VERIFY(spy.size() == 1); spy.clear();
anim->setMirror(true);
QCOMPARE(anim->currentFrame(), 1);
QImage frame1_flipped = window.grabWindow();
- QTRY_VERIFY(spy.count() == 1); spy.clear();
+ QTRY_VERIFY(spy.size() == 1); spy.clear();
QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first
QImage frame0_flipped = window.grabWindow();
@@ -336,48 +336,48 @@ void tst_qquickanimatedimage::sourceSizeChanges()
// Local
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Null);
- QTRY_COMPARE(sourceSizeSpy.count(), 0);
+ QTRY_COMPARE(sourceSizeSpy.size(), 0);
ctxt->setContextProperty("srcImage", testFileUrl("hearts.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
+ QTRY_COMPARE(sourceSizeSpy.size(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("hearts.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
+ QTRY_COMPARE(sourceSizeSpy.size(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("hearts_copy.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
+ QTRY_COMPARE(sourceSizeSpy.size(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("colors.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 2);
+ QTRY_COMPARE(sourceSizeSpy.size(), 2);
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Null);
- QTRY_COMPARE(sourceSizeSpy.count(), 3);
+ QTRY_COMPARE(sourceSizeSpy.size(), 3);
// Remote
ctxt->setContextProperty("srcImage", server.url("/hearts.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 4);
+ QTRY_COMPARE(sourceSizeSpy.size(), 4);
ctxt->setContextProperty("srcImage", server.url("/hearts.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 4);
+ QTRY_COMPARE(sourceSizeSpy.size(), 4);
ctxt->setContextProperty("srcImage", server.url("/hearts_copy.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 4);
+ QTRY_COMPARE(sourceSizeSpy.size(), 4);
ctxt->setContextProperty("srcImage", server.url("/colors.gif"));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 5);
+ QTRY_COMPARE(sourceSizeSpy.size(), 5);
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Null);
- QTRY_COMPARE(sourceSizeSpy.count(), 6);
+ QTRY_COMPARE(sourceSizeSpy.size(), 6);
delete anim;
}
@@ -453,17 +453,17 @@ void tst_qquickanimatedimage::progressAndStatusChanges()
ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif"));
QTRY_COMPARE(obj->status(), QQuickImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 0);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 0);
+ QTRY_COMPARE(sourceSpy.size(), 0);
+ QTRY_COMPARE(progressSpy.size(), 0);
+ QTRY_COMPARE(statusSpy.size(), 0);
// Loading local file
ctxt->setContextProperty("srcImage", testFileUrl("colors.gif"));
QTRY_COMPARE(obj->status(), QQuickImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 1);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 1);
+ QTRY_COMPARE(sourceSpy.size(), 1);
+ QTRY_COMPARE(progressSpy.size(), 0);
+ QTRY_COMPARE(statusSpy.size(), 1);
// Loading remote file
ctxt->setContextProperty("srcImage", server.url("/stickman.gif"));
@@ -471,16 +471,16 @@ void tst_qquickanimatedimage::progressAndStatusChanges()
QTRY_COMPARE(obj->progress(), 0.0);
QTRY_COMPARE(obj->status(), QQuickImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 2);
- QTRY_VERIFY(progressSpy.count() > 1);
- QTRY_COMPARE(statusSpy.count(), 3);
+ QTRY_COMPARE(sourceSpy.size(), 2);
+ QTRY_VERIFY(progressSpy.size() > 1);
+ QTRY_COMPARE(statusSpy.size(), 3);
ctxt->setContextProperty("srcImage", "");
QTRY_COMPARE(obj->status(), QQuickImage::Null);
QTRY_COMPARE(obj->progress(), 0.0);
- QTRY_COMPARE(sourceSpy.count(), 3);
- QTRY_VERIFY(progressSpy.count() > 2);
- QTRY_COMPARE(statusSpy.count(), 4);
+ QTRY_COMPARE(sourceSpy.size(), 3);
+ QTRY_VERIFY(progressSpy.size() > 2);
+ QTRY_COMPARE(statusSpy.size(), 4);
delete obj;
}
@@ -506,40 +506,40 @@ void tst_qquickanimatedimage::playingAndPausedChanges()
obj->setProperty("paused", false);
QTRY_VERIFY(obj->isPlaying());
QTRY_VERIFY(!obj->isPaused());
- QTRY_COMPARE(playingSpy.count(), 0);
- QTRY_COMPARE(pausedSpy.count(), 0);
+ QTRY_COMPARE(playingSpy.size(), 0);
+ QTRY_COMPARE(pausedSpy.size(), 0);
obj->setProperty("playing", false);
obj->setProperty("paused", true);
QTRY_VERIFY(!obj->isPlaying());
QTRY_VERIFY(obj->isPaused());
- QTRY_COMPARE(playingSpy.count(), 1);
- QTRY_COMPARE(pausedSpy.count(), 1);
+ QTRY_COMPARE(playingSpy.size(), 1);
+ QTRY_COMPARE(pausedSpy.size(), 1);
obj->setProperty("playing", true);
obj->setProperty("paused", false);
QTRY_VERIFY(obj->isPlaying());
QTRY_VERIFY(!obj->isPaused());
- QTRY_COMPARE(playingSpy.count(), 2);
- QTRY_COMPARE(pausedSpy.count(), 2);
+ QTRY_COMPARE(playingSpy.size(), 2);
+ QTRY_COMPARE(pausedSpy.size(), 2);
ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif"));
QTRY_VERIFY(obj->isPlaying());
QTRY_VERIFY(!obj->isPaused());
- QTRY_COMPARE(playingSpy.count(), 2);
- QTRY_COMPARE(pausedSpy.count(), 2);
+ QTRY_COMPARE(playingSpy.size(), 2);
+ QTRY_COMPARE(pausedSpy.size(), 2);
obj->setProperty("paused", true);
QTRY_VERIFY(obj->isPlaying());
QTRY_VERIFY(obj->isPaused());
- QTRY_COMPARE(playingSpy.count(), 2);
- QTRY_COMPARE(pausedSpy.count(), 3);
+ QTRY_COMPARE(playingSpy.size(), 2);
+ QTRY_COMPARE(pausedSpy.size(), 3);
obj->setProperty("playing", false);
QTRY_VERIFY(!obj->isPlaying());
QTRY_VERIFY(!obj->isPaused());
- QTRY_COMPARE(playingSpy.count(), 3);
- QTRY_COMPARE(pausedSpy.count(), 4);
+ QTRY_COMPARE(playingSpy.size(), 3);
+ QTRY_COMPARE(pausedSpy.size(), 4);
obj->setProperty("playing", true);
@@ -547,8 +547,8 @@ void tst_qquickanimatedimage::playingAndPausedChanges()
ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
QTRY_VERIFY(!obj->isPlaying());
QTRY_VERIFY(!obj->isPaused());
- QTRY_COMPARE(playingSpy.count(), 5);
- QTRY_COMPARE(pausedSpy.count(), 4);
+ QTRY_COMPARE(playingSpy.size(), 5);
+ QTRY_COMPARE(pausedSpy.size(), 4);
delete obj;
}
@@ -626,15 +626,15 @@ void tst_qquickanimatedimage::currentFrame()
anim->setCurrentFrame(1);
QCOMPARE(anim->currentFrame(), 1);
- QCOMPARE(frameChangedSpy.count(), 1);
- QCOMPARE(currentFrameChangedSpy.count(), 1);
+ QCOMPARE(frameChangedSpy.size(), 1);
+ QCOMPARE(currentFrameChangedSpy.size(), 1);
QCOMPARE(anim->property("currentFrameChangeCount"), 1);
QCOMPARE(anim->property("frameChangeCount"), 1);
evaluate<void>(anim, "scriptedSetCurrentFrame(2)");
QCOMPARE(anim->currentFrame(), 2);
- QCOMPARE(frameChangedSpy.count(), 2);
- QCOMPARE(currentFrameChangedSpy.count(), 2);
+ QCOMPARE(frameChangedSpy.size(), 2);
+ QCOMPARE(currentFrameChangedSpy.size(), 2);
QCOMPARE(anim->property("currentFrameChangeCount"), 2);
QCOMPARE(anim->property("frameChangeCount"), 2);
}
diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
index c9f16af86a..72c807bdf8 100644
--- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
+++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
@@ -63,7 +63,7 @@ void tst_qquickanimatedsprite::test_properties()
sprite->setRunning(false);
QVERIFY(!sprite->running());
// The finished() signal shouldn't be emitted when running is manually set to false.
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
sprite->setInterpolate(false);
QVERIFY(!sprite->interpolate());
}
@@ -87,11 +87,11 @@ void tst_qquickanimatedsprite::test_runningChangedSignal()
QVERIFY(finishedSpy.isValid());
sprite->setRunning(true);
- QTRY_COMPARE(runningChangedSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 0);
+ QTRY_COMPARE(runningChangedSpy.size(), 1);
+ QCOMPARE(finishedSpy.size(), 0);
QTRY_VERIFY(!sprite->running());
- QTRY_COMPARE(runningChangedSpy.count(), 2);
- QCOMPARE(finishedSpy.count(), 1);
+ QTRY_COMPARE(runningChangedSpy.size(), 2);
+ QCOMPARE(finishedSpy.size(), 1);
}
void tst_qquickanimatedsprite::test_startStop()
@@ -114,12 +114,12 @@ void tst_qquickanimatedsprite::test_startStop()
sprite->start();
QVERIFY(sprite->running());
- QTRY_COMPARE(runningChangedSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 0);
+ QTRY_COMPARE(runningChangedSpy.size(), 1);
+ QCOMPARE(finishedSpy.size(), 0);
sprite->stop();
QVERIFY(!sprite->running());
- QTRY_COMPARE(runningChangedSpy.count(), 2);
- QCOMPARE(finishedSpy.count(), 0);
+ QTRY_COMPARE(runningChangedSpy.size(), 2);
+ QCOMPARE(finishedSpy.size(), 0);
sprite->setCurrentFrame(2);
sprite->start();
@@ -154,12 +154,12 @@ void tst_qquickanimatedsprite::test_frameChangedSignal()
QVERIFY(!sprite->paused());
QCOMPARE(sprite->loops(), 3);
QCOMPARE(sprite->frameCount(), 6);
- QCOMPARE(frameChangedSpy.count(), 0);
+ QCOMPARE(frameChangedSpy.size(), 0);
frameChangedSpy.clear();
sprite->setRunning(true);
QTRY_VERIFY(!sprite->running());
- QCOMPARE(frameChangedSpy.count(), 3*6 + 1);
+ QCOMPARE(frameChangedSpy.size(), 3*6 + 1);
int prevFrame = -1;
int loopCounter = 0;
@@ -257,7 +257,7 @@ void tst_qquickanimatedsprite::test_largeAnimation()
sprite->setRunning(true);
QTRY_VERIFY_WITH_TIMEOUT(!sprite->running(), 100000 /* make sure we wait until its done*/ );
if (frameSync)
- QVERIFY(isWithinRange(3*40, int(frameChangedSpy.count()), 3*40 + 1));
+ QVERIFY(isWithinRange(3*40, int(frameChangedSpy.size()), 3*40 + 1));
int prevFrame = -1;
int loopCounter = 0;
int maxFrame = 0;
@@ -375,8 +375,8 @@ void tst_qquickanimatedsprite::test_implicitSize()
QVERIFY(frameImplicitWidthChangedSpy.isValid());
sprite->setFrameWidth(20);
- QCOMPARE(frameWidthChangedSpy.count(), 1);
- QCOMPARE(frameImplicitWidthChangedSpy.count(), 1);
+ QCOMPARE(frameWidthChangedSpy.size(), 1);
+ QCOMPARE(frameImplicitWidthChangedSpy.size(), 1);
// Ensure that implicitHeight matches frameHeight.
QSignalSpy frameHeightChangedSpy(sprite, SIGNAL(frameHeightChanged(int)));
@@ -386,8 +386,8 @@ void tst_qquickanimatedsprite::test_implicitSize()
QVERIFY(frameImplicitHeightChangedSpy.isValid());
sprite->setFrameHeight(20);
- QCOMPARE(frameHeightChangedSpy.count(), 1);
- QCOMPARE(frameImplicitHeightChangedSpy.count(), 1);
+ QCOMPARE(frameHeightChangedSpy.size(), 1);
+ QCOMPARE(frameImplicitHeightChangedSpy.size(), 1);
}
void tst_qquickanimatedsprite::test_infiniteLoops()
@@ -409,7 +409,7 @@ void tst_qquickanimatedsprite::test_infiniteLoops()
// The finished() signal shouldn't be emitted for infinite animations.
const int previousFrame = sprite->currentFrame();
QTRY_VERIFY(sprite->currentFrame() != previousFrame);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
}
void tst_qquickanimatedsprite::test_finishBehavior()
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index 4b0e38ba65..f7a84ca979 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -121,8 +121,8 @@ void tst_qquickanimations::simpleProperty()
QCOMPARE(animation.target(), &rect);
QCOMPARE(animation.property(), QLatin1String("x"));
QCOMPARE(animation.to().toReal(), 200.0);
- QCOMPARE(fromChangedSpy.count(), 0);
- QCOMPARE(toChangedSpy.count(), 1);
+ QCOMPARE(fromChangedSpy.size(), 0);
+ QCOMPARE(toChangedSpy.size(), 1);
animation.start();
QVERIFY(animation.isRunning());
QTest::qWait(animation.duration());
@@ -137,8 +137,8 @@ void tst_qquickanimations::simpleProperty()
QCOMPARE(animation.currentTime(), 125);
QCOMPARE(rect.x(),100.0);
animation.setFrom(100);
- QCOMPARE(fromChangedSpy.count(), 1);
- QCOMPARE(toChangedSpy.count(), 1);
+ QCOMPARE(fromChangedSpy.size(), 1);
+ QCOMPARE(toChangedSpy.size(), 1);
}
void tst_qquickanimations::simpleNumber()
@@ -153,8 +153,8 @@ void tst_qquickanimations::simpleNumber()
QCOMPARE(animation.target(), &rect);
QCOMPARE(animation.property(), QLatin1String("x"));
QCOMPARE(animation.to(), qreal(200));
- QCOMPARE(fromChangedSpy.count(), 0);
- QCOMPARE(toChangedSpy.count(), 1);
+ QCOMPARE(fromChangedSpy.size(), 0);
+ QCOMPARE(toChangedSpy.size(), 1);
animation.start();
QVERIFY(animation.isRunning());
QTest::qWait(animation.duration());
@@ -169,8 +169,8 @@ void tst_qquickanimations::simpleNumber()
QCOMPARE(animation.currentTime(), 125);
QCOMPARE(rect.x(), qreal(100));
animation.setFrom(100);
- QCOMPARE(fromChangedSpy.count(), 1);
- QCOMPARE(toChangedSpy.count(), 1);
+ QCOMPARE(fromChangedSpy.size(), 1);
+ QCOMPARE(toChangedSpy.size(), 1);
}
void tst_qquickanimations::simpleColor()
@@ -185,8 +185,8 @@ void tst_qquickanimations::simpleColor()
QCOMPARE(animation.target(), &rect);
QCOMPARE(animation.property(), QLatin1String("color"));
QCOMPARE(animation.to(), QColor("red"));
- QCOMPARE(fromChangedSpy.count(), 0);
- QCOMPARE(toChangedSpy.count(), 1);
+ QCOMPARE(fromChangedSpy.size(), 0);
+ QCOMPARE(toChangedSpy.size(), 1);
animation.start();
QVERIFY(animation.isRunning());
QTest::qWait(animation.duration());
@@ -204,8 +204,8 @@ void tst_qquickanimations::simpleColor()
rect.setColor(QColor("green"));
animation.setFrom(QColor("blue"));
QCOMPARE(animation.from(), QColor("blue"));
- QCOMPARE(fromChangedSpy.count(), 1);
- QCOMPARE(toChangedSpy.count(), 1);
+ QCOMPARE(fromChangedSpy.size(), 1);
+ QCOMPARE(toChangedSpy.size(), 1);
animation.restart();
QCOMPARE(rect.color(), QColor("blue"));
QVERIFY(animation.isRunning());
@@ -226,8 +226,8 @@ void tst_qquickanimations::simpleRotation()
QCOMPARE(animation.property(), QLatin1String("rotation"));
QCOMPARE(animation.to(), qreal(270));
QCOMPARE(animation.direction(), QQuickRotationAnimation::Numerical);
- QCOMPARE(fromChangedSpy.count(), 0);
- QCOMPARE(toChangedSpy.count(), 1);
+ QCOMPARE(fromChangedSpy.size(), 0);
+ QCOMPARE(toChangedSpy.size(), 1);
animation.start();
QVERIFY(animation.isRunning());
QTest::qWait(animation.duration());
@@ -242,8 +242,8 @@ void tst_qquickanimations::simpleRotation()
QCOMPARE(animation.currentTime(), 125);
QCOMPARE(rect.rotation(), qreal(135));
animation.setFrom(90);
- QCOMPARE(fromChangedSpy.count(), 1);
- QCOMPARE(toChangedSpy.count(), 1);
+ QCOMPARE(fromChangedSpy.size(), 1);
+ QCOMPARE(toChangedSpy.size(), 1);
}
void tst_qquickanimations::simplePath()
@@ -667,11 +667,11 @@ void tst_qquickanimations::resume()
QSignalSpy spy(&animation, SIGNAL(pausedChanged(bool)));
animation.pause();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QVERIFY(animation.isPaused());
animation.stop();
QVERIFY(!animation.isPaused());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
// Load QtQuick to ensure that QQuickPropertyAnimation is registered as PropertyAnimation
{
@@ -683,12 +683,12 @@ void tst_qquickanimations::resume()
QByteArray message = "<Unknown File>: QML PropertyAnimation: setPaused() cannot be used when animation isn't running.";
QTest::ignoreMessage(QtWarningMsg, message);
animation.pause();
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QVERIFY(!animation.isPaused());
animation.resume();
QVERIFY(!animation.isPaused());
QVERIFY(!animation.isRunning());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_qquickanimations::dotProperty()
@@ -727,7 +727,7 @@ void tst_qquickanimations::badTypes()
QScopedPointer<QObject> obj(c.create());
QVERIFY(obj.isNull());
- QCOMPARE(c.errors().count(), 1);
+ QCOMPARE(c.errors().size(), 1);
QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected"));
}
@@ -739,7 +739,7 @@ void tst_qquickanimations::badTypes()
QScopedPointer<QObject> obj(c.create());
QVERIFY(obj.isNull());
- QCOMPARE(c.errors().count(), 1);
+ QCOMPARE(c.errors().size(), 1);
QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected"));
}
@@ -1047,12 +1047,12 @@ void tst_qquickanimations::disabledTransition()
QSignalSpy runningSpy(trans, SIGNAL(runningChanged()));
QQuickItemPrivate::get(rect)->setState("");
QCOMPARE(myRect->x(),qreal(200));
- QCOMPARE(runningSpy.count(), 1); //stopped -> running
+ QCOMPARE(runningSpy.size(), 1); //stopped -> running
QVERIFY(trans->running());
QTest::qWait(300);
QTIMED_COMPARE(myRect->x(),qreal(100));
QVERIFY(!trans->running());
- QCOMPARE(runningSpy.count(), 2); //running -> stopped
+ QCOMPARE(runningSpy.size(), 2); //running -> stopped
}
void tst_qquickanimations::invalidDuration()
@@ -1226,7 +1226,7 @@ void tst_qquickanimations::easingProperties()
QVERIFY(animObject != nullptr);
QCOMPARE(animObject->easing().type(), QEasingCurve::BezierSpline);
QVector<QPointF> points = animObject->easing().toCubicSpline();
- QCOMPARE(points.count(), 3);
+ QCOMPARE(points.size(), 3);
QCOMPARE(points.at(0), QPointF(0.5, 0.2));
QCOMPARE(points.at(1), QPointF(0.13, 0.65));
QCOMPARE(points.at(2), QPointF(1.0, 1.0));
@@ -1355,7 +1355,7 @@ void tst_qquickanimations::signalOrder()
colorAnimation->setDuration(duration);
animation->start();
- QTRY_VERIFY(finishedSpy.count());
+ QTRY_VERIFY(finishedSpy.size());
QCOMPARE(actualSignalOrder, expectedSignalOrder);
}
@@ -1678,7 +1678,7 @@ void tst_qquickanimations::unsetAnimatorProxyJobWindow()
item.setParentItem(&dummy);
QSignalSpy spy(&window, SIGNAL(sceneGraphInitialized()));
window.show();
- if (spy.count() < 1)
+ if (spy.size() < 1)
spy.wait();
QCOMPARE(proxy.job().data(), job);
}
@@ -1705,8 +1705,8 @@ void tst_qquickanimations::finished()
QVERIFY(finishedSpy.isValid());
QVERIFY(simpleTopLevelAnimation->setProperty("running", QVariant(true)));
- QTRY_COMPARE(stoppedSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 1);
+ QTRY_COMPARE(stoppedSpy.size(), 1);
+ QCOMPARE(finishedSpy.size(), 1);
// Test that the signal is properly revisioned and hence accessible from QML.
QCOMPARE(root->property("finishedUsableInQml").toBool(), true);
@@ -1733,9 +1733,9 @@ void tst_qquickanimations::finished()
QObject *transitionRect = root->property("transitionRect").value<QObject*>();
QVERIFY(transitionRect);
QVERIFY(transitionRect->setProperty("state", QVariant(QLatin1String("go"))));
- QTRY_COMPARE(runningChangedSpy.count(), 1);
- QCOMPARE(stoppedSpy.count(), 0);
- QCOMPARE(finishedSpy.count(), 0);
+ QTRY_COMPARE(runningChangedSpy.size(), 1);
+ QCOMPARE(stoppedSpy.size(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
}
// Test that finished() is not emitted for animations within a Behavior.
@@ -1752,8 +1752,8 @@ void tst_qquickanimations::finished()
QVERIFY(root->setProperty("bar", QVariant(1.0)));
QTRY_COMPARE(root->property("bar").toReal(), 1.0);
- QCOMPARE(stoppedSpy.count(), 0);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(stoppedSpy.size(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
}
}
@@ -2095,8 +2095,8 @@ void tst_qquickanimations::changePropertiesDuringAnimation()
// mid-animation.
if (loops != QQuickAbstractAnimation::Infinite)
QVERIFY(numberAnimation->qtAnimation()->currentLoop() < numberAnimation->loops());
- QCOMPARE(startedSpy.count(), 0);
- QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(startedSpy.size(), 0);
+ QCOMPARE(stoppedSpy.size(), 0);
}
void tst_qquickanimations::infiniteLoopsWithoutFrom()
diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
index e65a67c045..5ea11729d8 100644
--- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
+++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
@@ -341,7 +341,7 @@ void tst_qquickbehaviors::runningTrue()
QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool)));
rect->setProperty("myValue", 180);
- QTRY_VERIFY(runningSpy.count() > 0);
+ QTRY_VERIFY(runningSpy.size() > 0);
}
//QTBUG-12295
@@ -579,7 +579,7 @@ void tst_qquickbehaviors::aliasedProperty()
QSignalSpy targetValueSpy(behavior, SIGNAL(targetValueChanged()));
QQuickItemPrivate::get(rect.data())->setState("moved");
QCOMPARE(behavior->targetValue(), 400);
- QCOMPARE(targetValueSpy.count(), 1);
+ QCOMPARE(targetValueSpy.size(), 1);
QScopedPointer<QQuickRectangle> acc(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("acc")));
QScopedPointer<QQuickRectangle> range(qobject_cast<QQuickRectangle*>(acc->findChild<QQuickRectangle*>("range")));
QTRY_VERIFY(acc->property("value").toDouble() > 0);
@@ -615,7 +615,7 @@ void tst_qquickbehaviors::oneWay()
QQuickRectangle *myRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRectOneWay"));
myRect->setProperty("x", 100);
QCOMPARE(behavior->targetValue(), 100);
- QCOMPARE(targetValueSpy.count(), 1);
+ QCOMPARE(targetValueSpy.size(), 1);
QCOMPARE(behavior->enabled(), false);
qreal x = myRect->x();
QCOMPARE(x, qreal(100)); //should change immediately
@@ -625,7 +625,7 @@ void tst_qquickbehaviors::oneWay()
myRect->setProperty("x", 0);
QCOMPARE(behavior->targetValue(), 0);
- QCOMPARE(targetValueSpy.count(), 2);
+ QCOMPARE(targetValueSpy.size(), 2);
QCOMPARE(behavior->enabled(), true);
QCOMPARE(myAnimation->isRunning(), true);
QVERIFY(myRect->x() > 0.0);
diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
index 793ab8d8c9..a217c4ea1b 100644
--- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
+++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
@@ -435,7 +435,7 @@ void tst_qquickborderimage::statusChanges()
if (remote)
server.sendDelayedItem();
QTRY_COMPARE(obj->status(), finalStatus);
- QCOMPARE(spy.count(), emissions);
+ QCOMPARE(spy.size(), emissions);
delete obj;
}
@@ -460,48 +460,48 @@ void tst_qquickborderimage::sourceSizeChanges()
// Local
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Null);
- QTRY_COMPARE(sourceSizeSpy.count(), 0);
+ QTRY_COMPARE(sourceSizeSpy.size(), 0);
ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
+ QTRY_COMPARE(sourceSizeSpy.size(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
+ QTRY_COMPARE(sourceSizeSpy.size(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("heart200_copy.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
+ QTRY_COMPARE(sourceSizeSpy.size(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 2);
+ QTRY_COMPARE(sourceSizeSpy.size(), 2);
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Null);
- QTRY_COMPARE(sourceSizeSpy.count(), 3);
+ QTRY_COMPARE(sourceSizeSpy.size(), 3);
// Remote
ctxt->setContextProperty("srcImage", server.url("/heart200.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 4);
+ QTRY_COMPARE(sourceSizeSpy.size(), 4);
ctxt->setContextProperty("srcImage", server.url("/heart200.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 4);
+ QTRY_COMPARE(sourceSizeSpy.size(), 4);
ctxt->setContextProperty("srcImage", server.url("/heart200_copy.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 4);
+ QTRY_COMPARE(sourceSizeSpy.size(), 4);
ctxt->setContextProperty("srcImage", server.url("/colors.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 5);
+ QTRY_COMPARE(sourceSizeSpy.size(), 5);
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Null);
- QTRY_COMPARE(sourceSizeSpy.count(), 6);
+ QTRY_COMPARE(sourceSizeSpy.size(), 6);
delete obj;
}
@@ -532,17 +532,17 @@ void tst_qquickborderimage::progressAndStatusChanges()
ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 0);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 0);
+ QTRY_COMPARE(sourceSpy.size(), 0);
+ QTRY_COMPARE(progressSpy.size(), 0);
+ QTRY_COMPARE(statusSpy.size(), 0);
// Loading local file
ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 1);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 1);
+ QTRY_COMPARE(sourceSpy.size(), 1);
+ QTRY_COMPARE(progressSpy.size(), 0);
+ QTRY_COMPARE(statusSpy.size(), 1);
// Loading remote file
ctxt->setContextProperty("srcImage", server.url("/heart200.png"));
@@ -550,16 +550,16 @@ void tst_qquickborderimage::progressAndStatusChanges()
QTRY_COMPARE(obj->progress(), 0.0);
QTRY_COMPARE(obj->status(), QQuickBorderImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 2);
- QTRY_VERIFY(progressSpy.count() > 1);
- QTRY_COMPARE(statusSpy.count(), 3);
+ QTRY_COMPARE(sourceSpy.size(), 2);
+ QTRY_VERIFY(progressSpy.size() > 1);
+ QTRY_COMPARE(statusSpy.size(), 3);
ctxt->setContextProperty("srcImage", "");
QTRY_COMPARE(obj->status(), QQuickBorderImage::Null);
QTRY_COMPARE(obj->progress(), 0.0);
- QTRY_COMPARE(sourceSpy.count(), 3);
- QTRY_VERIFY(progressSpy.count() > 2);
- QTRY_COMPARE(statusSpy.count(), 4);
+ QTRY_COMPARE(sourceSpy.size(), 3);
+ QTRY_VERIFY(progressSpy.size() > 2);
+ QTRY_COMPARE(statusSpy.size(), 4);
delete obj;
}
@@ -614,7 +614,7 @@ void tst_qquickborderimage::multiFrame()
if (asynchronous) {
QCOMPARE(image->frameCount(), 0);
QTRY_COMPARE(image->frameCount(), 4);
- QCOMPARE(countSpy.count(), 1);
+ QCOMPARE(countSpy.size(), 1);
} else {
QCOMPARE(image->frameCount(), 4);
}
@@ -636,7 +636,7 @@ void tst_qquickborderimage::multiFrame()
image->setCurrentFrame(1);
QTRY_COMPARE(image->status(), QQuickImageBase::Ready);
- QCOMPARE(currentSpy.count(), 1);
+ QCOMPARE(currentSpy.size(), 1);
QCOMPARE(image->currentFrame(), 1);
contents = view.grabWindow();
// The middle of the second frame looks green, approximately qRgba(0x3a, 0xd2, 0x31, 0xff)
diff --git a/tests/auto/quick/qquickboundaryrule/tst_qquickboundaryrule.cpp b/tests/auto/quick/qquickboundaryrule/tst_qquickboundaryrule.cpp
index dab29e21cc..1aa926ab19 100644
--- a/tests/auto/quick/qquickboundaryrule/tst_qquickboundaryrule.cpp
+++ b/tests/auto/quick/qquickboundaryrule/tst_qquickboundaryrule.cpp
@@ -54,25 +54,25 @@ void tst_qquickboundaryrule::dragHandler()
QVERIFY(ok);
QCOMPARE(boundaryRule->property("peakOvershoot").toReal(&ok), 0);
QVERIFY(ok);
- QCOMPARE(overshootChangedSpy.count(), 0);
+ QCOMPARE(overshootChangedSpy.size(), 0);
// restricted drag: halfway into overshoot
p1 += QPoint(20, 0);
QTest::mouseMove(&window, p1);
QCOMPARE(target->position().x(), 117.5);
QCOMPARE(boundaryRule->property("currentOvershoot").toReal(), 20);
QCOMPARE(boundaryRule->property("peakOvershoot").toReal(), 20);
- QCOMPARE(overshootChangedSpy.count(), 1);
+ QCOMPARE(overshootChangedSpy.size(), 1);
// restricted drag: maximum overshoot
p1 += QPoint(80, 0);
QTest::mouseMove(&window, p1);
QCOMPARE(target->position().x(), 140);
QCOMPARE(boundaryRule->property("currentOvershoot").toReal(), 100);
QCOMPARE(boundaryRule->property("peakOvershoot").toReal(), 100);
- QCOMPARE(overshootChangedSpy.count(), 2);
+ QCOMPARE(overshootChangedSpy.size(), 2);
// release and let it return to bounds
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p1);
QTRY_COMPARE(dragHandler->active(), false);
- QTRY_COMPARE(overshootChangedSpy.count(), 3);
+ QTRY_COMPARE(overshootChangedSpy.size(), 3);
QCOMPARE(boundaryRule->property("currentOvershoot").toReal(&ok), 0);
QVERIFY(ok);
QCOMPARE(boundaryRule->property("peakOvershoot").toReal(&ok), 0);
diff --git a/tests/auto/quick/qquickcolorgroup/tst_qquickcolorgroup.cpp b/tests/auto/quick/qquickcolorgroup/tst_qquickcolorgroup.cpp
index f1bc591bd3..046cd5a14c 100644
--- a/tests/auto/quick/qquickcolorgroup/tst_qquickcolorgroup.cpp
+++ b/tests/auto/quick/qquickcolorgroup/tst_qquickcolorgroup.cpp
@@ -46,7 +46,7 @@ void tst_QQuickColorGroup::checkColorProperty()
qvariant_cast<QColor>(property.read(&defaultGroup)));
constexpr int expectedNotificationsCount = 2; // One from write + one from reset
- QCOMPARE(sp.count(), expectedNotificationsCount);
+ QCOMPARE(sp.size(), expectedNotificationsCount);
}
void tst_QQuickColorGroup::checkColorProperty_data()
@@ -73,7 +73,7 @@ void tst_QQuickColorGroup::colorGroupChangedWhenColorChanged()
group.setMid(Qt::blue);
- QCOMPARE(sp.count(), 1);
+ QCOMPARE(sp.size(), 1);
}
QTEST_MAIN(tst_QQuickColorGroup)
diff --git a/tests/auto/quick/qquickdeliveryagent/data/listViewDelegate.qml b/tests/auto/quick/qquickdeliveryagent/data/listViewDelegate.qml
new file mode 100644
index 0000000000..bdb7246450
--- /dev/null
+++ b/tests/auto/quick/qquickdeliveryagent/data/listViewDelegate.qml
@@ -0,0 +1,21 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+
+Item {
+ id: root
+ width: 320
+ height: 240
+
+ ListView {
+ id: listView
+ width: 320
+ height: 240
+ delegate: Rectangle {
+ width: ListView.view.width
+ height: ListView.view.height / ListView.view.count
+ color: "tomato"
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickdeliveryagent/tst_qquickdeliveryagent.cpp b/tests/auto/quick/qquickdeliveryagent/tst_qquickdeliveryagent.cpp
index 075dd77b3f..7e6416b8e2 100644
--- a/tests/auto/quick/qquickdeliveryagent/tst_qquickdeliveryagent.cpp
+++ b/tests/auto/quick/qquickdeliveryagent/tst_qquickdeliveryagent.cpp
@@ -11,6 +11,7 @@
#include <QtQuick/QQuickWindow>
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuick/private/qquickflickable_p.h>
+#include <QtQuick/private/qquicklistview_p.h>
#include <QtQuick/private/qquickpointhandler_p.h>
#include <QtQuick/private/qquickshadereffectsource_p.h>
#include <QtQuick/private/qquicktaphandler_p.h>
@@ -130,7 +131,9 @@ public:
private slots:
void passiveGrabberOrder();
void passiveGrabberItems();
+ void tapHandlerDoesntOverrideSubsceneGrabber_data();
void tapHandlerDoesntOverrideSubsceneGrabber();
+ void undoDelegationWhenSubsceneFocusCleared();
void touchCompression();
void hoverPropagation_nested_data();
void hoverPropagation_nested();
@@ -176,7 +179,7 @@ void tst_qquickdeliveryagent::passiveGrabberOrder()
auto devPriv = QPointingDevicePrivate::get(QPointingDevice::primaryPointingDevice());
const auto &persistentPoint = devPriv->activePoints.values().first();
qCDebug(lcTests) << "passive grabbers" << persistentPoint.passiveGrabbers << "contexts" << persistentPoint.passiveGrabbersContext;
- QCOMPARE(persistentPoint.passiveGrabbers.count(), 2);
+ QCOMPARE(persistentPoint.passiveGrabbers.size(), 2);
QCOMPARE(persistentPoint.passiveGrabbers.first(), subsceneTap);
QCOMPARE(persistentPoint.passiveGrabbersContext.first(), subscene.deliveryAgent);
QCOMPARE(persistentPoint.passiveGrabbers.last(), rootTap);
@@ -184,10 +187,10 @@ void tst_qquickdeliveryagent::passiveGrabberOrder()
QTest::mouseRelease(&view, Qt::LeftButton);
QTest::qWait(100);
// QQuickWindow::event() has failsafe: clear all grabbers after release
- QCOMPARE(persistentPoint.passiveGrabbers.count(), 0);
+ QCOMPARE(persistentPoint.passiveGrabbers.size(), 0);
qCDebug(lcTests) << "TapHandlers emitted tapped in this order:" << spy.senders;
- QCOMPARE(spy.senders.count(), 2);
+ QCOMPARE(spy.senders.size(), 2);
// passive grabbers are visited in order, and emit tapped() at that time
QCOMPARE(spy.senders.first(), subsceneTap);
QCOMPARE(spy.senders.last(), rootTap);
@@ -276,7 +279,7 @@ void tst_qquickdeliveryagent::passiveGrabberItems()
QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, QPoint(exclusiveGrabber->x() + 1, exclusiveGrabber->y() + 1));
auto devPriv = QPointingDevicePrivate::get(QPointingDevice::primaryPointingDevice());
const auto &persistentPoint = devPriv->activePoints.values().first();
- QTRY_COMPARE(persistentPoint.passiveGrabbers.count(), 1);
+ QTRY_COMPARE(persistentPoint.passiveGrabbers.size(), 1);
QCOMPARE(persistentPoint.passiveGrabbers.first(), passiveGrabber);
QCOMPARE(persistentPoint.exclusiveGrabber, exclusiveGrabber);
QVERIFY(exclusiveGrabber->lastPressed);
@@ -292,7 +295,7 @@ void tst_qquickdeliveryagent::passiveGrabberItems()
// since it became the exclusive grabber on mouseMove
QTRY_VERIFY(!passiveGrabber->lastPressed);
QVERIFY(exclusiveGrabber->lastPressed);
- QCOMPARE(persistentPoint.passiveGrabbers.count(), 0);
+ QCOMPARE(persistentPoint.passiveGrabbers.size(), 0);
QCOMPARE(persistentPoint.exclusiveGrabber, nullptr);
exclusiveGrabber->lastPressed = false;
@@ -301,7 +304,7 @@ void tst_qquickdeliveryagent::passiveGrabberItems()
QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, QPoint(exclusiveGrabber->x() + 1, exclusiveGrabber->y() + 1));
const auto &pressedPoint = devPriv->activePoints.values().first();
- QTRY_COMPARE(pressedPoint.passiveGrabbers.count(), 1);
+ QTRY_COMPARE(pressedPoint.passiveGrabbers.size(), 1);
QCOMPARE(pressedPoint.passiveGrabbers.first(), passiveGrabber);
QCOMPARE(pressedPoint.exclusiveGrabber, exclusiveGrabber);
QVERIFY(exclusiveGrabber->lastPressed);
@@ -316,12 +319,29 @@ void tst_qquickdeliveryagent::passiveGrabberItems()
// Both the passive and the exclusive grabber get the mouseRelease event
QTRY_VERIFY(!passiveGrabber->lastPressed);
QVERIFY(!exclusiveGrabber->lastPressed);
- QCOMPARE(pressedPoint.passiveGrabbers.count(), 0);
+ QCOMPARE(pressedPoint.passiveGrabbers.size(), 0);
QCOMPARE(pressedPoint.exclusiveGrabber, nullptr);
}
+void tst_qquickdeliveryagent::tapHandlerDoesntOverrideSubsceneGrabber_data()
+{
+ QTest::addColumn<QQuickTapHandler::GesturePolicy>("gesturePolicy");
+ QTest::addColumn<int>("expectedTaps");
+ QTest::addColumn<int>("expectedCancels");
+ // TapHandler gets passive grab => "stealth" tap, regardless of other Items
+ QTest::newRow("DragThreshold") << QQuickTapHandler::DragThreshold << 1 << 0;
+ // TapHandler gets exclusive grab => it's cancelled when the TextEdit takes the grab
+ QTest::newRow("WithinBounds") << QQuickTapHandler::WithinBounds << 0 << 2; // 2 because of QTBUG-105865
+ QTest::newRow("ReleaseWithinBounds") << QQuickTapHandler::ReleaseWithinBounds << 0 << 2;
+ QTest::newRow("DragWithinBounds") << QQuickTapHandler::DragWithinBounds << 0 << 2;
+}
+
void tst_qquickdeliveryagent::tapHandlerDoesntOverrideSubsceneGrabber() // QTBUG-94012
{
+ QFETCH(QQuickTapHandler::GesturePolicy, gesturePolicy);
+ QFETCH(int, expectedTaps);
+ QFETCH(int, expectedCancels);
+
QQuickView window;
#ifdef DISABLE_HOVER_IN_IRRELEVANT_TESTS
QQuickWindowPrivate::get(&window)->deliveryAgentPrivate()->frameSynchronousHoverEnabled = false;
@@ -338,19 +358,47 @@ void tst_qquickdeliveryagent::tapHandlerDoesntOverrideSubsceneGrabber() // QTBUG
// add a TapHandler to it
QQuickTapHandler tapHandler(&subscene);
+ tapHandler.setGesturePolicy(gesturePolicy);
QSignalSpy clickSpy(&tapHandler, &QQuickTapHandler::tapped);
+ QSignalSpy cancelSpy(&tapHandler, &QQuickTapHandler::canceled);
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
int cursorPos = textEdit->property("cursorPosition").toInt();
// Click on the middle of the subscene to the right (texture cloned from the left).
- // TapHandler takes a passive grab on press; TextEdit takes the exclusive grab;
- // and TapHandler does not emit tapped, because of the non-filtering exclusive grabber.
+ // TapHandler takes whichever type of grab on press; TextEdit takes the exclusive grab;
+ // TapHandler either gets tapped if it has passive grab, or gets its exclusive grab cancelled.
QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, clickPos);
qCDebug(lcTests) << "clicking subscene TextEdit set cursorPos to" << cursorPos;
- QVERIFY(textEdit->property("cursorPosition").toInt() > cursorPos);
- QCOMPARE(clickSpy.count(), 0); // doesn't tap
+ QVERIFY(textEdit->property("cursorPosition").toInt() > cursorPos); // TextEdit reacts regardless
+ QCOMPARE(clickSpy.size(), expectedTaps);
+ QCOMPARE(cancelSpy.size(), expectedCancels);
+}
+
+void tst_qquickdeliveryagent::undoDelegationWhenSubsceneFocusCleared() // QTBUG-105192
+{
+ QQuickView window;
+#ifdef DISABLE_HOVER_IN_IRRELEVANT_TESTS
+ QQuickWindowPrivate::get(&window)->deliveryAgentPrivate()->frameSynchronousHoverEnabled = false;
+#endif
+ QVERIFY(QQuickTest::initView(window, testFileUrl("listViewDelegate.qml")));
+ QQuickListView *listView = window.rootObject()->findChild<QQuickListView*>();
+ QVERIFY(listView);
+
+ // put the ListView into a SubsceneRootItem
+ SubsceneRootItem subscene(listView, listView->boundingRect(), window.rootObject());
+
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ // populate a delegate in ListView
+ listView->setModel(1);
+ QQuickItem *delegate = nullptr;
+ QTRY_VERIFY(QQuickVisualTestUtils::findViewDelegateItem(listView, 0, delegate));
+ QCOMPARE(QQuickWindowPrivate::get(&window)->deliveryAgentPrivate()->activeFocusItem, delegate);
+ delete listView;
+ QCOMPARE_NE(QQuickWindowPrivate::get(&window)->deliveryAgentPrivate()->activeFocusItem, delegate);
}
void tst_qquickdeliveryagent::touchCompression()
diff --git a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
index 04d2784f20..c35f31b8f2 100644
--- a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
+++ b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
@@ -344,7 +344,7 @@ void tst_qquickdesignersupport::basicStates()
QVERIFY(stateGroup);
- QCOMPARE(stateGroup->states().count(), 2 );
+ QCOMPARE(stateGroup->states().size(), 2 );
QQuickState *state01 = stateGroup->states().first();
QQuickState *state02 = stateGroup->states().last();
@@ -390,7 +390,7 @@ void tst_qquickdesignersupport::statesPropertyChanges()
QVERIFY(stateGroup);
- QCOMPARE(stateGroup->states().count(), 2 );
+ QCOMPARE(stateGroup->states().size(), 2 );
QQuickState *state01 = stateGroup->states().first();
QQuickState *state02 = stateGroup->states().last();
@@ -409,7 +409,7 @@ void tst_qquickdesignersupport::statesPropertyChanges()
QCOMPARE(state01->operationCount(), 1);
- QCOMPARE(statePrivate01->operations.count(), 1);
+ QCOMPARE(statePrivate01->operations.size(), 1);
QQuickStateOperation *propertyChange = statePrivate01->operations.at(0).data();
@@ -444,7 +444,7 @@ void tst_qquickdesignersupport::statesPropertyChanges()
QCOMPARE(rootItem, QQuickDesignerSupportPropertyChanges::targetObject(newPropertyChange));
QCOMPARE(state01->operationCount(), 2);
- QCOMPARE(statePrivate01->operations.count(), 2);
+ QCOMPARE(statePrivate01->operations.size(), 2);
QCOMPARE(QQuickDesignerSupportPropertyChanges::stateObject(newPropertyChange), state01);
diff --git a/tests/auto/quick/qquickdroparea/data/ignoreRetriggerEvent.qml b/tests/auto/quick/qquickdroparea/data/ignoreRetriggerEvent.qml
new file mode 100644
index 0000000000..af25a04ee7
--- /dev/null
+++ b/tests/auto/quick/qquickdroparea/data/ignoreRetriggerEvent.qml
@@ -0,0 +1,15 @@
+import QtQuick 2.0
+
+DropArea {
+ property int enterEvents: 0
+ property int exitEvents: 0
+ width: 100; height: 100
+ objectName: "dropArea"
+ onEntered: function (drag) { ++enterEvents; drag.accepted = false }
+ onExited: {++exitEvents}
+ Item {
+ objectName: "dragItem"
+ x: 50; y: 50
+ width: 10; height: 10
+ }
+}
diff --git a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
index 7d01207e58..fb036b6fad 100644
--- a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
+++ b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
@@ -45,6 +45,9 @@ public:
private slots:
void containsDrag_internal();
void containsDrag_external();
+
+ void ignoreRetriggerEvent();
+
void keys_internal();
void keys_external();
void source_internal();
@@ -807,6 +810,32 @@ void tst_QQuickDropArea::competingDrags()
QCOMPARE(evaluate<QString>(dropArea1, "statuslol"), QStringLiteral("parent"));
}
+void tst_QQuickDropArea::ignoreRetriggerEvent()
+{
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(QQuickTest::initView(window, testFileUrl("ignoreRetriggerEvent.qml"), true, &errorMessage), errorMessage.constData());
+
+ QQuickItem *dropArea = window.rootObject();
+ QVERIFY(dropArea);
+ QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
+ QVERIFY(dragItem);
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ // Drag the item within the drop area
+ dragItem->setPosition(QPointF(25, 25));
+ QCoreApplication::processEvents();
+ dragItem->setPosition(QPointF(50, 50));
+ QCoreApplication::processEvents();
+ dragItem->setPosition(QPointF(75, 75));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+}
+
+
void tst_QQuickDropArea::simultaneousDrags()
{
QQuickWindow window;
diff --git a/tests/auto/quick/qquickflickable/data/contentPosWhileDragging.qml b/tests/auto/quick/qquickflickable/data/contentPosWhileDragging.qml
new file mode 100644
index 0000000000..b42fbc1adb
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/data/contentPosWhileDragging.qml
@@ -0,0 +1,24 @@
+import QtQuick
+import QtQuick.Shapes
+import QtQuick.Controls
+
+Item {
+ id: root
+ width: 500
+ height: 500
+ Flickable {
+ anchors.centerIn: parent
+ width: 100
+ height: 100
+ clip: true
+ contentWidth: content.width
+ contentHeight: content.height
+ Rectangle {
+ id: content
+ width: 320
+ height: width
+ color: "#41cd52"
+ radius: width/2
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickflickable/data/flickableWithTapHandler.qml b/tests/auto/quick/qquickflickable/data/flickableWithTapHandler.qml
new file mode 100644
index 0000000000..91b81059ab
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/data/flickableWithTapHandler.qml
@@ -0,0 +1,24 @@
+import QtQuick
+
+Item {
+ width: 300
+ height: 300
+
+ Flickable {
+ anchors.fill: parent
+ anchors.topMargin: 100
+ contentWidth: 1000
+ contentHeight: 1000
+
+ Rectangle {
+ objectName: "childItem"
+ x: 20
+ y: 50
+ width: 20
+ height: 20
+ color: "red"
+ TapHandler {
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 1e8d162d03..7d5c113e87 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -1,11 +1,13 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-#include <qtest.h>
+
+#include <QtTest/QtTest>
#include <QtTest/QSignalSpy>
+#include <QtQuick/qquickview.h>
+#include <QtQuickTest/QtQuickTest>
#include <QtGui/QStyleHints>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
-#include <QtQuick/qquickview.h>
#include <private/qquickflickable_p.h>
#include <private/qquickflickable_p_p.h>
#include <private/qquickmousearea_p.h>
@@ -71,7 +73,7 @@ public:
protected:
void touchEvent(QTouchEvent *ev) override
{
- QCOMPARE(ev->points().count(), 1);
+ QCOMPARE(ev->points().size(), 1);
auto touchpoint = ev->points().first();
switch (touchpoint.state()) {
case QEventPoint::State::Pressed:
@@ -180,6 +182,7 @@ private slots:
void movingAndDragging_data();
void flickOnRelease();
void pressWhileFlicking();
+ void dragWhileFlicking();
void disabled();
void flickVelocity();
void margins();
@@ -214,8 +217,13 @@ private slots:
void receiveTapOutsideContentItem();
void flickWhenRotated_data();
void flickWhenRotated();
+ void flickAndReleaseOutsideBounds();
void scrollingWithFractionalExtentSize_data();
void scrollingWithFractionalExtentSize();
+ void setContentPositionWhileDragging_data();
+ void setContentPositionWhileDragging();
+ void coalescedMove();
+ void onlyOneMove();
private:
void flickWithTouch(QQuickWindow *window, const QPoint &from, const QPoint &to);
@@ -346,27 +354,27 @@ void tst_qquickflickable::boundsBehavior()
flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::DragAndOvershootBounds);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::DragOverBounds);
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::StopAtBounds);
- QCOMPARE(spy.count(),3);
+ QCOMPARE(spy.size(),3);
flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
- QCOMPARE(spy.count(),3);
+ QCOMPARE(spy.size(),3);
flickable->setBoundsBehavior(QQuickFlickable::OvershootBounds);
QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::OvershootBounds);
- QCOMPARE(spy.count(),4);
+ QCOMPARE(spy.size(),4);
flickable->setBoundsBehavior(QQuickFlickable::OvershootBounds);
- QCOMPARE(spy.count(),4);
+ QCOMPARE(spy.size(),4);
delete flickable;
}
@@ -399,23 +407,23 @@ void tst_qquickflickable::rebound()
flick(window.data(), QPoint(20,20), QPoint(120,120), 200);
QTRY_COMPARE(window->rootObject()->property("transitionsStarted").toInt(), 2);
- QCOMPARE(hMoveSpy.count(), 1);
- QCOMPARE(vMoveSpy.count(), 1);
- QCOMPARE(movementStartedSpy.count(), 1);
- QCOMPARE(movementEndedSpy.count(), 0);
+ QCOMPARE(hMoveSpy.size(), 1);
+ QCOMPARE(vMoveSpy.size(), 1);
+ QCOMPARE(movementStartedSpy.size(), 1);
+ QCOMPARE(movementEndedSpy.size(), 0);
QVERIFY(rebound->running());
QTRY_VERIFY(!flickable->isMoving());
QCOMPARE(flickable->contentX(), 0.0);
QCOMPARE(flickable->contentY(), 0.0);
- QCOMPARE(hMoveSpy.count(), 2);
- QCOMPARE(vMoveSpy.count(), 2);
- QCOMPARE(movementStartedSpy.count(), 1);
- QCOMPARE(movementEndedSpy.count(), 1);
+ QCOMPARE(hMoveSpy.size(), 2);
+ QCOMPARE(vMoveSpy.size(), 2);
+ QCOMPARE(movementStartedSpy.size(), 1);
+ QCOMPARE(movementEndedSpy.size(), 1);
QCOMPARE(window->rootObject()->property("transitionsStarted").toInt(), 2);
QVERIFY(!rebound->running());
- QCOMPARE(reboundSpy.count(), 2);
+ QCOMPARE(reboundSpy.size(), 2);
hMoveSpy.clear();
vMoveSpy.clear();
@@ -431,19 +439,19 @@ void tst_qquickflickable::rebound()
QVERIFY(flickable->isMoving());
QTRY_VERIFY(window->rootObject()->property("transitionsStarted").toInt() >= 1);
- QCOMPARE(hMoveSpy.count(), 1);
- QCOMPARE(vMoveSpy.count(), 1);
- QCOMPARE(movementStartedSpy.count(), 1);
+ QCOMPARE(hMoveSpy.size(), 1);
+ QCOMPARE(vMoveSpy.size(), 1);
+ QCOMPARE(movementStartedSpy.size(), 1);
QTRY_VERIFY(!flickable->isMoving());
QCOMPARE(flickable->contentX(), 0.0);
// moving started/stopped signals should only have been emitted once,
// and when they are, all transitions should have finished
- QCOMPARE(hMoveSpy.count(), 2);
- QCOMPARE(vMoveSpy.count(), 2);
- QCOMPARE(movementStartedSpy.count(), 1);
- QCOMPARE(movementEndedSpy.count(), 1);
+ QCOMPARE(hMoveSpy.size(), 2);
+ QCOMPARE(vMoveSpy.size(), 2);
+ QCOMPARE(movementStartedSpy.size(), 1);
+ QCOMPARE(movementEndedSpy.size(), 1);
hMoveSpy.clear();
vMoveSpy.clear();
@@ -458,16 +466,16 @@ void tst_qquickflickable::rebound()
flick(window.data(), QPoint(20,20), QPoint(120,120), 200);
QCOMPARE(window->rootObject()->property("transitionsStarted").toInt(), 0);
- QCOMPARE(hMoveSpy.count(), 1);
- QCOMPARE(vMoveSpy.count(), 1);
- QCOMPARE(movementStartedSpy.count(), 1);
- QCOMPARE(movementEndedSpy.count(), 0);
+ QCOMPARE(hMoveSpy.size(), 1);
+ QCOMPARE(vMoveSpy.size(), 1);
+ QCOMPARE(movementStartedSpy.size(), 1);
+ QCOMPARE(movementEndedSpy.size(), 0);
QTRY_VERIFY(!flickable->isMoving());
- QCOMPARE(hMoveSpy.count(), 2);
- QCOMPARE(vMoveSpy.count(), 2);
- QCOMPARE(movementStartedSpy.count(), 1);
- QCOMPARE(movementEndedSpy.count(), 1);
+ QCOMPARE(hMoveSpy.size(), 2);
+ QCOMPARE(vMoveSpy.size(), 2);
+ QCOMPARE(movementStartedSpy.size(), 1);
+ QCOMPARE(movementEndedSpy.size(), 1);
QCOMPARE(window->rootObject()->property("transitionsStarted").toInt(), 0);
}
@@ -484,9 +492,9 @@ void tst_qquickflickable::maximumFlickVelocity()
flickable->setMaximumFlickVelocity(2.0);
QCOMPARE(flickable->maximumFlickVelocity(), 2.0);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
flickable->setMaximumFlickVelocity(2.0);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
delete flickable;
}
@@ -504,9 +512,9 @@ void tst_qquickflickable::flickDeceleration()
flickable->setFlickDeceleration(2.0);
QCOMPARE(flickable->flickDeceleration(), 2.0);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
flickable->setFlickDeceleration(2.0);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
delete flickable;
}
@@ -530,9 +538,9 @@ void tst_qquickflickable::pressDelay()
flickable->setPressDelay(200);
QCOMPARE(flickable->pressDelay(), 200);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
flickable->setPressDelay(200);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
QQuickItem *mouseArea = window->rootObject()->findChild<QQuickItem*>("mouseArea");
QSignalSpy clickedSpy(mouseArea, SIGNAL(clicked(QQuickMouseEvent*)));
@@ -545,11 +553,11 @@ void tst_qquickflickable::pressDelay()
// But, it should occur eventually
QTRY_VERIFY(mouseArea->property("pressed").toBool());
- QCOMPARE(clickedSpy.count(),0);
+ QCOMPARE(clickedSpy.size(),0);
// On release the clicked signal should be emitted
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(150, 150));
- QCOMPARE(clickedSpy.count(),1);
+ QCOMPARE(clickedSpy.size(),1);
// Press and release position should match
QCOMPARE(flickable->property("pressX").toReal(), flickable->property("releaseX").toReal());
@@ -563,11 +571,11 @@ void tst_qquickflickable::pressDelay()
// The press should not occur immediately
QVERIFY(!mouseArea->property("pressed").toBool());
- QCOMPARE(clickedSpy.count(),0);
+ QCOMPARE(clickedSpy.size(),0);
// On release the press, release and clicked signal should be emitted
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(180, 180));
- QCOMPARE(clickedSpy.count(),1);
+ QCOMPARE(clickedSpy.size(),1);
// Press and release position should match
QCOMPARE(flickable->property("pressX").toReal(), flickable->property("releaseX").toReal());
@@ -588,7 +596,7 @@ void tst_qquickflickable::pressDelay()
// On release the clicked signal should *not* be emitted
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(150, 190));
- QCOMPARE(clickedSpy.count(),1);
+ QCOMPARE(clickedSpy.size(),1);
}
// QTBUG-17361
@@ -772,19 +780,19 @@ void tst_qquickflickable::flickableDirection()
flickable->setFlickableDirection(QQuickFlickable::HorizontalAndVerticalFlick);
QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalAndVerticalFlick);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
flickable->setFlickableDirection(QQuickFlickable::AutoFlickDirection);
QCOMPARE(flickable->flickableDirection(), QQuickFlickable::AutoFlickDirection);
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
- QCOMPARE(spy.count(),3);
+ QCOMPARE(spy.size(),3);
flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
- QCOMPARE(spy.count(),3);
+ QCOMPARE(spy.size(),3);
delete flickable;
}
@@ -857,7 +865,7 @@ void tst_qquickflickable::returnToBounds()
QTRY_COMPARE(obj->contentY(), 0.);
QVERIFY(!rebound->running());
- QCOMPARE(reboundSpy.count(), setRebound ? 2 : 0);
+ QCOMPARE(reboundSpy.size(), setRebound ? 2 : 0);
}
void tst_qquickflickable::returnToBounds_data()
@@ -895,7 +903,7 @@ void tst_qquickflickable::wheel()
QTRY_VERIFY(flick->contentY() > 0);
QCOMPARE(flick->contentX(), qreal(0));
- QTRY_COMPARE(moveEndSpy.count(), 1);
+ QTRY_COMPARE(moveEndSpy.size(), 1);
QCOMPARE(fp->velocityTimeline.isActive(), false);
QCOMPARE(fp->timeline.isActive(), false);
QTest::qWait(50); // make sure that onContentYChanged won't sneak in again
@@ -920,7 +928,7 @@ void tst_qquickflickable::wheel()
QTRY_VERIFY(flick->contentX() > 0);
QCOMPARE(flick->contentY(), qreal(0));
- QTRY_COMPARE(moveEndSpy.count(), 2);
+ QTRY_COMPARE(moveEndSpy.size(), 2);
QCOMPARE(fp->velocityTimeline.isActive(), false);
QCOMPARE(fp->timeline.isActive(), false);
QTest::qWait(50); // make sure that onContentXChanged won't sneak in again
@@ -974,7 +982,7 @@ void tst_qquickflickable::trackpad()
QGuiApplication::sendEvent(window.data(), &event);
}
- QTRY_COMPARE(moveEndSpy.count(), 1); // QTBUG-55871
+ QTRY_COMPARE(moveEndSpy.size(), 1); // QTBUG-55871
QCOMPARE(flick->property("movementsAfterEnd").value<int>(), 0); // QTBUG-55886
}
@@ -1011,7 +1019,7 @@ void tst_qquickflickable::nestedTrackpad()
event.setTimestamp(timestamp++);
QGuiApplication::sendEvent(&window, &event);
}
- QTRY_COMPARE(innerMoveEndSpy.count(), 1);
+ QTRY_COMPARE(innerMoveEndSpy.size(), 1);
innerFlickable->setContentX(0);
QCOMPARE(innerFlickable->contentX(), qreal(0));
@@ -1035,7 +1043,7 @@ void tst_qquickflickable::nestedTrackpad()
event.setTimestamp(timestamp++);
QGuiApplication::sendEvent(&window, &event);
}
- QTRY_COMPARE(outerMoveEndSpy.count(), 1);
+ QTRY_COMPARE(outerMoveEndSpy.size(), 1);
}
void tst_qquickflickable::movingAndFlicking_data()
@@ -1107,15 +1115,15 @@ void tst_qquickflickable::movingAndFlicking()
QCOMPARE(flickable->property("movingInContentX").value<bool>(), true);
QCOMPARE(flickable->property("movingInContentY").value<bool>(), true);
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(vMoveSpy.count(), verticalEnabled ? 1 : 0);
- QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 1 : 0);
- QCOMPARE(flickSpy.count(), 1);
- QCOMPARE(vFlickSpy.count(), verticalEnabled ? 1 : 0);
- QCOMPARE(hFlickSpy.count(), horizontalEnabled ? 1 : 0);
+ QCOMPARE(moveSpy.size(), 1);
+ QCOMPARE(vMoveSpy.size(), verticalEnabled ? 1 : 0);
+ QCOMPARE(hMoveSpy.size(), horizontalEnabled ? 1 : 0);
+ QCOMPARE(flickSpy.size(), 1);
+ QCOMPARE(vFlickSpy.size(), verticalEnabled ? 1 : 0);
+ QCOMPARE(hFlickSpy.size(), horizontalEnabled ? 1 : 0);
- QCOMPARE(moveStartSpy.count(), 1);
- QCOMPARE(flickStartSpy.count(), 1);
+ QCOMPARE(moveStartSpy.size(), 1);
+ QCOMPARE(flickStartSpy.size(), 1);
// wait for any motion to end
QTRY_VERIFY(!flickable->isMoving());
@@ -1126,17 +1134,17 @@ void tst_qquickflickable::movingAndFlicking()
QVERIFY(!flickable->isFlickingHorizontally());
QVERIFY(!flickable->isFlickingVertically());
- QCOMPARE(moveSpy.count(), 2);
- QCOMPARE(vMoveSpy.count(), verticalEnabled ? 2 : 0);
- QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 2 : 0);
- QCOMPARE(flickSpy.count(), 2);
- QCOMPARE(vFlickSpy.count(), verticalEnabled ? 2 : 0);
- QCOMPARE(hFlickSpy.count(), horizontalEnabled ? 2 : 0);
+ QCOMPARE(moveSpy.size(), 2);
+ QCOMPARE(vMoveSpy.size(), verticalEnabled ? 2 : 0);
+ QCOMPARE(hMoveSpy.size(), horizontalEnabled ? 2 : 0);
+ QCOMPARE(flickSpy.size(), 2);
+ QCOMPARE(vFlickSpy.size(), verticalEnabled ? 2 : 0);
+ QCOMPARE(hFlickSpy.size(), horizontalEnabled ? 2 : 0);
- QCOMPARE(moveStartSpy.count(), 1);
- QCOMPARE(moveEndSpy.count(), 1);
- QCOMPARE(flickStartSpy.count(), 1);
- QCOMPARE(flickEndSpy.count(), 1);
+ QCOMPARE(moveStartSpy.size(), 1);
+ QCOMPARE(moveEndSpy.size(), 1);
+ QCOMPARE(flickStartSpy.size(), 1);
+ QCOMPARE(flickEndSpy.size(), 1);
// Stop on a full pixel after user interaction
if (verticalEnabled)
@@ -1163,17 +1171,17 @@ void tst_qquickflickable::movingAndFlicking()
QCOMPARE(flickable->isFlickingHorizontally(), horizontalEnabled);
QCOMPARE(flickable->isFlickingVertically(), verticalEnabled);
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(vMoveSpy.count(), verticalEnabled ? 1 : 0);
- QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 1 : 0);
- QCOMPARE(flickSpy.count(), 1);
- QCOMPARE(vFlickSpy.count(), verticalEnabled ? 1 : 0);
- QCOMPARE(hFlickSpy.count(), horizontalEnabled ? 1 : 0);
+ QCOMPARE(moveSpy.size(), 1);
+ QCOMPARE(vMoveSpy.size(), verticalEnabled ? 1 : 0);
+ QCOMPARE(hMoveSpy.size(), horizontalEnabled ? 1 : 0);
+ QCOMPARE(flickSpy.size(), 1);
+ QCOMPARE(vFlickSpy.size(), verticalEnabled ? 1 : 0);
+ QCOMPARE(hFlickSpy.size(), horizontalEnabled ? 1 : 0);
- QCOMPARE(moveStartSpy.count(), 1);
- QCOMPARE(moveEndSpy.count(), 0);
- QCOMPARE(flickStartSpy.count(), 1);
- QCOMPARE(flickEndSpy.count(), 0);
+ QCOMPARE(moveStartSpy.size(), 1);
+ QCOMPARE(moveEndSpy.size(), 0);
+ QCOMPARE(flickStartSpy.size(), 1);
+ QCOMPARE(flickEndSpy.size(), 0);
// wait for any motion to end
QTRY_VERIFY(!flickable->isMoving());
@@ -1184,17 +1192,17 @@ void tst_qquickflickable::movingAndFlicking()
QVERIFY(!flickable->isFlickingHorizontally());
QVERIFY(!flickable->isFlickingVertically());
- QCOMPARE(moveSpy.count(), 2);
- QCOMPARE(vMoveSpy.count(), verticalEnabled ? 2 : 0);
- QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 2 : 0);
- QCOMPARE(flickSpy.count(), 2);
- QCOMPARE(vFlickSpy.count(), verticalEnabled ? 2 : 0);
- QCOMPARE(hFlickSpy.count(), horizontalEnabled ? 2 : 0);
+ QCOMPARE(moveSpy.size(), 2);
+ QCOMPARE(vMoveSpy.size(), verticalEnabled ? 2 : 0);
+ QCOMPARE(hMoveSpy.size(), horizontalEnabled ? 2 : 0);
+ QCOMPARE(flickSpy.size(), 2);
+ QCOMPARE(vFlickSpy.size(), verticalEnabled ? 2 : 0);
+ QCOMPARE(hFlickSpy.size(), horizontalEnabled ? 2 : 0);
- QCOMPARE(moveStartSpy.count(), 1);
- QCOMPARE(moveEndSpy.count(), 1);
- QCOMPARE(flickStartSpy.count(), 1);
- QCOMPARE(flickEndSpy.count(), 1);
+ QCOMPARE(moveStartSpy.size(), 1);
+ QCOMPARE(moveEndSpy.size(), 1);
+ QCOMPARE(flickStartSpy.size(), 1);
+ QCOMPARE(flickEndSpy.size(), 1);
QCOMPARE(flickable->contentX(), 0.0);
QCOMPARE(flickable->contentY(), 0.0);
@@ -1275,26 +1283,26 @@ void tst_qquickflickable::movingAndDragging()
QCOMPARE(flickable->property("draggingInContentX").value<bool>(), true);
QCOMPARE(flickable->property("draggingInContentY").value<bool>(), true);
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(vMoveSpy.count(), verticalEnabled ? 1 : 0);
- QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 1 : 0);
- QCOMPARE(dragSpy.count(), 1);
- QCOMPARE(vDragSpy.count(), verticalEnabled ? 1 : 0);
- QCOMPARE(hDragSpy.count(), horizontalEnabled ? 1 : 0);
+ QCOMPARE(moveSpy.size(), 1);
+ QCOMPARE(vMoveSpy.size(), verticalEnabled ? 1 : 0);
+ QCOMPARE(hMoveSpy.size(), horizontalEnabled ? 1 : 0);
+ QCOMPARE(dragSpy.size(), 1);
+ QCOMPARE(vDragSpy.size(), verticalEnabled ? 1 : 0);
+ QCOMPARE(hDragSpy.size(), horizontalEnabled ? 1 : 0);
- QCOMPARE(moveStartSpy.count(), 1);
- QCOMPARE(dragStartSpy.count(), 1);
+ QCOMPARE(moveStartSpy.size(), 1);
+ QCOMPARE(dragStartSpy.size(), 1);
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, moveFrom + moveByWithoutSnapBack*3);
QVERIFY(!flickable->isDragging());
QVERIFY(!flickable->isDraggingHorizontally());
QVERIFY(!flickable->isDraggingVertically());
- QCOMPARE(dragSpy.count(), 2);
- QCOMPARE(vDragSpy.count(), verticalEnabled ? 2 : 0);
- QCOMPARE(hDragSpy.count(), horizontalEnabled ? 2 : 0);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 1);
+ QCOMPARE(dragSpy.size(), 2);
+ QCOMPARE(vDragSpy.size(), verticalEnabled ? 2 : 0);
+ QCOMPARE(hDragSpy.size(), horizontalEnabled ? 2 : 0);
+ QCOMPARE(dragStartSpy.size(), 1);
+ QCOMPARE(dragEndSpy.size(), 1);
// Don't test whether moving finished because a flick could occur
// wait for any motion to end
@@ -1306,17 +1314,17 @@ void tst_qquickflickable::movingAndDragging()
QVERIFY(!flickable->isDraggingHorizontally());
QVERIFY(!flickable->isDraggingVertically());
- QCOMPARE(dragSpy.count(), 2);
- QCOMPARE(vDragSpy.count(), verticalEnabled ? 2 : 0);
- QCOMPARE(hDragSpy.count(), horizontalEnabled ? 2 : 0);
- QCOMPARE(moveSpy.count(), 2);
- QCOMPARE(vMoveSpy.count(), verticalEnabled ? 2 : 0);
- QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 2 : 0);
+ QCOMPARE(dragSpy.size(), 2);
+ QCOMPARE(vDragSpy.size(), verticalEnabled ? 2 : 0);
+ QCOMPARE(hDragSpy.size(), horizontalEnabled ? 2 : 0);
+ QCOMPARE(moveSpy.size(), 2);
+ QCOMPARE(vMoveSpy.size(), verticalEnabled ? 2 : 0);
+ QCOMPARE(hMoveSpy.size(), horizontalEnabled ? 2 : 0);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 1);
- QCOMPARE(moveStartSpy.count(), 1);
- QCOMPARE(moveEndSpy.count(), 1);
+ QCOMPARE(dragStartSpy.size(), 1);
+ QCOMPARE(dragEndSpy.size(), 1);
+ QCOMPARE(moveStartSpy.size(), 1);
+ QCOMPARE(moveEndSpy.size(), 1);
// Stop on a full pixel after user interaction
if (verticalEnabled)
@@ -1346,17 +1354,17 @@ void tst_qquickflickable::movingAndDragging()
QCOMPARE(flickable->isDraggingHorizontally(), horizontalEnabled);
QCOMPARE(flickable->isDraggingVertically(), verticalEnabled);
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(vMoveSpy.count(), verticalEnabled ? 1 : 0);
- QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 1 : 0);
- QCOMPARE(dragSpy.count(), 1);
- QCOMPARE(vDragSpy.count(), verticalEnabled ? 1 : 0);
- QCOMPARE(hDragSpy.count(), horizontalEnabled ? 1 : 0);
+ QCOMPARE(moveSpy.size(), 1);
+ QCOMPARE(vMoveSpy.size(), verticalEnabled ? 1 : 0);
+ QCOMPARE(hMoveSpy.size(), horizontalEnabled ? 1 : 0);
+ QCOMPARE(dragSpy.size(), 1);
+ QCOMPARE(vDragSpy.size(), verticalEnabled ? 1 : 0);
+ QCOMPARE(hDragSpy.size(), horizontalEnabled ? 1 : 0);
- QCOMPARE(moveStartSpy.count(), 1);
- QCOMPARE(moveEndSpy.count(), 0);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 0);
+ QCOMPARE(moveStartSpy.size(), 1);
+ QCOMPARE(moveEndSpy.size(), 0);
+ QCOMPARE(dragStartSpy.size(), 1);
+ QCOMPARE(dragEndSpy.size(), 0);
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, moveFrom + moveByWithSnapBack*3);
@@ -1368,15 +1376,15 @@ void tst_qquickflickable::movingAndDragging()
QVERIFY(!flickable->isDraggingHorizontally());
QVERIFY(!flickable->isDraggingVertically());
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(vMoveSpy.count(), verticalEnabled ? 1 : 0);
- QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 1 : 0);
- QCOMPARE(dragSpy.count(), 2);
- QCOMPARE(vDragSpy.count(), verticalEnabled ? 2 : 0);
- QCOMPARE(hDragSpy.count(), horizontalEnabled ? 2 : 0);
+ QCOMPARE(moveSpy.size(), 1);
+ QCOMPARE(vMoveSpy.size(), verticalEnabled ? 1 : 0);
+ QCOMPARE(hMoveSpy.size(), horizontalEnabled ? 1 : 0);
+ QCOMPARE(dragSpy.size(), 2);
+ QCOMPARE(vDragSpy.size(), verticalEnabled ? 2 : 0);
+ QCOMPARE(hDragSpy.size(), horizontalEnabled ? 2 : 0);
- QCOMPARE(moveStartSpy.count(), 1);
- QCOMPARE(moveEndSpy.count(), 0);
+ QCOMPARE(moveStartSpy.size(), 1);
+ QCOMPARE(moveEndSpy.size(), 0);
// wait for any motion to end
QTRY_VERIFY(!flickable->isMoving());
@@ -1387,17 +1395,17 @@ void tst_qquickflickable::movingAndDragging()
QVERIFY(!flickable->isDraggingHorizontally());
QVERIFY(!flickable->isDraggingVertically());
- QCOMPARE(moveSpy.count(), 2);
- QCOMPARE(vMoveSpy.count(), verticalEnabled ? 2 : 0);
- QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 2 : 0);
- QCOMPARE(dragSpy.count(), 2);
- QCOMPARE(vDragSpy.count(), verticalEnabled ? 2 : 0);
- QCOMPARE(hDragSpy.count(), horizontalEnabled ? 2 : 0);
+ QCOMPARE(moveSpy.size(), 2);
+ QCOMPARE(vMoveSpy.size(), verticalEnabled ? 2 : 0);
+ QCOMPARE(hMoveSpy.size(), horizontalEnabled ? 2 : 0);
+ QCOMPARE(dragSpy.size(), 2);
+ QCOMPARE(vDragSpy.size(), verticalEnabled ? 2 : 0);
+ QCOMPARE(hDragSpy.size(), horizontalEnabled ? 2 : 0);
- QCOMPARE(moveStartSpy.count(), 1);
- QCOMPARE(moveEndSpy.count(), 1);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 1);
+ QCOMPARE(moveStartSpy.size(), 1);
+ QCOMPARE(moveEndSpy.size(), 1);
+ QCOMPARE(dragStartSpy.size(), 1);
+ QCOMPARE(dragEndSpy.size(), 1);
QCOMPARE(flickable->contentX(), 0.0);
QCOMPARE(flickable->contentY(), 0.0);
@@ -1425,7 +1433,7 @@ void tst_qquickflickable::flickOnRelease()
QTest::mouseMove(window.data(), QPoint(50, 10), 10);
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(50, 10), 10);
- QCOMPARE(vFlickSpy.count(), 1);
+ QCOMPARE(vFlickSpy.size(), 1);
// wait for any motion to end
QTRY_VERIFY(!flickable->isMoving());
@@ -1454,6 +1462,8 @@ void tst_qquickflickable::pressWhileFlicking()
QSignalSpy hFlickSpy(flickable, SIGNAL(flickingHorizontallyChanged()));
QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged()));
QSignalSpy flickSpy(flickable, SIGNAL(flickingChanged()));
+ QSignalSpy flickStartSpy(flickable, &QQuickFlickable::flickStarted);
+ QSignalSpy flickEndSpy(flickable, &QQuickFlickable::flickEnded);
// flick then press while it is still moving
// flicking == false, moving == true;
@@ -1465,12 +1475,14 @@ void tst_qquickflickable::pressWhileFlicking()
QVERIFY(flickable->isMoving());
QVERIFY(flickable->isMovingVertically());
QVERIFY(!flickable->isMovingHorizontally());
- QCOMPARE(vMoveSpy.count(), 1);
- QCOMPARE(hMoveSpy.count(), 0);
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(vFlickSpy.count(), 1);
- QCOMPARE(hFlickSpy.count(), 0);
- QCOMPARE(flickSpy.count(), 1);
+ QCOMPARE(vMoveSpy.size(), 1);
+ QCOMPARE(hMoveSpy.size(), 0);
+ QCOMPARE(moveSpy.size(), 1);
+ QCOMPARE(vFlickSpy.size(), 1);
+ QCOMPARE(hFlickSpy.size(), 0);
+ QCOMPARE(flickSpy.size(), 1);
+ QCOMPARE(flickStartSpy.size(), 1);
+ QCOMPARE(flickEndSpy.size(), 0);
QTest::mousePress(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(20, 50));
QTRY_VERIFY(!flickable->isFlicking());
@@ -1483,6 +1495,76 @@ void tst_qquickflickable::pressWhileFlicking()
QVERIFY(!flickable->isFlickingVertically());
QTRY_VERIFY(!flickable->isMoving());
QVERIFY(!flickable->isMovingVertically());
+ QCOMPARE(flickStartSpy.size(), 1);
+ QCOMPARE(flickEndSpy.size(), 1);
+ // Stop on a full pixel after user interaction
+ QCOMPARE(flickable->contentX(), (qreal)qRound(flickable->contentX()));
+}
+
+void tst_qquickflickable::dragWhileFlicking()
+{
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("flickable03.qml")));
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window.rootObject());
+ QVERIFY(flickable != nullptr);
+
+ QSignalSpy vMoveSpy(flickable, &QQuickFlickable::movingVerticallyChanged);
+ QSignalSpy hMoveSpy(flickable, &QQuickFlickable::movingHorizontallyChanged);
+ QSignalSpy moveSpy(flickable, &QQuickFlickable::movingChanged);
+ QSignalSpy hFlickSpy(flickable, &QQuickFlickable::flickingHorizontallyChanged);
+ QSignalSpy vFlickSpy(flickable, &QQuickFlickable::flickingVerticallyChanged);
+ QSignalSpy flickSpy(flickable, &QQuickFlickable::flickingChanged);
+ QSignalSpy flickStartSpy(flickable, &QQuickFlickable::flickStarted);
+ QSignalSpy flickEndSpy(flickable, &QQuickFlickable::flickEnded);
+
+ // flick first, let it keep moving
+ flick(&window, QPoint(20,190), QPoint(20, 50), 200);
+ QVERIFY(flickable->verticalVelocity() > 0.0);
+ QTRY_VERIFY(flickable->isFlicking());
+ QVERIFY(flickable->isFlickingVertically());
+ QCOMPARE(flickable->isFlickingHorizontally(), false);
+ QVERIFY(flickable->isMoving());
+ QVERIFY(flickable->isMovingVertically());
+ QCOMPARE(flickable->isMovingHorizontally(), false);
+ QCOMPARE(vMoveSpy.size(), 1);
+ QCOMPARE(hMoveSpy.size(), 0);
+ QCOMPARE(moveSpy.size(), 1);
+ QCOMPARE(vFlickSpy.size(), 1);
+ QCOMPARE(hFlickSpy.size(), 0);
+ QCOMPARE(flickSpy.size(), 1);
+ QCOMPARE(flickStartSpy.size(), 1);
+ QCOMPARE(flickEndSpy.size(), 0);
+
+ // then drag slowly while it's still flicking and moving
+ const int dragStepDelay = 100;
+ QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, QPoint(20, 70));
+ QTRY_COMPARE(flickable->isFlicking(), false);
+ QCOMPARE(flickable->isFlickingVertically(), false);
+ QVERIFY(flickable->isMoving());
+ QVERIFY(flickable->isMovingVertically());
+
+ for (int y = 70; y > 50; y -= 5) {
+ QTest::mouseMove(&window, QPoint(20, y), dragStepDelay);
+ QVERIFY(flickable->isMoving());
+ QVERIFY(flickable->isMovingVertically());
+ // Flickable's timeline is real-time, so spoofing timestamps isn't enough
+ QTest::qWait(dragStepDelay);
+ }
+
+ QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(20, 50), dragStepDelay);
+
+ QCOMPARE(flickable->isFlicking(), false);
+ QCOMPARE(flickable->isFlickingVertically(), false);
+ QTRY_COMPARE(flickable->isMoving(), false);
+ QCOMPARE(flickable->isMovingVertically(), false);
+ QCOMPARE(flickStartSpy.size(), 1);
+ QCOMPARE(flickEndSpy.size(), 1);
+ QCOMPARE(vMoveSpy.size(), 2);
+ QCOMPARE(hMoveSpy.size(), 0);
+ QCOMPARE(moveSpy.size(), 2);
+ QCOMPARE(vFlickSpy.size(), 2);
+ QCOMPARE(hFlickSpy.size(), 0);
// Stop on a full pixel after user interaction
QCOMPARE(flickable->contentX(), (qreal)qRound(flickable->contentX()));
}
@@ -2026,10 +2108,10 @@ void tst_qquickflickable::stopAtBounds()
else
QCOMPARE(transpose ? flickable->isAtYBeginning() : flickable->isAtXBeginning(), false);
- QCOMPARE(atXBeginningChangedSpy.count(), (!transpose && !invert) ? 1 : 0);
- QCOMPARE(atYBeginningChangedSpy.count(), ( transpose && !invert) ? 1 : 0);
- QCOMPARE(atXEndChangedSpy.count(), (!transpose && invert) ? 1 : 0);
- QCOMPARE(atYEndChangedSpy.count(), ( transpose && invert) ? 1 : 0);
+ QCOMPARE(atXBeginningChangedSpy.size(), (!transpose && !invert) ? 1 : 0);
+ QCOMPARE(atYBeginningChangedSpy.size(), ( transpose && !invert) ? 1 : 0);
+ QCOMPARE(atXEndChangedSpy.size(), (!transpose && invert) ? 1 : 0);
+ QCOMPARE(atYEndChangedSpy.size(), ( transpose && invert) ? 1 : 0);
// Drag away from the aligned boundary again.
// None of the mouse movements will position the view at the boundary exactly,
@@ -2063,7 +2145,7 @@ void tst_qquickflickable::stopAtBounds()
else
flick(&view, QPoint(120,120), QPoint(20,20), 100);
- QVERIFY(flickSignal.count() > 0);
+ QVERIFY(flickSignal.size() > 0);
if (transpose) {
if (invert)
QTRY_COMPARE(flickable->isAtYBeginning(), true);
@@ -2234,22 +2316,22 @@ void tst_qquickflickable::contentSize()
flickable.setWidth(100);
QCOMPARE(flickable.width(), qreal(100));
QCOMPARE(flickable.contentWidth(), qreal(-1.0));
- QCOMPARE(cwspy.count(), 0);
+ QCOMPARE(cwspy.size(), 0);
flickable.setContentWidth(10);
QCOMPARE(flickable.width(), qreal(100));
QCOMPARE(flickable.contentWidth(), qreal(10));
- QCOMPARE(cwspy.count(), 1);
+ QCOMPARE(cwspy.size(), 1);
flickable.setHeight(100);
QCOMPARE(flickable.height(), qreal(100));
QCOMPARE(flickable.contentHeight(), qreal(-1.0));
- QCOMPARE(chspy.count(), 0);
+ QCOMPARE(chspy.size(), 0);
flickable.setContentHeight(10);
QCOMPARE(flickable.height(), qreal(100));
QCOMPARE(flickable.contentHeight(), qreal(10));
- QCOMPARE(chspy.count(), 1);
+ QCOMPARE(chspy.size(), 1);
}
// QTBUG-53726
@@ -2743,13 +2825,13 @@ void tst_qquickflickable::ignoreNonLeftMouseButtons() // QTBUG-96909
QTest::mouseMove(&view, p1, 50);
}
QVERIFY(flickable->isDragging());
- QCOMPARE(dragSpy.count(), 1);
+ QCOMPARE(dragSpy.size(), 1);
// Press other button too, then release left button: dragging changes to false
QTest::mousePress(&view, otherButton);
QTest::mouseRelease(&view, Qt::LeftButton);
QTRY_COMPARE(flickable->isDragging(), false);
- QCOMPARE(dragSpy.count(), 2);
+ QCOMPARE(dragSpy.size(), 2);
// Drag further with the other button held: Flickable ignores it
for (int i = 0; i < 8; ++i) {
@@ -2757,11 +2839,11 @@ void tst_qquickflickable::ignoreNonLeftMouseButtons() // QTBUG-96909
QTest::mouseMove(&view, p1, 50);
}
QCOMPARE(flickable->isDragging(), false);
- QCOMPARE(dragSpy.count(), 2);
+ QCOMPARE(dragSpy.size(), 2);
// Release other button: nothing happens
QTest::mouseRelease(&view, otherButton);
- QCOMPARE(dragSpy.count(), 2);
+ QCOMPARE(dragSpy.size(), 2);
}
void tst_qquickflickable::ignoreNonLeftMouseButtons_data()
@@ -2794,12 +2876,12 @@ void tst_qquickflickable::receiveTapOutsideContentItem()
// Tap outside the content item in the top-left corner
QTest::mouseClick(&window, Qt::LeftButton, {}, QPoint(5, 5));
- QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
// Tap outside the content item in the bottom-right corner
const QPoint bottomRight(flickable.contentItem()->width() + 5, flickable.contentItem()->height() + 5);
QTest::mouseClick(&window, Qt::LeftButton, {}, bottomRight);
- QCOMPARE(clickedSpy.count(), 2);
+ QCOMPARE(clickedSpy.size(), 2);
}
void tst_qquickflickable::flickWhenRotated_data()
@@ -2853,6 +2935,42 @@ void tst_qquickflickable::flickWhenRotated() // QTBUG-99639
QVERIFY(!flickable->isAtYBeginning());
}
+void tst_qquickflickable::flickAndReleaseOutsideBounds() // QTBUG-104987
+{
+ // Check that flicking works when the mouse release happens
+ // outside the bounds of the flickable (and the flick started on top
+ // of a TapHandler that has a passive grab).
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("flickableWithTapHandler.qml")));
+ QQuickItem *rootItem = window.rootObject();
+ QVERIFY(rootItem);
+ QQuickFlickable *flickable = rootItem->findChild<QQuickFlickable*>();
+ QVERIFY(flickable);
+ QQuickItem *childItem = flickable->findChild<QQuickItem*>("childItem");
+ QVERIFY(childItem);
+
+ QVERIFY(flickable->isAtYBeginning());
+
+ // Startpoint is on top of the tapHandler, while the endpoint is outside the flickable
+ const QPointF startPos = childItem->mapToGlobal(QPoint(10, 10));
+ const QPointF endPos = flickable->mapToGlobal(QPoint(10, -10));
+ const QPoint globalStartPos = window.mapFromGlobal(startPos).toPoint();
+ const QPoint globalEndPos = window.mapFromGlobal(endPos).toPoint();
+ const qreal dragDistance = 20;
+
+ // Note: here we need to initiate a flick using raw events, rather than
+ // flickable.flick(), since we're testing if the mouse events takes the
+ // correct path to starts a flick (among passive and exclusive grabbers, combined
+ // with childMouseEventFilter()).
+ QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, globalStartPos);
+ QTest::mouseMove(&window, globalStartPos - QPoint(0, dragDistance / 2));
+ QTest::mouseMove(&window, globalStartPos - QPoint(0, dragDistance));
+ QTest::mouseMove(&window, globalEndPos);
+ QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, globalEndPos);
+
+ // Ensure that the content item ends up being moved more than what we dragged
+ QTRY_VERIFY(flickable->contentY() > dragDistance * 2);
+}
void tst_qquickflickable::scrollingWithFractionalExtentSize_data()
{
@@ -2938,6 +3056,183 @@ void tst_qquickflickable::scrollingWithFractionalExtentSize() // QTBUG-101268
}
}
+void tst_qquickflickable::setContentPositionWhileDragging_data()
+{
+ QTest::addColumn<bool>("isHorizontal");
+ QTest::addColumn<int>("newPos");
+ QTest::addColumn<int>("newExtent");
+ QTest::newRow("horizontal, setContentX") << true << 0 << -1;
+ QTest::newRow("vertical, setContentY") << false << 0 << -1;
+ QTest::newRow("horizontal, setContentWidth") << true << -1 << 200;
+ QTest::newRow("vertical, setContentHeight") << false << -1 << 200;
+}
+
+void tst_qquickflickable::setContentPositionWhileDragging() // QTBUG-104966
+{
+ QFETCH(bool, isHorizontal);
+ QFETCH(int, newPos);
+ QFETCH(int, newExtent);
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("contentPosWhileDragging.qml")));
+ QQuickViewTestUtils::centerOnScreen(&window);
+ QVERIFY(window.isVisible());
+ QQuickItem *rootItem = window.rootObject();
+ QVERIFY(rootItem);
+ QQuickFlickable *flickable = rootItem->findChild<QQuickFlickable *>();
+ QVERIFY(flickable);
+
+ const auto contentPos = [flickable]() -> QPoint {
+ return QPoint(flickable->contentX(), flickable->contentY());
+ };
+ const qreal threshold =
+ qApp->styleHints()->startDragDistance() * flickable->parentItem()->scale();
+ const QPoint thresholdPnt(qRound(threshold), qRound(threshold));
+ const auto flickableCenterPos = flickable->mapToScene({flickable->width() / 2, flickable->height() / 2}).toPoint();
+
+ // Drag the mouse until we have surpassed the mouse drag threshold and a drag is initiated
+ // by checking for flickable->isDragging()
+ QPoint pos = flickableCenterPos;
+ QQuickViewTestUtils::moveAndPress(&window, pos);
+ int j = 1;
+ QVERIFY(!flickable->isDragging());
+ while (!flickable->isDragging()) {
+ pos = flickableCenterPos - QPoint(j, j);
+ QTest::mouseMove(&window, pos);
+ j++;
+ }
+
+ // Now we have entered the drag state
+ QVERIFY(flickable->isDragging());
+ QCOMPARE(flickable->contentX(), 0);
+ QCOMPARE(flickable->contentY(), 0);
+ QVERIFY(flickable->width() > 0);
+ QVERIFY(flickable->height() > 0);
+
+
+ const int moveLength = 50;
+ const QPoint unitDelta(isHorizontal ? 1 : 0, isHorizontal ? 0 : 1);
+ const QPoint moveDelta = unitDelta * moveLength;
+
+ pos -= 3*moveDelta;
+ QTest::mouseMove(&window, pos);
+ // Should be positive because we drag in the opposite direction
+ QCOMPARE(contentPos(), 3 * moveDelta);
+ QPoint expectedContentPos;
+
+ // Set the content item position back to zero *while dragging* (!!)
+ if (newPos >= 0) {
+ if (isHorizontal) {
+ flickable->setContentX(newPos);
+ } else {
+ flickable->setContentY(newPos);
+ }
+ // Continue dragging
+ pos -= moveDelta;
+ expectedContentPos = moveDelta;
+ } else if (newExtent >= 0) {
+ // ...or reduce the content size be be less than current (contentX, contentY) position
+ // This forces the content item to move.
+ // contentY: 150
+ // 320 - 150 = 170 pixels down to bottom
+ // Now reduce contentHeight to 200
+ // since we are at the bottom, and the flickable is 100 pixels tall, contentY must land
+ // at newExtent - 100.
+
+ if (isHorizontal) {
+ flickable->setContentWidth(newExtent);
+ } else {
+ flickable->setContentHeight(newExtent);
+ }
+ // Assumption is that the contentItem is aligned to the bottom of the flickable
+ // We therefore cannot scroll/flick it further down. Drag it up towards the top instead
+ // (by moving mouse down).
+ pos += moveDelta;
+ expectedContentPos = unitDelta * (newExtent - (isHorizontal ? flickable->width() : flickable->height()));
+ }
+
+ QTest::mouseMove(&window, pos);
+
+ // Make sure that the contentItem was only dragged the delta in mouse movement since the last
+ // setContentX/Y() call.
+ QCOMPARE(contentPos(), expectedContentPos);
+ QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, pos);
+ QVERIFY(!flickable->isDragging());
+}
+
+void tst_qquickflickable::coalescedMove()
+{
+ QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> windowPtr(window);
+ windowPtr->setSource(testFileUrl("flickable03.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickVisualTestUtils::centerOnScreen(window);
+ QQuickVisualTestUtils::moveMouseAway(window);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+ QVERIFY(window->rootObject() != nullptr);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QVERIFY(flickable != nullptr);
+
+ QSignalSpy movementStartedSpy(flickable, SIGNAL(movementStarted()));
+ QSignalSpy movementEndedSpy(flickable, SIGNAL(movementEnded()));
+ QSignalSpy flickStartedSpy(flickable, SIGNAL(flickStarted()));
+ QSignalSpy flickEndedSpy(flickable, SIGNAL(flickEnded()));
+
+ QTest::touchEvent(window, touchDevice).press(0, {10, 10}).commit();
+
+ QTest::touchEvent(window, touchDevice).move(0, {10, 40}).commit();
+
+ QTest::touchEvent(window, touchDevice).move(0, {10, 100}).commit();
+
+ QTest::touchEvent(window, touchDevice).release(0, {10, 150}).commit();
+ QQuickTouchUtils::flush(window);
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ QCOMPARE(movementStartedSpy.size(), 1);
+ QCOMPARE(flickStartedSpy.size(), 1);
+ QCOMPARE(movementEndedSpy.size(), 1);
+ QCOMPARE(flickEndedSpy.size(), 1);
+}
+
+void tst_qquickflickable::onlyOneMove()
+{
+ QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> windowPtr(window);
+ windowPtr->setSource(testFileUrl("flickable03.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickVisualTestUtils::centerOnScreen(window);
+ QQuickVisualTestUtils::moveMouseAway(window);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+ QVERIFY(window->rootObject() != nullptr);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QVERIFY(flickable != nullptr);
+
+ QSignalSpy movementStartedSpy(flickable, SIGNAL(movementStarted()));
+ QSignalSpy movementEndedSpy(flickable, SIGNAL(movementEnded()));
+ QSignalSpy flickStartedSpy(flickable, SIGNAL(flickStarted()));
+ QSignalSpy flickEndedSpy(flickable, SIGNAL(flickEnded()));
+
+ QTest::touchEvent(window, touchDevice).press(0, {10, 10}).commit();
+ QQuickTouchUtils::flush(window);
+
+ QTest::touchEvent(window, touchDevice).move(0, {10, 100}).commit();
+ QQuickTouchUtils::flush(window);
+
+ QTest::touchEvent(window, touchDevice).release(0, {10, 200}).commit();
+ QQuickTouchUtils::flush(window);
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ QCOMPARE(movementStartedSpy.size(), 1);
+ QCOMPARE(flickStartedSpy.size(), 1);
+ QCOMPARE(movementEndedSpy.size(), 1);
+ QCOMPARE(flickEndedSpy.size(), 1);
+}
+
QTEST_MAIN(tst_qquickflickable)
#include "tst_qquickflickable.moc"
diff --git a/tests/auto/quick/qquickflipable/data/flip-y-axis-flipable.qml b/tests/auto/quick/qquickflipable/data/flip-y-axis-flipable.qml
new file mode 100644
index 0000000000..1b6a3f5018
--- /dev/null
+++ b/tests/auto/quick/qquickflipable/data/flip-y-axis-flipable.qml
@@ -0,0 +1,32 @@
+// Copyright (C) 2023 UnionTech Software Technology Co., Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+
+Flipable {
+ id: flipable
+
+ property real angle: 0
+ width: 3840 // wider than 1024 * 2: part of it goes behind the camera while flipping
+ height: 2160
+
+ front: Rectangle {
+ width: parent.width
+ height: parent.height
+ color: "red"
+ anchors.centerIn: parent
+ }
+ back: Rectangle {
+ color: "yellow"
+ anchors.centerIn: parent
+ width: parent.width
+ height: parent.height
+ }
+ transform: Rotation {
+ id: rotation
+ origin.x: flipable.width / 2
+ origin.y: flipable.height / 2
+ axis.x: 0; axis.y: 1; axis.z: 0
+ angle: flipable.angle
+ }
+}
diff --git a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp
index c1eab29759..17b5bba9d5 100644
--- a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp
+++ b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp
@@ -27,6 +27,9 @@ private slots:
void QTBUG_9161_crash();
void QTBUG_8474_qgv_abort();
+ void flipRotationAngle_data();
+ void flipRotationAngle();
+
private:
QQmlEngine engine;
};
@@ -112,6 +115,31 @@ void tst_qquickflipable::QTBUG_8474_qgv_abort()
delete window;
}
+void tst_qquickflipable::flipRotationAngle_data()
+{
+ QTest::addColumn<int>("angle");
+ QTest::addColumn<QQuickFlipable::Side>("side");
+
+ QTest::newRow("89") << 89 << QQuickFlipable::Front;
+ QTest::newRow("91") << 91 << QQuickFlipable::Back;
+ QTest::newRow("-89") << -89 << QQuickFlipable::Front;
+ QTest::newRow("-91") << -91 << QQuickFlipable::Back;
+}
+
+void tst_qquickflipable::flipRotationAngle() // QTBUG-75954
+{
+ QFETCH(int, angle);
+ QFETCH(QQuickFlipable::Side, side);
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("flip-y-axis-flipable.qml"));
+ QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
+ QVERIFY(obj != nullptr);
+ obj->setProperty("angle", angle);
+ QCOMPARE(obj->side(), side);
+ delete obj;
+}
+
QTEST_MAIN(tst_qquickflipable)
#include "tst_qquickflipable.moc"
diff --git a/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
index 3c9417fb1d..4dcbcc4884 100644
--- a/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
+++ b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
@@ -379,78 +379,78 @@ void tst_qquickfocusscope::forceActiveFocus()
itemA1->forceActiveFocus();
QVERIFY(itemA1->hasActiveFocus());
QVERIFY(!rootObject->hasActiveFocus());
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
+ QCOMPARE(rootSpy.size(), 0);
+ QCOMPARE(scopeSpy.size(), 1);
scopeA->forceActiveFocus();
QVERIFY(!itemA1->hasActiveFocus());
QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
+ QCOMPARE(scopeASpy.size(), 1);
+ QCOMPARE(rootSpy.size(), 0);
+ QCOMPARE(scopeSpy.size(), 1);
itemA2->forceActiveFocus();
QVERIFY(!itemA1->hasActiveFocus());
QVERIFY(itemA2->hasActiveFocus());
QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
+ QCOMPARE(scopeASpy.size(), 1);
+ QCOMPARE(rootSpy.size(), 0);
+ QCOMPARE(scopeSpy.size(), 1);
scopeA->forceActiveFocus();
QVERIFY(!itemA1->hasActiveFocus());
QVERIFY(itemA2->hasActiveFocus());
QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
+ QCOMPARE(scopeASpy.size(), 1);
+ QCOMPARE(rootSpy.size(), 0);
+ QCOMPARE(scopeSpy.size(), 1);
itemA1->forceActiveFocus();
QVERIFY(itemA1->hasActiveFocus());
QVERIFY(!scopeA->hasActiveFocus());
QVERIFY(!itemA2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 2);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
+ QCOMPARE(scopeASpy.size(), 2);
+ QCOMPARE(rootSpy.size(), 0);
+ QCOMPARE(scopeSpy.size(), 1);
// Then jump back and forth between branch 'a' and 'b'
itemB1->forceActiveFocus();
QVERIFY(itemB1->hasActiveFocus());
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
+ QCOMPARE(rootSpy.size(), 0);
+ QCOMPARE(scopeSpy.size(), 1);
scopeA->forceActiveFocus();
QVERIFY(!itemA1->hasActiveFocus());
QVERIFY(!itemB1->hasActiveFocus());
QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 3);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
+ QCOMPARE(scopeASpy.size(), 3);
+ QCOMPARE(rootSpy.size(), 0);
+ QCOMPARE(scopeSpy.size(), 1);
scopeB->forceActiveFocus();
QVERIFY(!scopeA->hasActiveFocus());
QVERIFY(!itemB1->hasActiveFocus());
QVERIFY(scopeB->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 4);
- QCOMPARE(scopeBSpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
+ QCOMPARE(scopeASpy.size(), 4);
+ QCOMPARE(scopeBSpy.size(), 1);
+ QCOMPARE(rootSpy.size(), 0);
+ QCOMPARE(scopeSpy.size(), 1);
itemA2->forceActiveFocus();
QVERIFY(!scopeB->hasActiveFocus());
QVERIFY(itemA2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 5);
- QCOMPARE(scopeBSpy.count(), 2);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
+ QCOMPARE(scopeASpy.size(), 5);
+ QCOMPARE(scopeBSpy.size(), 2);
+ QCOMPARE(rootSpy.size(), 0);
+ QCOMPARE(scopeSpy.size(), 1);
itemB2->forceActiveFocus();
QVERIFY(!itemA2->hasActiveFocus());
QVERIFY(itemB2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 6);
- QCOMPARE(scopeBSpy.count(), 3);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
+ QCOMPARE(scopeASpy.size(), 6);
+ QCOMPARE(scopeBSpy.size(), 3);
+ QCOMPARE(rootSpy.size(), 0);
+ QCOMPARE(scopeSpy.size(), 1);
delete view;
}
@@ -516,12 +516,12 @@ void tst_qquickfocusscope::canvasFocus()
QCOMPARE(item2->hasFocus(), false);
QCOMPARE(item2->hasActiveFocus(), false);
- QCOMPARE(rootFocusSpy.count(), 1);
- QCOMPARE(rootActiveFocusSpy.count(), 1);
- QCOMPARE(scope1FocusSpy.count(), 0);
- QCOMPARE(scope1ActiveFocusSpy.count(), 1);
- QCOMPARE(item1FocusSpy.count(), 0);
- QCOMPARE(item1ActiveFocusSpy.count(), 1);
+ QCOMPARE(rootFocusSpy.size(), 1);
+ QCOMPARE(rootActiveFocusSpy.size(), 1);
+ QCOMPARE(scope1FocusSpy.size(), 0);
+ QCOMPARE(scope1ActiveFocusSpy.size(), 1);
+ QCOMPARE(item1FocusSpy.size(), 0);
+ QCOMPARE(item1ActiveFocusSpy.size(), 1);
// view->hide(); // seemingly doesn't remove focus, so have an another view steal it.
@@ -537,12 +537,12 @@ void tst_qquickfocusscope::canvasFocus()
QCOMPARE(item1->hasFocus(), true);
QCOMPARE(item1->hasActiveFocus(), false);
- QCOMPARE(rootFocusSpy.count(), 2);
- QCOMPARE(rootActiveFocusSpy.count(), 2);
- QCOMPARE(scope1FocusSpy.count(), 0);
- QCOMPARE(scope1ActiveFocusSpy.count(), 2);
- QCOMPARE(item1FocusSpy.count(), 0);
- QCOMPARE(item1ActiveFocusSpy.count(), 2);
+ QCOMPARE(rootFocusSpy.size(), 2);
+ QCOMPARE(rootActiveFocusSpy.size(), 2);
+ QCOMPARE(scope1FocusSpy.size(), 0);
+ QCOMPARE(scope1ActiveFocusSpy.size(), 2);
+ QCOMPARE(item1FocusSpy.size(), 0);
+ QCOMPARE(item1ActiveFocusSpy.size(), 2);
// window does not have focus, so item2 will not get active focus
@@ -559,16 +559,16 @@ void tst_qquickfocusscope::canvasFocus()
QCOMPARE(item2->hasFocus(), true);
QCOMPARE(item2->hasActiveFocus(), false);
- QCOMPARE(rootFocusSpy.count(), 2);
- QCOMPARE(rootActiveFocusSpy.count(), 2);
- QCOMPARE(scope1FocusSpy.count(), 1);
- QCOMPARE(scope1ActiveFocusSpy.count(), 2);
- QCOMPARE(item1FocusSpy.count(), 0);
- QCOMPARE(item1ActiveFocusSpy.count(), 2);
- QCOMPARE(scope2FocusSpy.count(), 1);
- QCOMPARE(scope2ActiveFocusSpy.count(), 0);
- QCOMPARE(item2FocusSpy.count(), 1);
- QCOMPARE(item2ActiveFocusSpy.count(), 0);
+ QCOMPARE(rootFocusSpy.size(), 2);
+ QCOMPARE(rootActiveFocusSpy.size(), 2);
+ QCOMPARE(scope1FocusSpy.size(), 1);
+ QCOMPARE(scope1ActiveFocusSpy.size(), 2);
+ QCOMPARE(item1FocusSpy.size(), 0);
+ QCOMPARE(item1ActiveFocusSpy.size(), 2);
+ QCOMPARE(scope2FocusSpy.size(), 1);
+ QCOMPARE(scope2ActiveFocusSpy.size(), 0);
+ QCOMPARE(item2FocusSpy.size(), 1);
+ QCOMPARE(item2ActiveFocusSpy.size(), 0);
// give the window focus, and item2 will get active focus
view->show();
@@ -582,12 +582,12 @@ void tst_qquickfocusscope::canvasFocus()
QCOMPARE(scope2->hasActiveFocus(), true);
QCOMPARE(item2->hasFocus(), true);
QCOMPARE(item2->hasActiveFocus(), true);
- QCOMPARE(rootFocusSpy.count(), 3);
- QCOMPARE(rootActiveFocusSpy.count(), 3);
- QCOMPARE(scope2FocusSpy.count(), 1);
- QCOMPARE(scope2ActiveFocusSpy.count(), 1);
- QCOMPARE(item2FocusSpy.count(), 1);
- QCOMPARE(item2ActiveFocusSpy.count(), 1);
+ QCOMPARE(rootFocusSpy.size(), 3);
+ QCOMPARE(rootActiveFocusSpy.size(), 3);
+ QCOMPARE(scope2FocusSpy.size(), 1);
+ QCOMPARE(scope2ActiveFocusSpy.size(), 1);
+ QCOMPARE(item2FocusSpy.size(), 1);
+ QCOMPARE(item2ActiveFocusSpy.size(), 1);
delete view;
}
diff --git a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
index 0efe3a2c24..c34edbcdde 100644
--- a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
+++ b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
@@ -147,27 +147,27 @@ void tst_qquickfontloader::changeFont()
QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged()));
QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
- QCOMPARE(nameSpy.count(), 0);
- QCOMPARE(statusSpy.count(), 0);
+ QCOMPARE(nameSpy.size(), 0);
+ QCOMPARE(statusSpy.size(), 0);
QTRY_COMPARE(fontObject->name(), QString("OCRA"));
ctxt->setContextProperty("fnt", server.urlString("/daniel.ttf"));
QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Loading);
QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
- QCOMPARE(nameSpy.count(), 1);
- QCOMPARE(statusSpy.count(), 2);
+ QCOMPARE(nameSpy.size(), 1);
+ QCOMPARE(statusSpy.size(), 2);
QTRY_COMPARE(fontObject->name(), QString("Daniel"));
ctxt->setContextProperty("fnt", testFileUrl("tarzeau_ocr_a.ttf"));
QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
- QCOMPARE(nameSpy.count(), 2);
- QCOMPARE(statusSpy.count(), 2);
+ QCOMPARE(nameSpy.size(), 2);
+ QCOMPARE(statusSpy.size(), 2);
QTRY_COMPARE(fontObject->name(), QString("OCRA"));
ctxt->setContextProperty("fnt", server.urlString("/daniel.ttf"));
QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
- QCOMPARE(nameSpy.count(), 3);
- QCOMPARE(statusSpy.count(), 2);
+ QCOMPARE(nameSpy.size(), 3);
+ QCOMPARE(statusSpy.size(), 2);
QTRY_COMPARE(fontObject->name(), QString("Daniel"));
}
diff --git a/tests/auto/quick/qquickfontmetrics/tst_quickfontmetrics.cpp b/tests/auto/quick/qquickfontmetrics/tst_quickfontmetrics.cpp
index 6d98b62696..f34bdc2059 100644
--- a/tests/auto/quick/qquickfontmetrics/tst_quickfontmetrics.cpp
+++ b/tests/auto/quick/qquickfontmetrics/tst_quickfontmetrics.cpp
@@ -39,7 +39,7 @@ void tst_QuickFontMetrics::properties()
QSignalSpy spy(&metrics, SIGNAL(fontChanged(QFont)));
metrics.setFont(font);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(metrics.ascent(), expected.ascent());
QCOMPARE(metrics.descent(), expected.descent());
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index 182458bb10..9e42e0f4e4 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -350,7 +350,7 @@ void tst_QQuickGridView::items()
QTRY_COMPARE(gridview->count(), model.count());
QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().size(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
for (int i = 0; i < model.count(); ++i) {
QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
@@ -365,7 +365,7 @@ void tst_QQuickGridView::items()
QaimModel model2;
ctxt->setContextProperty("testModel", &model2);
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
QTRY_COMPARE(itemCount, 0);
delete window;
@@ -430,7 +430,7 @@ void tst_QQuickGridView::inserted_basic()
model.insertItem(1, "Will", "9876");
QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().size(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
QTRY_VERIFY(name != nullptr);
@@ -452,7 +452,7 @@ void tst_QQuickGridView::inserted_basic()
model.insertItem(0, "Foo", "1111"); // zero index, and current item
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().size(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
name = findItem<QQuickText>(contentItem, "textName", 0);
QTRY_VERIFY(name != nullptr);
@@ -539,7 +539,7 @@ void tst_QQuickGridView::inserted_defaultLayout(QQuickGridView::Flow flow,
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (item && delegateVisible(item)) {
firstVisibleIndex = i;
@@ -549,7 +549,7 @@ void tst_QQuickGridView::inserted_defaultLayout(QQuickGridView::Flow flow,
QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
// Confirm items positioned correctly and indexes correct
- for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
+ for (int i = firstVisibleIndex; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
QCOMPARE(item->position(), expectedItemPos(gridview, i, rowOffsetAfterMove));
@@ -732,7 +732,7 @@ void tst_QQuickGridView::insertBeforeVisible()
QTRY_COMPARE(gridview->contentY(), 0.0 + itemsOffsetAfterMove);
// Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
@@ -804,7 +804,7 @@ void tst_QQuickGridView::removed_basic()
QTRY_COMPARE(removed, QString("Item1"));
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -825,7 +825,7 @@ void tst_QQuickGridView::removed_basic()
// Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -838,7 +838,7 @@ void tst_QQuickGridView::removed_basic()
QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count());
// Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -876,7 +876,7 @@ void tst_QQuickGridView::removed_basic()
QVERIFY(QQuickTest::qWaitForPolish(gridview));
// Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QTRY_COMPARE(item->x(), qreal((i%3)*80));
@@ -959,7 +959,7 @@ void tst_QQuickGridView::removed_defaultLayout(QQuickGridView::Flow flow,
int firstVisibleIndex = -1;
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
QRectF viewRect(gridview->contentX(), gridview->contentY(), gridview->width(), gridview->height());
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (item) {
QRectF itemRect(item->x(), item->y(), item->width(), item->height());
@@ -975,7 +975,7 @@ void tst_QQuickGridView::removed_defaultLayout(QQuickGridView::Flow flow,
QCOMPARE(firstName, firstVisible);
// Confirm items positioned correctly and indexes correct
- for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
+ for (int i = firstVisibleIndex; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
QCOMPARE(item->position(), expectedItemPos(gridview, i, rowOffsetAfterMove));
@@ -1200,7 +1200,7 @@ void tst_QQuickGridView::addOrRemoveBeforeVisible()
QCOMPARE(name->text(), QString("Item1"));
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", i));
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
@@ -1309,7 +1309,7 @@ void tst_QQuickGridView::moved_defaultLayout(QQuickGridView::Flow flow,
// Confirm items positioned correctly and indexes correct
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (item && delegateVisible(item)) {
firstVisibleIndex = i;
@@ -1318,7 +1318,7 @@ void tst_QQuickGridView::moved_defaultLayout(QQuickGridView::Flow flow,
}
QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
- for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
+ for (int i = firstVisibleIndex; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item &&
( (flow == QQuickGridView::FlowLeftToRight && i >= firstVisibleIndex + (3*6))
@@ -1545,7 +1545,7 @@ void tst_QQuickGridView::multipleChanges(bool condensed)
QTRY_VERIFY(gridview != nullptr);
QVERIFY(QQuickTest::qWaitForPolish(gridview));
- for (int i=0; i<changes.count(); i++) {
+ for (int i=0; i<changes.size(); i++) {
switch (changes[i].type) {
case ListChange::Inserted:
{
@@ -1584,7 +1584,7 @@ void tst_QQuickGridView::multipleChanges(bool condensed)
QQuickText *number;
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
@@ -2172,7 +2172,7 @@ void tst_QQuickGridView::changeFlow()
QTRY_VERIFY(contentItem != nullptr);
// Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -2190,7 +2190,7 @@ void tst_QQuickGridView::changeFlow()
ctxt->setContextProperty("testTopToBottom", QVariant(true));
// Confirm items positioned correctly and indexes correct
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -2208,7 +2208,7 @@ void tst_QQuickGridView::changeFlow()
ctxt->setContextProperty("testRightToLeft", QVariant(true));
// Confirm items positioned correctly and indexes correct
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -2228,7 +2228,7 @@ void tst_QQuickGridView::changeFlow()
QTRY_COMPARE(gridview->contentX(), 0.);
// Confirm items positioned correctly and indexes correct
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -2322,17 +2322,17 @@ void tst_QQuickGridView::propertyChanges()
QTRY_COMPARE(gridView->cacheBuffer(), 3);
QTRY_COMPARE(gridView->flow(), QQuickGridView::FlowTopToBottom);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.size(),1);
+ QTRY_COMPARE(cacheBufferSpy.size(),1);
+ QTRY_COMPARE(flowSpy.size(),1);
gridView->setWrapEnabled(false);
gridView->setCacheBuffer(3);
gridView->setFlow(QQuickGridView::FlowTopToBottom);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.size(),1);
+ QTRY_COMPARE(cacheBufferSpy.size(),1);
+ QTRY_COMPARE(flowSpy.size(),1);
gridView->setFlow(QQuickGridView::FlowLeftToRight);
QTRY_COMPARE(gridView->flow(), QQuickGridView::FlowLeftToRight);
@@ -2345,26 +2345,26 @@ void tst_QQuickGridView::propertyChanges()
QTRY_COMPARE(gridView->cacheBuffer(), 5);
QTRY_COMPARE(gridView->layoutDirection(), Qt::RightToLeft);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
- QTRY_COMPARE(cacheBufferSpy.count(),2);
- QTRY_COMPARE(layoutSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),2);
+ QTRY_COMPARE(keyNavigationWrapsSpy.size(),2);
+ QTRY_COMPARE(cacheBufferSpy.size(),2);
+ QTRY_COMPARE(layoutSpy.size(),1);
+ QTRY_COMPARE(flowSpy.size(),2);
gridView->setWrapEnabled(true);
gridView->setCacheBuffer(5);
gridView->setLayoutDirection(Qt::RightToLeft);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
- QTRY_COMPARE(cacheBufferSpy.count(),2);
- QTRY_COMPARE(layoutSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),2);
+ QTRY_COMPARE(keyNavigationWrapsSpy.size(),2);
+ QTRY_COMPARE(cacheBufferSpy.size(),2);
+ QTRY_COMPARE(layoutSpy.size(),1);
+ QTRY_COMPARE(flowSpy.size(),2);
gridView->setFlow(QQuickGridView::FlowTopToBottom);
QTRY_COMPARE(gridView->flow(), QQuickGridView::FlowTopToBottom);
- QTRY_COMPARE(flowSpy.count(),3);
+ QTRY_COMPARE(flowSpy.size(),3);
gridView->setFlow(QQuickGridView::FlowTopToBottom);
- QTRY_COMPARE(flowSpy.count(),3);
+ QTRY_COMPARE(flowSpy.size(),3);
delete window;
}
@@ -2404,24 +2404,24 @@ void tst_QQuickGridView::componentChanges()
QVERIFY(gridView->headerItem());
QVERIFY(gridView->footerItem());
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
- QTRY_COMPARE(headerItemSpy.count(),1);
- QTRY_COMPARE(footerItemSpy.count(),1);
+ QTRY_COMPARE(highlightSpy.size(),1);
+ QTRY_COMPARE(delegateSpy.size(),1);
+ QTRY_COMPARE(headerSpy.size(),1);
+ QTRY_COMPARE(footerSpy.size(),1);
+ QTRY_COMPARE(headerItemSpy.size(),1);
+ QTRY_COMPARE(footerItemSpy.size(),1);
gridView->setHighlight(&component);
gridView->setDelegate(&delegateComponent);
gridView->setHeader(&component);
gridView->setFooter(&component);
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
- QTRY_COMPARE(headerItemSpy.count(),1);
- QTRY_COMPARE(footerItemSpy.count(),1);
+ QTRY_COMPARE(highlightSpy.size(),1);
+ QTRY_COMPARE(delegateSpy.size(),1);
+ QTRY_COMPARE(headerSpy.size(),1);
+ QTRY_COMPARE(footerSpy.size(),1);
+ QTRY_COMPARE(headerItemSpy.size(),1);
+ QTRY_COMPARE(footerItemSpy.size(),1);
delete window;
}
@@ -2442,13 +2442,13 @@ void tst_QQuickGridView::modelChanges()
gridView->setModel(modelVariant);
QTRY_COMPARE(gridView->model(), modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
+ QTRY_COMPARE(modelSpy.size(),1);
gridView->setModel(modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
+ QTRY_COMPARE(modelSpy.size(),1);
gridView->setModel(QVariant());
- QTRY_COMPARE(modelSpy.count(),2);
+ QTRY_COMPARE(modelSpy.size(),2);
delete window;
}
@@ -2578,7 +2578,7 @@ void tst_QQuickGridView::positionViewAtIndex()
QTRY_COMPARE(gridview->contentY(), contentPos);
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = index; i < model.count() && i < itemCount-index-1; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -3073,7 +3073,7 @@ void tst_QQuickGridView::footer()
QSignalSpy footerItemSpy(gridview, SIGNAL(footerItemChanged()));
QMetaObject::invokeMethod(window->rootObject(), "changeFooter");
- QCOMPARE(footerItemSpy.count(), 1);
+ QCOMPARE(footerItemSpy.size(), 1);
footer = findItem<QQuickText>(contentItem, "footer");
QVERIFY(!footer);
@@ -3292,7 +3292,7 @@ void tst_QQuickGridView::header()
QSignalSpy headerItemSpy(gridview, SIGNAL(headerItemChanged()));
QMetaObject::invokeMethod(window->rootObject(), "changeHeader");
- QCOMPARE(headerItemSpy.count(), 1);
+ QCOMPARE(headerItemSpy.size(), 1);
header = findItem<QQuickText>(contentItem, "header");
QVERIFY(!header);
@@ -3525,51 +3525,46 @@ void tst_QQuickGridView::extents_data()
QTest::newRow("LeftToRight, LtR, TtB")
<< QQuickGridView::FlowLeftToRight << Qt::LeftToRight << QQuickItemView::TopToBottom
- << QPointF(0, -20) << QPointF(0, 0)
- << QPointF(0, 20) << QPointF(240, 20)
+ << QPointF(0, -20) << QPointF(0, 0) << QPointF(0, 20) << QPointF(0, 20)
<< QPointF(0, -20) << QPointF(0, -20);
QTest::newRow("LeftToRight, RtL, TtB")
<< QQuickGridView::FlowLeftToRight << Qt::RightToLeft << QQuickItemView::TopToBottom
- << QPointF(0, -20) << QPointF(0, 0)
- << QPointF(0, 20) << QPointF(240, 20)
+ << QPointF(0, -20) << QPointF(0, 0) << QPointF(0, 20) << QPointF(0, 20)
<< QPointF(0, -20) << QPointF(0, -20);
QTest::newRow("LeftToRight, LtR, BtT")
<< QQuickGridView::FlowLeftToRight << Qt::LeftToRight << QQuickItemView::BottomToTop
- << QPointF(0, 0) << QPointF(0, -30)
- << QPointF(0, 320 - 20) << QPointF(240, 320 - 20) // content flow is reversed
+ << QPointF(0, 0) << QPointF(0, -30) << QPointF(0, 320 - 20)
+ << QPointF(0, 320 - 20) // content flow is reversed
<< QPointF(0, -30) << QPointF(0, (-60.0 * 10) - 30);
QTest::newRow("LeftToRight, RtL, BtT")
<< QQuickGridView::FlowLeftToRight << Qt::RightToLeft << QQuickItemView::BottomToTop
- << QPointF(0, 0) << QPointF(0, -30)
- << QPointF(0, 320 - 20) << QPointF(240, 320 - 20) // content flow is reversed
+ << QPointF(0, 0) << QPointF(0, -30) << QPointF(0, 320 - 20)
+ << QPointF(0, 320 - 20) // content flow is reversed
<< QPointF(0, -30) << QPointF(0, (-60.0 * 10) - 30);
-
QTest::newRow("TopToBottom, LtR, TtB")
<< QQuickGridView::FlowTopToBottom << Qt::LeftToRight << QQuickItemView::TopToBottom
- << QPointF(-20, 0) << QPointF(0, 0)
- << QPointF(20, 0) << QPointF(20, 320)
+ << QPointF(-20, 0) << QPointF(0, 0) << QPointF(20, 0) << QPointF(20, 0)
<< QPointF(-20, 0) << QPointF(-20, 0);
QTest::newRow("TopToBottom, RtL, TtB")
<< QQuickGridView::FlowTopToBottom << Qt::RightToLeft << QQuickItemView::TopToBottom
- << QPointF(0, 0) << QPointF(-30, 0)
- << QPointF(240 - 20, 0) << QPointF(240 - 20, 320) // content flow is reversed
+ << QPointF(0, 0) << QPointF(-30, 0) << QPointF(240 - 20, 0)
+ << QPointF(240 - 20, 0) // content flow is reversed
<< QPointF(-30, 0) << QPointF((-80.0 * 6) - 30, 0);
QTest::newRow("TopToBottom, LtR, BtT")
<< QQuickGridView::FlowTopToBottom << Qt::LeftToRight << QQuickItemView::BottomToTop
- << QPointF(-20, -320) << QPointF(0, -320)
- << QPointF(20, 0) << QPointF(20, 320)
+ << QPointF(-20, -320) << QPointF(0, -320) << QPointF(20, 0) << QPointF(20, 0)
<< QPointF(-20, 0) << QPointF(-20, 0);
QTest::newRow("TopToBottom, RtL, BtT")
<< QQuickGridView::FlowTopToBottom << Qt::RightToLeft << QQuickItemView::BottomToTop
- << QPointF(0, -320) << QPointF(-30, -320)
- << QPointF(240 - 20, 0) << QPointF(240 - 20, 320) // content flow is reversed
+ << QPointF(0, -320) << QPointF(-30, -320) << QPointF(240 - 20, 0)
+ << QPointF(240 - 20, 0) // content flow is reversed
<< QPointF(-30, 0) << QPointF((-80.0 * 6) - 30, 0);
}
@@ -3651,16 +3646,16 @@ void tst_QQuickGridView::resizeViewAndRepaint()
// Ensure we handle -ve sizes
gridview->setHeight(-100);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 3);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 3);
gridview->setCacheBuffer(120);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 9);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 9);
// ensure items in cache become visible
gridview->setHeight(120);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 15);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 15);
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -3672,9 +3667,9 @@ void tst_QQuickGridView::resizeViewAndRepaint()
// ensure items outside view become invisible
gridview->setHeight(60);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 12);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 12);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -3730,8 +3725,8 @@ void tst_QQuickGridView::resizeGrid()
// Confirm items positioned correctly and indexes correct
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- QVERIFY(items.count() >= 18 && items.count() <= 21);
- for (int i = 0; i < model.count() && i < items.count(); ++i) {
+ QVERIFY(items.size() >= 18 && items.size() <= 21);
+ for (int i = 0; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
QCOMPARE(item->position(), expectedItemPos(gridview, i, 0));
@@ -3762,8 +3757,8 @@ void tst_QQuickGridView::resizeGrid()
// Confirm items positioned correctly and indexes correct
items = findItems<QQuickItem>(contentItem, "wrapper");
- QVERIFY(items.count() >= 28);
- for (int i = 0; i < model.count() && i < items.count(); ++i) {
+ QVERIFY(items.size() >= 28);
+ for (int i = 0; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
QCOMPARE(item->position(), expectedItemPos(gridview, i, 0));
@@ -3851,7 +3846,7 @@ void tst_QQuickGridView::changeColumnCount()
QVERIFY(QQuickTest::qWaitForPolish(gridview));
// a single column of 6 items are visible
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
QCOMPARE(itemCount, 6);
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
@@ -3863,7 +3858,7 @@ void tst_QQuickGridView::changeColumnCount()
// now 6x3 grid is visible, plus 1 extra below for refill
gridview->setWidth(240);
QVERIFY(QQuickTest::qWaitForPolish(gridview));
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
QCOMPARE(itemCount, 6*3 + 1);
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
@@ -3875,7 +3870,7 @@ void tst_QQuickGridView::changeColumnCount()
// back to single column
gridview->setWidth(100);
QVERIFY(QQuickTest::qWaitForPolish(gridview));
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
QCOMPARE(itemCount, 6);
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
@@ -3976,8 +3971,8 @@ void tst_QQuickGridView::onAdd()
qApp->processEvents();
QVariantList result = gridview->property("addedDelegates").toList();
- QTRY_COMPARE(result.count(), items.count());
- for (int i=0; i<items.count(); i++)
+ QTRY_COMPARE(result.size(), items.size());
+ for (int i=0; i<items.size(); i++)
QCOMPARE(result[i].toString(), items[i].first);
releaseView(window);
@@ -4461,7 +4456,7 @@ void tst_QQuickGridView::snapOneRow()
if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
QCOMPARE(gridview->currentIndex(), 2);
- QCOMPARE(currentIndexSpy.count(), 1);
+ QCOMPARE(currentIndexSpy.size(), 1);
}
// flick to end
@@ -4474,7 +4469,7 @@ void tst_QQuickGridView::snapOneRow()
if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
QCOMPARE(gridview->currentIndex(), 6);
- QCOMPARE(currentIndexSpy.count(), 3);
+ QCOMPARE(currentIndexSpy.size(), 3);
}
if (flow == QQuickGridView::FlowLeftToRight)
@@ -4497,7 +4492,7 @@ void tst_QQuickGridView::snapOneRow()
if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
QCOMPARE(gridview->currentIndex(), 0);
- QCOMPARE(currentIndexSpy.count(), 6);
+ QCOMPARE(currentIndexSpy.size(), 6);
}
releaseView(window);
@@ -4611,7 +4606,7 @@ void tst_QQuickGridView::populateTransitions()
QCOMPARE(gridview->property("countAddTransitions").toInt(), 0);
}
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
@@ -4633,7 +4628,7 @@ void tst_QQuickGridView::populateTransitions()
// clear the model
window->rootContext()->setContextProperty("testModel", QVariant());
QTRY_COMPARE(gridview->count(), 0);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").size(), 0);
gridview->setProperty("countPopulateTransitions", 0);
gridview->setProperty("countAddTransitions", 0);
@@ -4647,7 +4642,7 @@ void tst_QQuickGridView::populateTransitions()
QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 18 : 0);
QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
@@ -4665,7 +4660,7 @@ void tst_QQuickGridView::populateTransitions()
QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 18 : 0);
QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
@@ -4753,7 +4748,7 @@ void tst_QQuickGridView::addTransitions()
targetIndexes << i;
}
}
- QVERIFY(expectedTargetData.count() > 0);
+ QVERIFY(expectedTargetData.size() > 0);
}
// start animation
@@ -4766,7 +4761,7 @@ void tst_QQuickGridView::addTransitions()
QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
if (shouldAnimateTargets) {
- QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.size());
QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
@@ -4792,7 +4787,7 @@ void tst_QQuickGridView::addTransitions()
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
if (items[i]->y() >= gridview->contentY()) {
QQmlExpression e(qmlContext(items[i]), items[i], "index");
firstVisibleIndex = e.evaluate().toInt();
@@ -4802,7 +4797,7 @@ void tst_QQuickGridView::addTransitions()
QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
// verify all items moved to the correct final positions
- for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
+ for (int i = firstVisibleIndex; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
QCOMPARE(item->x(), (i%3)*80.0);
@@ -4965,7 +4960,7 @@ void tst_QQuickGridView::moveTransitions()
model.moveItems(moveFrom, moveTo, moveCount);
gridview->forceLayout();
- QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.size());
QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
@@ -4989,7 +4984,7 @@ void tst_QQuickGridView::moveTransitions()
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
if (items[i]->y() >= gridview->contentY()) {
QQmlExpression e(qmlContext(items[i]), items[i], "index");
firstVisibleIndex = e.evaluate().toInt();
@@ -5000,7 +4995,7 @@ void tst_QQuickGridView::moveTransitions()
// verify all items moved to the correct final positions
qreal pixelOffset = 60 * rowOffsetAfterMove;
- for (int i=firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
+ for (int i=firstVisibleIndex; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
QCOMPARE(item->x(), (i%3)*80.0);
@@ -5201,13 +5196,13 @@ void tst_QQuickGridView::removeTransitions()
targetIndexes << i;
}
}
- QVERIFY(expectedTargetData.count() > 0);
+ QVERIFY(expectedTargetData.size() > 0);
}
// calculate targetItems and expectedTargets before model changes
QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
QVariantMap expectedTargets;
- for (int i=0; i<targetIndexes.count(); i++)
+ for (int i=0; i<targetIndexes.size(); i++)
expectedTargets[model.name(targetIndexes[i])] = targetIndexes[i];
// start animation
@@ -5216,7 +5211,7 @@ void tst_QQuickGridView::removeTransitions()
QTRY_COMPARE(model.count(), gridview->count());
if (shouldAnimateTargets || expectedDisplacedIndexes.isValid()) {
- QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.size());
QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
@@ -5241,9 +5236,9 @@ void tst_QQuickGridView::removeTransitions()
}
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int itemCount = items.count();
+ int itemCount = items.size();
int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
QQmlExpression e(qmlContext(items[i]), items[i], "index");
int index = e.evaluate().toInt();
if (firstVisibleIndex < 0 && items[i]->y() >= gridview->contentY())
@@ -5438,15 +5433,15 @@ void tst_QQuickGridView::displacedTransitions()
QTRY_VERIFY(gridview->property("displaceTransitionsDone").toBool());
// check the correct number of target items and indexes were received
- QCOMPARE(resultTargetIndexes.count(), expectedDisplacedIndexes.count());
- for (int i=0; i<resultTargetIndexes.count(); i++)
- QCOMPARE(resultTargetIndexes[i].value<QList<int> >().count(), change.count);
- QCOMPARE(resultTargetItems.count(), expectedDisplacedIndexes.count());
- for (int i=0; i<resultTargetItems.count(); i++)
- QCOMPARE(resultTargetItems[i].toList().count(), change.count);
+ QCOMPARE(resultTargetIndexes.size(), expectedDisplacedIndexes.count());
+ for (int i=0; i<resultTargetIndexes.size(); i++)
+ QCOMPARE(resultTargetIndexes[i].value<QList<int> >().size(), change.count);
+ QCOMPARE(resultTargetItems.size(), expectedDisplacedIndexes.count());
+ for (int i=0; i<resultTargetItems.size(); i++)
+ QCOMPARE(resultTargetItems[i].toList().size(), change.count);
} else {
- QCOMPARE(resultTargetIndexes.count(), 0);
- QCOMPARE(resultTargetItems.count(), 0);
+ QCOMPARE(resultTargetIndexes.size(), 0);
+ QCOMPARE(resultTargetItems.size(), 0);
}
if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled)
@@ -5473,7 +5468,7 @@ void tst_QQuickGridView::displacedTransitions()
// verify all items moved to the correct final positions
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i < model.count() && i < items.count(); ++i) {
+ for (int i=0; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
QCOMPARE(item->x(), (i%3)*80.0);
@@ -5626,7 +5621,7 @@ void tst_QQuickGridView::multipleTransitions()
int timeBetweenActions = window->rootObject()->property("timeBetweenActions").toInt();
- for (int i=0; i<changes.count(); i++) {
+ for (int i=0; i<changes.size(); i++) {
switch (changes[i].type) {
case ListChange::Inserted:
{
@@ -5636,7 +5631,7 @@ void tst_QQuickGridView::multipleTransitions()
model.insertItems(changes[i].index, targetItems);
gridview->forceLayout();
QTRY_COMPARE(model.count(), gridview->count());
- if (i == changes.count() - 1) {
+ if (i == changes.size() - 1) {
QTRY_VERIFY(!gridview->property("runningAddTargets").toBool());
QTRY_VERIFY(!gridview->property("runningAddDisplaced").toBool());
} else {
@@ -5648,7 +5643,7 @@ void tst_QQuickGridView::multipleTransitions()
model.removeItems(changes[i].index, changes[i].count);
gridview->forceLayout();
QTRY_COMPARE(model.count(), gridview->count());
- if (i == changes.count() - 1) {
+ if (i == changes.size() - 1) {
QTRY_VERIFY(!gridview->property("runningRemoveTargets").toBool());
QTRY_VERIFY(!gridview->property("runningRemoveDisplaced").toBool());
} else {
@@ -5659,7 +5654,7 @@ void tst_QQuickGridView::multipleTransitions()
model.moveItems(changes[i].index, changes[i].to, changes[i].count);
gridview->forceLayout();
QVERIFY(QQuickTest::qWaitForPolish(gridview));
- if (i == changes.count() - 1) {
+ if (i == changes.size() - 1) {
QTRY_VERIFY(!gridview->property("runningMoveTargets").toBool());
QTRY_VERIFY(!gridview->property("runningMoveDisplaced").toBool());
} else {
@@ -5683,7 +5678,7 @@ void tst_QQuickGridView::multipleTransitions()
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
if (items[i]->y() >= contentY) {
QQmlExpression e(qmlContext(items[i]), items[i], "index");
firstVisibleIndex = e.evaluate().toInt();
@@ -5694,7 +5689,7 @@ void tst_QQuickGridView::multipleTransitions()
QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
// verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
@@ -5802,7 +5797,7 @@ void tst_QQuickGridView::multipleDisplaced()
// verify all items moved to the correct final positions
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i < model.count() && i < items.count(); ++i) {
+ for (int i=0; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->x(), (i%3)*80.0);
@@ -5896,7 +5891,7 @@ void tst_QQuickGridView::cacheBuffer()
QVERIFY(gridview->model() != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QTRY_COMPARE(item->x(), (i%3)*80.0);
@@ -5926,7 +5921,7 @@ void tst_QQuickGridView::cacheBuffer()
}
int newItemCount = 0;
- newItemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ newItemCount = findItems<QQuickItem>(contentItem, "wrapper", false).size();
// Confirm items positioned correctly
for (int i = 0; i < model.count() && i < newItemCount; ++i) {
@@ -6404,7 +6399,7 @@ QList<int> tst_QQuickGridView::toIntList(const QVariantList &list)
{
QList<int> ret;
bool ok = true;
- for (int i=0; i<list.count(); i++) {
+ for (int i=0; i<list.size(); i++) {
ret << list[i].toInt(&ok);
if (!ok)
qWarning() << "tst_QQuickGridView::toIntList(): not a number:" << list[i];
@@ -6416,7 +6411,7 @@ QList<int> tst_QQuickGridView::toIntList(const QVariantList &list)
void tst_QQuickGridView::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
{
const QSet<int> expectedIndexSet(expectedIndexes.cbegin(), expectedIndexes.cend());
- for (int i=0; i<indexLists.count(); i++) {
+ for (int i=0; i<indexLists.size(); i++) {
const auto &currentList = indexLists[i].value<QList<int> >();
const QSet<int> current(currentList.cbegin(), currentList.cend());
if (current != expectedIndexSet)
@@ -6436,19 +6431,19 @@ void tst_QQuickGridView::matchItemsAndIndexes(const QVariantMap &items, const Qa
qDebug() << itemIndex;
QCOMPARE(model.name(itemIndex), name);
}
- QCOMPARE(items.count(), expectedIndexes.count());
+ QCOMPARE(items.size(), expectedIndexes.size());
}
void tst_QQuickGridView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
{
- for (int i=0; i<itemLists.count(); i++) {
+ for (int i=0; i<itemLists.size(); i++) {
QVariantList current = itemLists[i].toList();
- for (int j=0; j<current.count(); j++) {
+ for (int j=0; j<current.size(); j++) {
QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
}
- QCOMPARE(current.count(), expectedItems.count());
+ QCOMPARE(current.size(), expectedItems.size());
}
}
@@ -6552,11 +6547,11 @@ void tst_QQuickGridView::jsArrayChange()
}
view->setModel(QVariant::fromValue(array1));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// no change
view->setModel(QVariant::fromValue(array2));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QQuickGridView::contentHeightWithDelayRemove_data()
@@ -6725,7 +6720,7 @@ void tst_QQuickGridView::keyNavigationEnabled()
// of disabling both mouse and keyboard interaction.
QSignalSpy enabledSpy(gridView, SIGNAL(keyNavigationEnabledChanged()));
gridView->setInteractive(false);
- QCOMPARE(enabledSpy.count(), 1);
+ QCOMPARE(enabledSpy.size(), 1);
QCOMPARE(gridView->isKeyNavigationEnabled(), false);
flick(window.data(), QPoint(200, 175), QPoint(200, 50), 100);
@@ -6738,17 +6733,17 @@ void tst_QQuickGridView::keyNavigationEnabled()
// Check that isKeyNavigationEnabled implicitly follows the value of interactive.
gridView->setInteractive(true);
- QCOMPARE(enabledSpy.count(), 2);
+ QCOMPARE(enabledSpy.size(), 2);
QCOMPARE(gridView->isKeyNavigationEnabled(), true);
// Change it back again for the next check.
gridView->setInteractive(false);
- QCOMPARE(enabledSpy.count(), 3);
+ QCOMPARE(enabledSpy.size(), 3);
QCOMPARE(gridView->isKeyNavigationEnabled(), false);
// Setting keyNavigationEnabled to true shouldn't enable mouse interaction.
gridView->setKeyNavigationEnabled(true);
- QCOMPARE(enabledSpy.count(), 4);
+ QCOMPARE(enabledSpy.size(), 4);
flick(window.data(), QPoint(200, 175), QPoint(200, 50), 100);
QVERIFY(!gridView->isMoving());
QCOMPARE(gridView->contentY(), 0.0);
@@ -6761,7 +6756,7 @@ void tst_QQuickGridView::keyNavigationEnabled()
// Changing interactive now shouldn't result in keyNavigationEnabled changing,
// since we broke the "binding".
gridView->setInteractive(true);
- QCOMPARE(enabledSpy.count(), 4);
+ QCOMPARE(enabledSpy.size(), 4);
// Keyboard interaction shouldn't work now.
gridView->setKeyNavigationEnabled(false);
diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
index 73b575f818..560fad64eb 100644
--- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp
+++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
@@ -582,9 +582,9 @@ void tst_qquickimage::noLoading()
ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
QTRY_COMPARE(obj->status(), QQuickImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 1);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 1);
+ QTRY_COMPARE(sourceSpy.size(), 1);
+ QTRY_COMPARE(progressSpy.size(), 0);
+ QTRY_COMPARE(statusSpy.size(), 1);
// Loading remote file
ctxt->setContextProperty("srcImage", server.url("/rect.png"));
@@ -592,9 +592,9 @@ void tst_qquickimage::noLoading()
QTRY_COMPARE(obj->progress(), 0.0);
QTRY_COMPARE(obj->status(), QQuickImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 2);
- QTRY_VERIFY(progressSpy.count() >= 2);
- QTRY_COMPARE(statusSpy.count(), 3);
+ QTRY_COMPARE(sourceSpy.size(), 2);
+ QTRY_VERIFY(progressSpy.size() >= 2);
+ QTRY_COMPARE(statusSpy.size(), 3);
// Loading remote file again - should not go through 'Loading' state.
progressSpy.clear();
@@ -602,9 +602,9 @@ void tst_qquickimage::noLoading()
ctxt->setContextProperty("srcImage", server.url("/rect.png"));
QTRY_COMPARE(obj->status(), QQuickImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 4);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 5);
+ QTRY_COMPARE(sourceSpy.size(), 4);
+ QTRY_COMPARE(progressSpy.size(), 0);
+ QTRY_COMPARE(statusSpy.size(), 5);
delete obj;
}
@@ -659,17 +659,17 @@ void tst_qquickimage::sourceSize_QTBUG_14303()
QTRY_COMPARE(obj->sourceSize().width(), 200);
QTRY_COMPARE(obj->sourceSize().height(), 200);
- QTRY_COMPARE(sourceSizeSpy.count(), 0);
+ QTRY_COMPARE(sourceSizeSpy.size(), 0);
ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
QTRY_COMPARE(obj->sourceSize().width(), 120);
QTRY_COMPARE(obj->sourceSize().height(), 120);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
+ QTRY_COMPARE(sourceSizeSpy.size(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
QTRY_COMPARE(obj->sourceSize().width(), 200);
QTRY_COMPARE(obj->sourceSize().height(), 200);
- QTRY_COMPARE(sourceSizeSpy.count(), 2);
+ QTRY_COMPARE(sourceSizeSpy.size(), 2);
delete obj;
}
@@ -811,48 +811,48 @@ void tst_qquickimage::sourceSizeChanges()
// Local
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(img->status(), QQuickImage::Null);
- QTRY_COMPARE(sourceSizeSpy.count(), 0);
+ QTRY_COMPARE(sourceSizeSpy.size(), 0);
ctxt->setContextProperty("srcImage", testFileUrl("heart.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
+ QTRY_COMPARE(sourceSizeSpy.size(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("heart.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
+ QTRY_COMPARE(sourceSizeSpy.size(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("heart_copy.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
+ QTRY_COMPARE(sourceSizeSpy.size(), 1);
ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 2);
+ QTRY_COMPARE(sourceSizeSpy.size(), 2);
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(img->status(), QQuickImage::Null);
- QTRY_COMPARE(sourceSizeSpy.count(), 3);
+ QTRY_COMPARE(sourceSizeSpy.size(), 3);
// Remote
ctxt->setContextProperty("srcImage", server.url("/heart.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 4);
+ QTRY_COMPARE(sourceSizeSpy.size(), 4);
ctxt->setContextProperty("srcImage", server.url("/heart.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 4);
+ QTRY_COMPARE(sourceSizeSpy.size(), 4);
ctxt->setContextProperty("srcImage", server.url("/heart_copy.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 4);
+ QTRY_COMPARE(sourceSizeSpy.size(), 4);
ctxt->setContextProperty("srcImage", server.url("/colors.png"));
QTRY_COMPARE(img->status(), QQuickImage::Ready);
- QTRY_COMPARE(sourceSizeSpy.count(), 5);
+ QTRY_COMPARE(sourceSizeSpy.size(), 5);
ctxt->setContextProperty("srcImage", QUrl(""));
QTRY_COMPARE(img->status(), QQuickImage::Null);
- QTRY_COMPARE(sourceSizeSpy.count(), 6);
+ QTRY_COMPARE(sourceSizeSpy.size(), 6);
delete img;
}
@@ -954,17 +954,17 @@ void tst_qquickimage::progressAndStatusChanges()
ctxt->setContextProperty("srcImage", testFileUrl("heart.png"));
QTRY_COMPARE(obj->status(), QQuickImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 0);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 0);
+ QTRY_COMPARE(sourceSpy.size(), 0);
+ QTRY_COMPARE(progressSpy.size(), 0);
+ QTRY_COMPARE(statusSpy.size(), 0);
// Loading local file
ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
QTRY_COMPARE(obj->status(), QQuickImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 1);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 1);
+ QTRY_COMPARE(sourceSpy.size(), 1);
+ QTRY_COMPARE(progressSpy.size(), 0);
+ QTRY_COMPARE(statusSpy.size(), 1);
// Loading remote file
ctxt->setContextProperty("srcImage", server.url("/heart.png"));
@@ -972,16 +972,16 @@ void tst_qquickimage::progressAndStatusChanges()
QTRY_COMPARE(obj->progress(), 0.0);
QTRY_COMPARE(obj->status(), QQuickImage::Ready);
QTRY_COMPARE(obj->progress(), 1.0);
- QTRY_COMPARE(sourceSpy.count(), 2);
- QTRY_VERIFY(progressSpy.count() > 1);
- QTRY_COMPARE(statusSpy.count(), 3);
+ QTRY_COMPARE(sourceSpy.size(), 2);
+ QTRY_VERIFY(progressSpy.size() > 1);
+ QTRY_COMPARE(statusSpy.size(), 3);
ctxt->setContextProperty("srcImage", "");
QTRY_COMPARE(obj->status(), QQuickImage::Null);
QTRY_COMPARE(obj->progress(), 0.0);
- QTRY_COMPARE(sourceSpy.count(), 3);
- QTRY_VERIFY(progressSpy.count() > 2);
- QTRY_COMPARE(statusSpy.count(), 4);
+ QTRY_COMPARE(sourceSpy.size(), 3);
+ QTRY_VERIFY(progressSpy.size() > 2);
+ QTRY_COMPARE(statusSpy.size(), 4);
delete obj;
}
@@ -1209,7 +1209,7 @@ void tst_qquickimage::multiFrame()
if (asynchronous) {
QCOMPARE(image->frameCount(), 0);
QTRY_COMPARE(image->frameCount(), 4);
- QCOMPARE(countSpy.count(), 1);
+ QCOMPARE(countSpy.size(), 1);
} else {
QCOMPARE(image->frameCount(), 4);
}
@@ -1228,7 +1228,7 @@ void tst_qquickimage::multiFrame()
image->setCurrentFrame(1);
QTRY_COMPARE(image->status(), QQuickImageBase::Ready);
- QCOMPARE(currentSpy.count(), 1);
+ QCOMPARE(currentSpy.size(), 1);
QCOMPARE(image->currentFrame(), 1);
contents = toUnscaledImage(view.grabWindow());
// The second frame is a green ball, approximately qRgba(0x27, 0xc8, 0x22, 0xff)
diff --git a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
index aa44e9ad61..78727d32a0 100644
--- a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
+++ b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
@@ -423,7 +423,7 @@ void tst_qquickimageprovider::threadTest()
//MUST not deadlock
QVERIFY(obj != nullptr);
QList<QQuickImage *> images = obj->findChildren<QQuickImage *>();
- QCOMPARE(images.count(), 4);
+ QCOMPARE(images.size(), 4);
QTest::qWait(100);
foreach (QQuickImage *img, images) {
QCOMPARE(img->status(), QQuickImage::Loading);
@@ -542,7 +542,7 @@ void tst_qquickimageprovider::asyncTextureTest()
//MUST not deadlock
QVERIFY(obj != nullptr);
QList<QQuickImage *> images = obj->findChildren<QQuickImage *>();
- QCOMPARE(images.count(), 4);
+ QCOMPARE(images.size(), 4);
QTRY_COMPARE(provider->pool.activeThreadCount(), 4);
foreach (QQuickImage *img, images) {
@@ -615,7 +615,7 @@ void tst_qquickimageprovider::instantAsyncTextureTest()
QVERIFY(!obj.isNull());
const QList<QQuickImage *> images = obj->findChildren<QQuickImage *>();
- QCOMPARE(images.count(), 4);
+ QCOMPARE(images.size(), 4);
for (QQuickImage *img: images) {
QTRY_COMPARE(img->status(), QQuickImage::Ready);
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index c74134c113..2736d6d9bb 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -1035,13 +1035,13 @@ void tst_qquickitem::constructor()
QQuickItem *child1 = new QQuickItem(root.data());
QCOMPARE(child1->parent(), root.data());
QCOMPARE(child1->parentItem(), root.data());
- QCOMPARE(root->childItems().count(), 1);
+ QCOMPARE(root->childItems().size(), 1);
QCOMPARE(root->childItems().at(0), child1);
QQuickItem *child2 = new QQuickItem(root.data());
QCOMPARE(child2->parent(), root.data());
QCOMPARE(child2->parentItem(), root.data());
- QCOMPARE(root->childItems().count(), 2);
+ QCOMPARE(root->childItems().size(), 2);
QCOMPARE(root->childItems().at(0), child1);
QCOMPARE(root->childItems().at(1), child2);
}
@@ -1059,7 +1059,7 @@ void tst_qquickitem::setParentItem()
child1->setParentItem(root);
QVERIFY(!child1->parent());
QCOMPARE(child1->parentItem(), root);
- QCOMPARE(root->childItems().count(), 1);
+ QCOMPARE(root->childItems().size(), 1);
QCOMPARE(root->childItems().at(0), child1);
QQuickItem *child2 = new QQuickItem;
@@ -1068,14 +1068,14 @@ void tst_qquickitem::setParentItem()
child2->setParentItem(root);
QVERIFY(!child2->parent());
QCOMPARE(child2->parentItem(), root);
- QCOMPARE(root->childItems().count(), 2);
+ QCOMPARE(root->childItems().size(), 2);
QCOMPARE(root->childItems().at(0), child1);
QCOMPARE(root->childItems().at(1), child2);
child1->setParentItem(nullptr);
QVERIFY(!child1->parent());
QVERIFY(!child1->parentItem());
- QCOMPARE(root->childItems().count(), 1);
+ QCOMPARE(root->childItems().size(), 1);
QCOMPARE(root->childItems().at(0), child2);
delete root;
@@ -1565,7 +1565,7 @@ void tst_qquickitem::polishLoopDetection()
}
QList<QQuickItem*> items = window.contentItem()->childItems();
- for (int i = 0; i < items.count(); ++i) {
+ for (int i = 0; i < items.size(); ++i) {
static_cast<TestPolishItem*>(items.at(i))->doPolish();
}
item = static_cast<TestPolishItem*>(items.first());
@@ -1921,7 +1921,7 @@ void tst_qquickitem::paintOrder()
QList<QQuickItem*> list = QQuickItemPrivate::get(root)->paintOrderChildItems();
QStringList items;
- for (int i = 0; i < list.count(); ++i)
+ for (int i = 0; i < list.size(); ++i)
items << list.at(i)->objectName();
QCOMPARE(items, expected);
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index 161397640e..2c4b2dd6ec 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -2548,19 +2548,19 @@ void tst_QQuickItem::smooth()
item->setSmooth(true);
QVERIFY(item->smooth());
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
QList<QVariant> arguments = spy.first();
- QCOMPARE(arguments.count(), 1);
+ QCOMPARE(arguments.size(), 1);
QVERIFY(arguments.at(0).toBool());
item->setSmooth(true);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
item->setSmooth(false);
QVERIFY(!item->smooth());
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
item->setSmooth(false);
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
delete item;
}
@@ -2577,19 +2577,19 @@ void tst_QQuickItem::antialiasing()
item->setAntialiasing(true);
QVERIFY(item->antialiasing());
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
QList<QVariant> arguments = spy.first();
- QCOMPARE(arguments.count(), 1);
+ QCOMPARE(arguments.size(), 1);
QVERIFY(arguments.at(0).toBool());
item->setAntialiasing(true);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
item->setAntialiasing(false);
QVERIFY(!item->antialiasing());
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
item->setAntialiasing(false);
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
delete item;
}
@@ -2608,18 +2608,18 @@ void tst_QQuickItem::clip()
QVERIFY(item->clip());
QList<QVariant> arguments = spy.first();
- QCOMPARE(arguments.count(), 1);
+ QCOMPARE(arguments.size(), 1);
QVERIFY(arguments.at(0).toBool());
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
item->setClip(true);
- QCOMPARE(spy.count(),1);
+ QCOMPARE(spy.size(),1);
item->setClip(false);
QVERIFY(!item->clip());
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
item->setClip(false);
- QCOMPARE(spy.count(),2);
+ QCOMPARE(spy.size(),2);
delete item;
}
@@ -2927,50 +2927,50 @@ void tst_QQuickItem::propertyChanges()
item->setBaselineOffset(10.0);
QCOMPARE(item->parentItem(), parentItem);
- QCOMPARE(parentSpy.count(),1);
+ QCOMPARE(parentSpy.size(),1);
QList<QVariant> parentArguments = parentSpy.first();
- QCOMPARE(parentArguments.count(), 1);
+ QCOMPARE(parentArguments.size(), 1);
QCOMPARE(item->parentItem(), qvariant_cast<QQuickItem *>(parentArguments.at(0)));
- QCOMPARE(childrenChangedSpy.count(),1);
+ QCOMPARE(childrenChangedSpy.size(),1);
item->setParentItem(parentItem);
- QCOMPARE(childrenChangedSpy.count(),1);
+ QCOMPARE(childrenChangedSpy.size(),1);
QCOMPARE(item->width(), 100.0);
- QCOMPARE(widthSpy.count(),1);
+ QCOMPARE(widthSpy.size(),1);
QCOMPARE(item->height(), 200.0);
- QCOMPARE(heightSpy.count(),1);
+ QCOMPARE(heightSpy.size(),1);
QCOMPARE(item->baselineOffset(), 10.0);
- QCOMPARE(baselineOffsetSpy.count(),1);
+ QCOMPARE(baselineOffsetSpy.size(),1);
QList<QVariant> baselineOffsetArguments = baselineOffsetSpy.first();
- QCOMPARE(baselineOffsetArguments.count(), 1);
+ QCOMPARE(baselineOffsetArguments.size(), 1);
QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal());
QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0));
- QCOMPARE(childrenRectSpy.count(),1);
+ QCOMPARE(childrenRectSpy.size(),1);
QList<QVariant> childrenRectArguments = childrenRectSpy.at(0);
- QCOMPARE(childrenRectArguments.count(), 1);
+ QCOMPARE(childrenRectArguments.size(), 1);
QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF());
QCOMPARE(item->hasActiveFocus(), true);
- QCOMPARE(focusSpy.count(),1);
+ QCOMPARE(focusSpy.size(),1);
QList<QVariant> focusArguments = focusSpy.first();
- QCOMPARE(focusArguments.count(), 1);
+ QCOMPARE(focusArguments.size(), 1);
QCOMPARE(focusArguments.at(0).toBool(), true);
QCOMPARE(parentItem->hasActiveFocus(), false);
QCOMPARE(parentItem->hasFocus(), false);
- QCOMPARE(wantsFocusSpy.count(),0);
+ QCOMPARE(wantsFocusSpy.size(),0);
item->setX(10.0);
QCOMPARE(item->x(), 10.0);
- QCOMPARE(xSpy.count(), 1);
+ QCOMPARE(xSpy.size(), 1);
item->setY(10.0);
QCOMPARE(item->y(), 10.0);
- QCOMPARE(ySpy.count(), 1);
+ QCOMPARE(ySpy.size(), 1);
delete window;
}
@@ -3255,7 +3255,7 @@ void tst_QQuickItem::changeListener()
QCOMPARE(child2Listener.count(QQuickItemPrivate::Destroyed), 1);
QQuickItemPrivate::get(parent)->removeItemChangeListener(&parentListener, QQuickItemPrivate::Children);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), 0);
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), 0);
// QTBUG-54732: all listeners should get invoked even if they remove themselves while iterating the listeners
QList<TestListener *> listeners;
@@ -3265,89 +3265,89 @@ void tst_QQuickItem::changeListener()
// itemVisibilityChanged x 5
foreach (TestListener *listener, listeners)
QQuickItemPrivate::get(parent)->addItemChangeListener(listener, QQuickItemPrivate::Visibility);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), listeners.count());
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), listeners.size());
parent->setVisible(false);
foreach (TestListener *listener, listeners)
QCOMPARE(listener->count(QQuickItemPrivate::Visibility), 1);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), 0);
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), 0);
// itemRotationChanged x 5
foreach (TestListener *listener, listeners)
QQuickItemPrivate::get(parent)->addItemChangeListener(listener, QQuickItemPrivate::Rotation);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), listeners.count());
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), listeners.size());
parent->setRotation(90);
foreach (TestListener *listener, listeners)
QCOMPARE(listener->count(QQuickItemPrivate::Rotation), 1);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), 0);
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), 0);
// itemOpacityChanged x 5
foreach (TestListener *listener, listeners)
QQuickItemPrivate::get(parent)->addItemChangeListener(listener, QQuickItemPrivate::Opacity);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), listeners.count());
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), listeners.size());
parent->setOpacity(0.5);
foreach (TestListener *listener, listeners)
QCOMPARE(listener->count(QQuickItemPrivate::Opacity), 1);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), 0);
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), 0);
// itemChildAdded() x 5
foreach (TestListener *listener, listeners)
QQuickItemPrivate::get(parent)->addItemChangeListener(listener, QQuickItemPrivate::Children);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), listeners.count());
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), listeners.size());
child1 = new QQuickItem(parent);
foreach (TestListener *listener, listeners)
QCOMPARE(listener->count(QQuickItemPrivate::Children), 1);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), 0);
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), 0);
// itemParentChanged() x 5
foreach (TestListener *listener, listeners)
QQuickItemPrivate::get(child1)->addItemChangeListener(listener, QQuickItemPrivate::Parent);
- QCOMPARE(QQuickItemPrivate::get(child1)->changeListeners.count(), listeners.count());
+ QCOMPARE(QQuickItemPrivate::get(child1)->changeListeners.size(), listeners.size());
child1->setParentItem(nullptr);
foreach (TestListener *listener, listeners)
QCOMPARE(listener->count(QQuickItemPrivate::Parent), 1);
- QCOMPARE(QQuickItemPrivate::get(child1)->changeListeners.count(), 0);
+ QCOMPARE(QQuickItemPrivate::get(child1)->changeListeners.size(), 0);
// itemImplicitWidthChanged() x 5
foreach (TestListener *listener, listeners)
QQuickItemPrivate::get(parent)->addItemChangeListener(listener, QQuickItemPrivate::ImplicitWidth);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), listeners.count());
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), listeners.size());
parent->setImplicitWidth(parent->implicitWidth() + 1);
foreach (TestListener *listener, listeners)
QCOMPARE(listener->count(QQuickItemPrivate::ImplicitWidth), 1);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), 0);
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), 0);
// itemImplicitHeightChanged() x 5
foreach (TestListener *listener, listeners)
QQuickItemPrivate::get(parent)->addItemChangeListener(listener, QQuickItemPrivate::ImplicitHeight);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), listeners.count());
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), listeners.size());
parent->setImplicitHeight(parent->implicitHeight() + 1);
foreach (TestListener *listener, listeners)
QCOMPARE(listener->count(QQuickItemPrivate::ImplicitHeight), 1);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), 0);
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), 0);
// itemGeometryChanged() x 5
foreach (TestListener *listener, listeners)
QQuickItemPrivate::get(parent)->addItemChangeListener(listener, QQuickItemPrivate::Geometry);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), listeners.count());
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), listeners.size());
parent->setWidth(parent->width() + 1);
foreach (TestListener *listener, listeners)
QCOMPARE(listener->count(QQuickItemPrivate::Geometry), 1);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), 0);
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), 0);
// itemChildRemoved() x 5
child1->setParentItem(parent);
foreach (TestListener *listener, listeners)
QQuickItemPrivate::get(parent)->addItemChangeListener(listener, QQuickItemPrivate::Children);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), listeners.count());
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), listeners.size());
delete child1;
foreach (TestListener *listener, listeners)
QCOMPARE(listener->count(QQuickItemPrivate::Children), 2);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), 0);
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), 0);
// itemDestroyed() x 5
foreach (TestListener *listener, listeners)
QQuickItemPrivate::get(parent)->addItemChangeListener(listener, QQuickItemPrivate::Destroyed);
- QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.count(), listeners.count());
+ QCOMPARE(QQuickItemPrivate::get(parent)->changeListeners.size(), listeners.size());
delete parent;
foreach (TestListener *listener, listeners)
QCOMPARE(listener->count(QQuickItemPrivate::Destroyed), 1);
diff --git a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
index 9ecad57ffc..261b8a9a8e 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
@@ -539,6 +539,56 @@ Item {
tryCompare(layout.children[4], "y", 60);
}
+ Component {
+ id: layout_alignBaseline_Component
+ GridLayout {
+ columns: 2
+ columnSpacing: 0
+ rowSpacing: 0
+ TextInput {
+ property var itemRect: [x, y, width, height]
+ text: "red"
+ baselineOffset: 7
+ color: "red"
+ verticalAlignment: TextInput.AlignVCenter
+ Layout.preferredWidth: 50
+ Layout.preferredHeight: 10
+ Layout.fillHeight: true
+ }
+ TextInput {
+ property var itemRect: [x, y, width, height]
+ text: "green"
+ baselineOffset: 7
+ color: "green"
+ verticalAlignment: TextInput.AlignVCenter
+ Layout.preferredWidth: 50
+ Layout.preferredHeight: 10
+ Layout.fillHeight: true
+ }
+
+ }
+ }
+
+ function test_alignBaseline_dont_always_invalidate()
+ {
+ var layout = createTemporaryObject(layout_alignBaseline_Component, container);
+ waitForItemPolished(layout)
+ layout.height = 20
+ // Adjusting height on an item that uses Qt.AlignBaseline might adjust the baseline
+ // Test if we don't get excessive number of polish() events because of baseline changes
+ // (In this case, we don't want to align by the baseline)
+ compare(isPolishScheduled(layout), false)
+ waitForItemPolished(layout)
+ var c0 = layout.children[0]
+ c0.Layout.alignment = Qt.AlignBaseline
+ var c1 = layout.children[1]
+ c1.Layout.alignment = Qt.AlignBaseline
+
+ // We want to align by baseline => expect a polish event
+ compare(isPolishScheduled(layout), true)
+ waitForItemPolished(layout)
+ }
+
Component {
id: layout_rightToLeft_Component
diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
index e14b7a2d89..4fd288cfc1 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
@@ -32,6 +32,18 @@ Item {
}
Component {
+ id: layout_rowLayout_Component
+ RowLayout {
+ }
+ }
+
+ Component {
+ id: layout_columnLayout_Component
+ ColumnLayout {
+ }
+ }
+
+ Component {
id: itemsWithAnchorsLayout_Component
RowLayout {
spacing: 2
@@ -495,6 +507,102 @@ Item {
layout.destroy();
}
+
+ function buildLayout(layout, arrLayoutData) {
+ for (let i = 0; i < arrLayoutData.length; i++) {
+ let layoutItemDesc = arrLayoutData[i]
+ let rect = layoutItem_Component.createObject(layout)
+ for (let keyName in layoutItemDesc) {
+ rect.Layout[keyName] = layoutItemDesc[keyName]
+ }
+ }
+ }
+
+ function test_dynamicAlignment_data()
+ {
+ return [
+ {
+ tag: "simple",
+
+ layout: {
+ type: "RowLayout",
+ items: [
+ {preferredWidth: 30, preferredHeight: 20, fillHeight: true},
+ {preferredWidth: 30, preferredHeight: 20},
+ ]
+ },
+ expectedGeometries: [
+ [ 0, 0, 30, 60],
+ [30, 20, 30, 20]
+ ]
+ },{
+ tag: "valign",
+ layout: {
+ type: "RowLayout",
+ items: [
+ {preferredWidth: 12, preferredHeight: 20, fillHeight: true},
+ {preferredWidth: 12, preferredHeight: 20},
+ {preferredWidth: 12, preferredHeight: 20, alignment: Qt.AlignTop},
+ {preferredWidth: 12, preferredHeight: 20, alignment: Qt.AlignVCenter},
+ {preferredWidth: 12, preferredHeight: 20, alignment: Qt.AlignBottom}
+ ]
+ },
+ expectedGeometries: [
+ [ 0, 0, 12, 60],
+ [12, 20, 12, 20],
+ [24, 0, 12, 20],
+ [36, 20, 12, 20],
+ [48, 40, 12, 20]
+ ]
+ },{
+ tag: "halign",
+ layout: {
+ type: "ColumnLayout",
+ items: [
+ {preferredWidth: 20, preferredHeight: 12, fillWidth: true},
+ {preferredWidth: 20, preferredHeight: 12},
+ {preferredWidth: 20, preferredHeight: 12, alignment: Qt.AlignLeft},
+ {preferredWidth: 20, preferredHeight: 12, alignment: Qt.AlignHCenter},
+ {preferredWidth: 20, preferredHeight: 12, alignment: Qt.AlignRight}
+ ]
+ },
+ expectedGeometries: [
+ [ 0, 0, 60, 12],
+ [ 0, 12, 20, 12],
+ [ 0, 24, 20, 12],
+ [20, 36, 20, 12],
+ [40, 48, 20, 12]
+ ]
+ }
+ ]
+ }
+
+ function test_dynamicAlignment(data)
+ {
+ let layout
+ switch (data.layout.type) {
+ case "RowLayout":
+ layout = createTemporaryObject(layout_rowLayout_Component, container)
+ break
+ case "ColumnLayout":
+ layout = createTemporaryObject(layout_columnLayout_Component, container)
+ break
+ default:
+ console.log("data.layout.type not recognized(" + data.layout.type + ")")
+ }
+ layout.spacing = 0
+ buildLayout(layout, data.layout.items)
+ layout.width = 60
+ layout.height = 60 // divides in 1/2/3/4/5/6
+ waitForItemPolished(layout)
+
+ for (let i = 0; i < layout.children.length; ++i) {
+ let itm = layout.children[i]
+ compare(itemRect(itm), data.expectedGeometries[i])
+ }
+ }
+
+
Component {
id: layout_sizeHintNormalization_Component
GridLayout {
@@ -751,13 +859,6 @@ Item {
layout.destroy();
}
-
- Component {
- id: layout_rowLayout_Component
- RowLayout {
- }
- }
-
function test_stretchItem_data()
{
return [
diff --git a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
index a04e7a9dd7..85a5bbc88f 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
@@ -263,5 +263,499 @@ Item {
compare(layout.implicitWidth, 20)
compare(layout.implicitHeight, 20)
}
+
+ Component {
+ id: layout_setCurrentIndex_Component
+
+ StackLayout {
+ width: 200
+ height: 200
+
+ property alias firstItem : rect
+ property alias secondItem: rowLayout
+
+ Rectangle {
+ id: rect
+ color: "red"
+ implicitWidth: 10
+ implicitHeight: 10
+ }
+ RowLayout {
+ id: rowLayout
+ spacing: 0
+ Rectangle {
+ color: "green"
+ implicitWidth: 10
+ implicitHeight: 10
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "blue"
+ implicitWidth: 10
+ implicitHeight: 10
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ }
+ }
+ }
+
+ function test_setCurrentIndex()
+ {
+ var layout = layout_setCurrentIndex_Component.createObject(container)
+ compare(layout.firstItem.width, 200)
+
+ // Invalidate the StackLayout (and its cached size hints)
+ layout.firstItem.implicitWidth = 42
+
+ layout.currentIndex = 1
+ compare(layout.secondItem.width, 200) // width should not be -1
+ layout.destroy()
+ }
+
+ function geometry(item) {
+ return [item.x, item.y, item.width, item.height]
+ }
+
+ Component {
+ id: countGeometryChanges_Component
+ StackLayout {
+ id: stack
+ property alias col: _col
+ property alias row: _row
+ width: 100
+ ColumnLayout {
+ id: _col
+ property alias r1: _r1
+ property alias r2: _r2
+ property alias r3: _r3
+ spacing: 0
+ property int counter : 0
+ onWidthChanged: { ++counter; }
+ Rectangle {
+ id: _r1
+ implicitWidth: 20
+ implicitHeight: 20
+ Layout.fillWidth: true
+ property int counter : 0
+ onWidthChanged: { ++counter; }
+ }
+ Rectangle {
+ id: _r2
+ implicitWidth: 50
+ implicitHeight: 50
+ Layout.fillWidth: true
+ property int counter : 0
+ onWidthChanged: { ++counter; }
+ }
+ Rectangle {
+ id: _r3
+ implicitWidth: 40
+ implicitHeight: 40
+ Layout.fillWidth: true
+ property int counter : 0
+ onWidthChanged: { ++counter; }
+ }
+ }
+ RowLayout {
+ id: _row
+ property alias r5: _r5
+ spacing: 0
+ property int counter : 0
+ onWidthChanged: { ++counter; }
+ Rectangle {
+ id: _r5
+ implicitWidth: 100
+ implicitHeight: 100
+ Layout.fillWidth: true
+ property int counter : 0
+ onWidthChanged: { ++counter; }
+ }
+ }
+ }
+ }
+
+ function test_countGeometryChanges() {
+
+ var stack = countGeometryChanges_Component.createObject(container)
+ compare(stack.currentIndex, 0)
+ compare(stack.col.width, 100)
+ compare(stack.col.height, 110)
+ compare(stack.row.width, 100)
+ compare(stack.row.height, 100)
+ verify(stack.col.r1.counter <= 2)
+ compare(stack.col.r2.counter, 1)
+ verify(stack.col.r3.counter <= 2)
+ verify(stack.col.counter <= 2)
+ compare(stack.row.counter, 1) // not visible, will only receive the initial geometry change
+ compare(stack.row.r5.counter, 0)
+ stack.destroy()
+ }
+
+
+ Component {
+ id: layoutItem_Component
+ Rectangle {
+ implicitWidth: 20
+ implicitHeight: 20
+ }
+ }
+
+ Component {
+ id: emtpy_StackLayout_Component
+ StackLayout {
+ property int num_onCountChanged: 0
+ property int num_onCurrentIndexChanged: 0
+ onCountChanged: { ++num_onCountChanged; }
+ onCurrentIndexChanged: { ++num_onCurrentIndexChanged; }
+ }
+ }
+
+ function test_addAndRemoveItems()
+ {
+ var stack = emtpy_StackLayout_Component.createObject(container)
+ stack.currentIndex = 2
+ compare(stack.implicitWidth, 0)
+ compare(stack.implicitHeight, 0)
+
+ var rect0 = layoutItem_Component.createObject(stack)
+ verify(waitForItemPolished(stack))
+ compare(stack.implicitWidth, 20)
+ compare(stack.implicitHeight, 20)
+ compare(rect0.visible, false)
+
+ var rect1 = layoutItem_Component.createObject(stack)
+ rect1.Layout.preferredWidth = 30
+ rect1.Layout.preferredHeight = 10
+ verify(waitForItemPolished(stack))
+ compare(stack.implicitWidth, 30)
+ compare(stack.implicitHeight, 20)
+ compare(rect0.visible, false)
+ compare(rect1.visible, false)
+
+ var rect2 = layoutItem_Component.createObject(stack)
+ rect2.x = 42 // ### items in a stacklayout will have their x and y positions discarded.
+ rect2.y = 42
+ rect2.Layout.preferredWidth = 80
+ rect2.Layout.preferredHeight = 30
+ rect2.Layout.fillWidth = true
+ verify(waitForItemPolished(stack))
+ compare(stack.implicitWidth, 80)
+ compare(stack.implicitHeight, 30)
+ compare(rect0.visible, false)
+ compare(rect1.visible, false)
+ compare(rect2.visible, true)
+ compare(geometry(rect2), geometry(stack))
+
+ rect2.destroy()
+ wait(0)
+ verify(waitForItemPolished(stack))
+ compare(stack.implicitWidth, 30)
+ compare(stack.implicitHeight, 20)
+
+ rect0.destroy()
+ wait(0)
+ verify(waitForItemPolished(stack))
+ compare(stack.implicitWidth, 30)
+ compare(stack.implicitHeight, 10)
+
+ rect1.destroy()
+ wait(0)
+ verify(waitForItemPolished(stack))
+ compare(stack.implicitWidth, 0)
+ compare(stack.implicitHeight, 0)
+
+ stack.destroy()
+ }
+
+ function test_sizeHint_data() {
+ return [
+ { tag: "propagateNone", layoutHints: [10, 20, 30], childHints: [11, 21, 31], expected:[10, 20, Number.POSITIVE_INFINITY]},
+ { tag: "propagateMinimumWidth", layoutHints: [-1, 20, 30], childHints: [10, 21, 31], expected:[10, 20, Number.POSITIVE_INFINITY]},
+ { tag: "propagatePreferredWidth", layoutHints: [10, -1, 30], childHints: [11, 20, 31], expected:[10, 20, Number.POSITIVE_INFINITY]},
+ { tag: "propagateMaximumWidth", layoutHints: [10, 20, -1], childHints: [11, 21, 30], expected:[10, 20, Number.POSITIVE_INFINITY]},
+ { tag: "propagateAll", layoutHints: [-1, -1, -1], childHints: [10, 20, 30], expected:[10, 20, Number.POSITIVE_INFINITY]},
+ { tag: "propagateCrazy", layoutHints: [-1, -1, -1], childHints: [40, 21, 30], expected:[30, 30, Number.POSITIVE_INFINITY]},
+ { tag: "expandMinToExplicitPref", layoutHints: [-1, 1, -1], childHints: [11, 21, 31], expected:[ 1, 1, Number.POSITIVE_INFINITY]},
+ { tag: "expandMaxToExplicitPref", layoutHints: [-1, 99, -1], childHints: [11, 21, 31], expected:[11, 99, Number.POSITIVE_INFINITY]},
+ { tag: "expandAllToExplicitMin", layoutHints: [99, -1, -1], childHints: [11, 21, 31], expected:[99, 99, Number.POSITIVE_INFINITY]},
+ { tag: "expandPrefToExplicitMin", layoutHints: [24, -1, -1], childHints: [11, 21, 31], expected:[24, 24, Number.POSITIVE_INFINITY]},
+ { tag: "boundPrefToExplicitMax", layoutHints: [-1, -1, 19], childHints: [11, 21, 31], expected:[11, 19, Number.POSITIVE_INFINITY]},
+ { tag: "boundAllToExplicitMax", layoutHints: [-1, -1, 9], childHints: [11, 21, 31], expected:[ 9, 9, Number.POSITIVE_INFINITY]},
+ ];
+ }
+
+ function itemSizeHints(item) {
+ return [item.Layout.minimumWidth, item.implicitWidth, item.Layout.maximumWidth]
+ }
+ Component {
+ id: stacklayout_sizeHint_Component
+ StackLayout {
+ property int implicitWidthChangedCount : 0
+ onImplicitWidthChanged: { ++implicitWidthChangedCount }
+ ColumnLayout {
+ Rectangle {
+ id: r1
+ color: "red"
+ Layout.minimumWidth: 1
+ Layout.preferredWidth: 2
+ Layout.maximumWidth: 3
+
+ Layout.minimumHeight: 20
+ Layout.preferredHeight: 20
+ Layout.maximumHeight: 20
+ Layout.fillWidth: true
+ }
+ }
+ }
+ }
+
+ function test_sizeHint(data) {
+ var layout = stacklayout_sizeHint_Component.createObject(container)
+
+ var col = layout.children[0]
+ col.Layout.minimumWidth = data.layoutHints[0]
+ col.Layout.preferredWidth = data.layoutHints[1]
+ col.Layout.maximumWidth = data.layoutHints[2]
+
+ var child = col.children[0]
+ if (data.implicitWidth !== undefined) {
+ child.implicitWidth = data.implicitWidth
+ }
+ child.Layout.minimumWidth = data.childHints[0]
+ child.Layout.preferredWidth = data.childHints[1]
+ child.Layout.maximumWidth = data.childHints[2]
+
+ verify(waitForItemPolished(layout))
+ var effectiveSizeHintResult = [layout.Layout.minimumWidth, layout.implicitWidth, layout.Layout.maximumWidth]
+ compare(effectiveSizeHintResult, data.expected)
+ layout.destroy()
+ }
+
+ Component {
+ id: stacklayout_addIgnoredItem_Component
+ StackLayout {
+ Repeater {
+ id: rep
+ model: 1
+ Rectangle {
+ id: r
+ }
+ }
+ }
+ }
+
+ // Items with no size information is ignored.
+ function test_addIgnoredItem()
+ {
+ var stack = stacklayout_addIgnoredItem_Component.createObject(container)
+ compare(stack.count, 1)
+ compare(stack.implicitWidth, 0)
+ compare(stack.implicitHeight, 0)
+ var r = stack.children[0]
+ r.Layout.preferredWidth = 20
+ r.Layout.preferredHeight = 30
+ verify(waitForItemPolished(stack))
+ compare(stack.count, 1)
+ compare(stack.implicitWidth, 20)
+ compare(stack.implicitHeight, 30)
+ stack.destroy();
+ }
+
+ function test_dontCrashWhenAnchoredToAWindow() {
+ var test_layoutStr =
+ 'import QtQuick; \
+ import QtQuick.Window; \
+ import QtQuick.Layouts; \
+ Window { \
+ visible: true; \
+ width: stack.implicitWidth; \
+ height: stack.implicitHeight; \
+ StackLayout { \
+ id: stack; \
+ currentIndex: 0; \
+ anchors.fill: parent; \
+ Rectangle { \
+ color: "red"; \
+ implicitWidth: 300; \
+ implicitHeight: 200; \
+ } \
+ } \
+ } '
+
+ var win = Qt.createQmlObject(test_layoutStr, container, '');
+ if (win.visibility === Window.Windowed) {
+ // on single-window systems (such as Android), the window geometry will be
+ // fullscreen, and most likely it will be set to screen size. Avoid this test for
+ // those systems, as the size of the window will not be determined by the layout
+ tryCompare(win, 'width', 300);
+ }
+ win.destroy()
+ }
+
+ Component {
+ id: test_dontCrashWhenChildIsResizedToNull_Component
+ StackLayout {
+ property alias rect : _rect
+ Rectangle {
+ id: _rect;
+ color: "red"
+ implicitWidth: 200
+ implicitHeight: 200
+ }
+ }
+ }
+
+ function test_dontCrashWhenChildIsResizedToNull() {
+ var layout = test_dontCrashWhenChildIsResizedToNull_Component.createObject(container)
+ layout.rect.width = 0
+ layout.width = 222 // trigger a rearrange with a valid size
+ layout.height = 222
+ }
+
+ Component {
+ id: test_currentIndex_Component
+ StackLayout {
+ currentIndex: 1
+ Text {
+ text: "0"
+ }
+ Text {
+ text: "1"
+ }
+ }
+ }
+
+ function test_currentIndex() {
+ var layout = test_currentIndex_Component.createObject(container)
+ var c0 = layout.children[0]
+ var c1 = layout.children[1]
+ compare(layout.currentIndex, 1)
+ tryCompare(layout, 'visible', true)
+ compare(c0.visible, false)
+ compare(c1.visible, true)
+ layout.currentIndex = 0
+ compare(c0.visible, true)
+ compare(c1.visible, false)
+ var c2 = layoutItem_Component.createObject(layout)
+ compare(c2.visible, false)
+
+ /*
+ * destroy the current item and check if visibility advances to next
+ */
+ c0.destroy()
+ tryCompare(c1, 'visible', true)
+ compare(c2.visible, false)
+ c1.destroy()
+ tryCompare(c2, 'visible', true)
+ c2.destroy()
+ tryCompare(layout, 'currentIndex', 0)
+
+ layout.destroy()
+
+ /*
+ * Test the default/implicit value of currentIndex, either -1 (if empty) or 0:
+ */
+ layout = emtpy_StackLayout_Component.createObject(container)
+ tryCompare(layout, 'visible', true)
+ compare(layout.currentIndex, -1)
+ compare(layout.num_onCurrentIndexChanged, 0)
+ // make it non-empty
+ c0 = layoutItem_Component.createObject(layout)
+ compare(layout.currentIndex, 0)
+ compare(layout.num_onCurrentIndexChanged, 1)
+ compare(c0.visible, true)
+ // make it empty again
+ c0.destroy()
+ wait(0)
+ compare(layout.currentIndex, -1)
+ //tryCompare(layout, 'currentIndex', -1)
+ compare(layout.num_onCurrentIndexChanged, 2)
+
+ /*
+ * Check that explicit value doesn't change,
+ * and that no items are visible if the index is invalid/out of range
+ */
+ layout.currentIndex = 2
+ compare(layout.currentIndex, 2)
+ compare(layout.num_onCurrentIndexChanged, 3)
+ c0 = layoutItem_Component.createObject(layout)
+ compare(layout.currentIndex, 2)
+ compare(c0.visible, false)
+
+ c1 = layoutItem_Component.createObject(layout)
+ compare(layout.currentIndex, 2)
+ compare(c0.visible, false)
+ compare(c1.visible, false)
+
+ c2 = layoutItem_Component.createObject(layout)
+ compare(layout.currentIndex, 2)
+ compare(c0.visible, false)
+ compare(c1.visible, false)
+ compare(c2.visible, true)
+
+ c2.destroy()
+ wait(0)
+ compare(layout.currentIndex, 2)
+ compare(c0.visible, false)
+ compare(c1.visible, false)
+ c1.destroy()
+ wait(0)
+ compare(layout.currentIndex, 2)
+ compare(c0.visible, false)
+ c0.destroy()
+ wait(0)
+ compare(layout.currentIndex, 2)
+ compare(layout.num_onCurrentIndexChanged, 3)
+ }
+
+ function test_count() {
+ var layout = emtpy_StackLayout_Component.createObject(container)
+ tryCompare(layout, 'visible', true)
+ compare(layout.count, 0)
+ compare(layout.currentIndex, -1)
+ compare(layout.num_onCountChanged, 0)
+ compare(layout.num_onCurrentIndexChanged, 0)
+ var c0 = layoutItem_Component.createObject(layout)
+ compare(layout.count, 1)
+ compare(layout.currentIndex, 0)
+ compare(layout.num_onCurrentIndexChanged, 1)
+ compare(layout.num_onCountChanged, 1)
+ }
+
+ // QTBUG-111902
+ Component {
+ id: stackComponent
+ Loader {
+ id: loader
+ asynchronous: true
+ sourceComponent: StackLayout {
+ id: stackLayout
+ Repeater {
+ model: 3
+ Item {
+ required property int index
+ }
+ }
+ }
+ }
+ }
+
+ function test_loadStackLayoutAsynchronously() {
+ var loaderObj = stackComponent.createObject(container)
+ // Check for loader status to be ready
+ tryCompare(loaderObj, 'status', 1)
+ // Get stack layout object
+ var stackLayoutObj = loaderObj.item
+ // Check repeater index of child object
+ compare(stackLayoutObj.children[0].index, 0)
+ compare(stackLayoutObj.children[1].index, 1)
+ compare(stackLayoutObj.children[2].index, 2)
+ // Check stack layout attached property index
+ compare(stackLayoutObj.children[0].StackLayout.index, 0)
+ compare(stackLayoutObj.children[1].StackLayout.index, 1)
+ compare(stackLayoutObj.children[2].StackLayout.index, 2)
+ }
}
}
diff --git a/tests/auto/quick/qquicklistview/data/appendDuringScrollDown.qml b/tests/auto/quick/qquicklistview/data/appendDuringScrollDown.qml
index af35c29143..6ba6480297 100644
--- a/tests/auto/quick/qquicklistview/data/appendDuringScrollDown.qml
+++ b/tests/auto/quick/qquicklistview/data/appendDuringScrollDown.qml
@@ -1,10 +1,11 @@
import QtQuick 2.6
ListView {
+ id: listView
width: 320; height: 240
focus: true
delegate: Text {
- height: 40; width: parent.width
+ height: 40; width: listView.width
text: model.text
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
diff --git a/tests/auto/quick/qquicklistview/data/displayMargin.qml b/tests/auto/quick/qquicklistview/data/displayMargin.qml
index 4fa034922d..20ba124a97 100644
--- a/tests/auto/quick/qquicklistview/data/displayMargin.qml
+++ b/tests/auto/quick/qquicklistview/data/displayMargin.qml
@@ -19,7 +19,7 @@ Item {
model: 100
delegate: Rectangle {
objectName: "delegate"
- width: parent.width
+ width: view.width
height: 25
color: index % 2 ? "steelblue" : "lightsteelblue"
Text {
diff --git a/tests/auto/quick/qquicklistview/data/listview-itematindex.qml b/tests/auto/quick/qquicklistview/data/listview-itematindex.qml
index fba8b11933..2194f1edff 100644
--- a/tests/auto/quick/qquicklistview/data/listview-itematindex.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-itematindex.qml
@@ -1,13 +1,14 @@
import QtQuick 2.0
ListView {
+ id: listView
width: 400
height: 400
focus: true
model: 3
delegate: Text {
- width: parent.width
+ width: listView.width
height: 10
property int idx: index
text: index
diff --git a/tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml b/tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml
index 875199901a..c169d92826 100644
--- a/tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml
+++ b/tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml
@@ -9,7 +9,7 @@ ListView {
anchors.fill: parent
model: 10
delegate: Rectangle {
- width: parent.width
+ width: listView.width
height: 40
border.color: "lightsteelblue"
Text {
diff --git a/tests/auto/quick/qquicklistview/data/sectionSnapping.qml b/tests/auto/quick/qquicklistview/data/sectionSnapping.qml
index 2583cc0377..48a893f88c 100644
--- a/tests/auto/quick/qquicklistview/data/sectionSnapping.qml
+++ b/tests/auto/quick/qquicklistview/data/sectionSnapping.qml
@@ -1,6 +1,7 @@
import QtQuick 2.0
ListView {
+ id: listView
width: 400
height: 400
preferredHighlightBegin: 100
@@ -17,7 +18,7 @@ ListView {
}
delegate: Rectangle {
- width: parent.width
+ width: listView.width
height: 50
color: index % 2 ? "lightsteelblue" : "steelblue"
Text {
diff --git a/tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml b/tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml
index f5b7b35d0c..1dfbfe0feb 100644
--- a/tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml
+++ b/tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml
@@ -1,13 +1,14 @@
import QtQuick 2.0
ListView {
+ id: listView
width: 400
height: 400
focus: true
model: 10
delegate: Rectangle {
- width: parent.width
+ width: listView.width
height: 50
color: index % 2 ? "blue" : "green"
}
diff --git a/tests/auto/quick/qquicklistview/data/strictlyenforcerange-resize.qml b/tests/auto/quick/qquicklistview/data/strictlyenforcerange-resize.qml
index 338af38475..16b9c72b16 100644
--- a/tests/auto/quick/qquicklistview/data/strictlyenforcerange-resize.qml
+++ b/tests/auto/quick/qquicklistview/data/strictlyenforcerange-resize.qml
@@ -1,6 +1,7 @@
import QtQuick 2.0
ListView {
+ id: listView
width: 400
height: 400
focus: true
@@ -15,7 +16,7 @@ ListView {
model: 10
delegate: Item {
- width: parent.width
+ width: listView.width
height: ListView.isCurrentItem ? 100 : 50
Text {
diff --git a/tests/auto/quick/qquicklistview/proxytestinnermodel.cpp b/tests/auto/quick/qquicklistview/proxytestinnermodel.cpp
index c0dbb641fb..d00b417429 100644
--- a/tests/auto/quick/qquicklistview/proxytestinnermodel.cpp
+++ b/tests/auto/quick/qquicklistview/proxytestinnermodel.cpp
@@ -28,7 +28,7 @@ int ProxyTestInnerModel::rowCount(const QModelIndex &parent) const
if (parent.isValid())
return 0;
- return m_values.count();
+ return m_values.size();
}
int ProxyTestInnerModel::columnCount(const QModelIndex &parent) const
@@ -49,7 +49,7 @@ QVariant ProxyTestInnerModel::data(const QModelIndex &index, int role) const
void ProxyTestInnerModel::append(const QString &s)
{
- beginInsertRows(QModelIndex(), m_values.count(), m_values.count());
+ beginInsertRows(QModelIndex(), m_values.size(), m_values.size());
m_values << s;
endInsertRows();
}
diff --git a/tests/auto/quick/qquicklistview/randomsortmodel.cpp b/tests/auto/quick/qquicklistview/randomsortmodel.cpp
index 764dc81fb7..3e0c45bb1a 100644
--- a/tests/auto/quick/qquicklistview/randomsortmodel.cpp
+++ b/tests/auto/quick/qquicklistview/randomsortmodel.cpp
@@ -23,7 +23,7 @@ QHash<int, QByteArray> RandomSortModel::roleNames() const
int RandomSortModel::rowCount(const QModelIndex& parent) const
{
if (!parent.isValid())
- return mData.count();
+ return mData.size();
return 0;
}
@@ -34,7 +34,7 @@ QVariant RandomSortModel::data(const QModelIndex& index, int role) const
return QVariant();
}
- if (index.row() >= mData.count()) {
+ if (index.row() >= mData.size()) {
return QVariant();
}
@@ -49,14 +49,14 @@ QVariant RandomSortModel::data(const QModelIndex& index, int role) const
void RandomSortModel::randomize()
{
- const int row = QRandomGenerator::global()->bounded(mData.count());
+ const int row = QRandomGenerator::global()->bounded(mData.size());
int random;
bool exists = false;
// Make sure we won't end up with two items with the same weight, as that
// would make unit-testing much harder
do {
exists = false;
- random = QRandomGenerator::global()->bounded(mData.count() * 10);
+ random = QRandomGenerator::global()->bounded(mData.size() * 10);
QList<QPair<QString, int> >::ConstIterator iter, end;
for (iter = mData.constBegin(), end = mData.constEnd(); iter != end; ++iter) {
if ((*iter).second == random) {
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 9cbae9ad6f..1bafe01768 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -445,7 +445,7 @@ void tst_QQuickListView::items(const QUrl &source)
QTRY_COMPARE(listview->count(), model.count());
QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count());
listview->forceLayout();
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().size(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
// current item should be first item
QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
@@ -563,7 +563,7 @@ void tst_QQuickListView::inserted(const QUrl &source)
model.insertItem(1, "Will", "9876");
QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().size(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
QTRY_VERIFY(name != nullptr);
@@ -581,7 +581,7 @@ void tst_QQuickListView::inserted(const QUrl &source)
model.insertItem(0, "Foo", "1111"); // zero index, and current item
QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().size(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
name = findItem<QQuickText>(contentItem, "textName", 0);
QTRY_VERIFY(name != nullptr);
@@ -697,7 +697,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (item && !QQuickItemPrivate::get(item)->culled) {
firstVisibleIndex = i;
@@ -711,7 +711,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
QQuickText *number;
const qreal visibleFromPos = listview->contentY() - listview->displayMarginBeginning() - listview->cacheBuffer();
const qreal visibleToPos = listview->contentY() + listview->height() + listview->displayMarginEnd() + listview->cacheBuffer();
- for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
+ for (int i = firstVisibleIndex; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
qreal pos = i*20.0 + itemsOffsetAfterMove;
@@ -885,7 +885,7 @@ void tst_QQuickListView::insertBeforeVisible()
QTRY_COMPARE(listview->contentY(), 0.0 + itemsOffsetAfterMove);
// Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
@@ -976,7 +976,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
QTRY_COMPARE(number->text(), model.number(1));
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -996,7 +996,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
QTRY_COMPARE(number->text(), model.number(0));
// Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -1009,7 +1009,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count());
// Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -1045,7 +1045,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
QVERIFY(QQuickTest::qWaitForPolish(listview));
// Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -1079,7 +1079,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
QTRY_COMPARE(listview->count() , model.count());
// Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i+1);
if (!item) qWarning() << "Item" << i+1 << "not found";
@@ -1114,7 +1114,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
listview->positionViewAtEnd();
for (int i = 0; i < 18; ++i)
model.removeItems(model.count() - 1, 1);
- QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() > 16);
+ QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").size() > 16);
}
template <class T>
@@ -1170,7 +1170,7 @@ void tst_QQuickListView::removed_more(const QUrl &source, QQuickItemView::Vertic
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (item && delegateVisible(item)) {
firstVisibleIndex = i;
@@ -1182,7 +1182,7 @@ void tst_QQuickListView::removed_more(const QUrl &source, QQuickItemView::Vertic
// Confirm items positioned correctly and indexes correct
QQuickText *name;
QQuickText *number;
- for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
+ for (int i = firstVisibleIndex; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
qreal pos = i*20.0 + itemsOffsetAfterMove;
@@ -1333,7 +1333,7 @@ void tst_QQuickListView::clear(const QUrl &source, QQuickItemView::VerticalLayou
model.clear();
- QTRY_COMPARE(findItems<QQuickListView>(contentItem, "wrapper").count(), 0);
+ QTRY_COMPARE(findItems<QQuickListView>(contentItem, "wrapper").size(), 0);
QTRY_COMPARE(listview->count(), 0);
QTRY_VERIFY(!listview->currentItem());
if (verticalLayoutDirection == QQuickItemView::TopToBottom)
@@ -1402,7 +1402,7 @@ void tst_QQuickListView::moved(const QUrl &source, QQuickItemView::VerticalLayou
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (item && delegateVisible(item)) {
firstVisibleIndex = i;
@@ -1412,7 +1412,7 @@ void tst_QQuickListView::moved(const QUrl &source, QQuickItemView::VerticalLayou
QVERIFY2(firstVisibleIndex >= 0, QByteArray::number(firstVisibleIndex));
// Confirm items positioned correctly and indexes correct
- for (int i = firstVisibleIndex; i < model.count() && i < items.count(); ++i) {
+ for (int i = firstVisibleIndex; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
qreal pos = i*20.0 + itemsOffsetAfterMove;
@@ -1612,7 +1612,7 @@ void tst_QQuickListView::multipleChanges(bool condensed)
QTRY_VERIFY(listview != nullptr);
QVERIFY(QQuickTest::qWaitForPolish(listview));
- for (int i=0; i<changes.count(); i++) {
+ for (int i=0; i<changes.size(); i++) {
switch (changes[i].type) {
case ListChange::Inserted:
{
@@ -1651,7 +1651,7 @@ void tst_QQuickListView::multipleChanges(bool condensed)
QQuickText *number;
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
@@ -2048,7 +2048,7 @@ void tst_QQuickListView::spacing()
QVERIFY(QQuickTest::qWaitForPolish(listview));
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -2060,7 +2060,7 @@ void tst_QQuickListView::spacing()
QTRY_COMPARE(listview->spacing(), qreal(10));
// Confirm items positioned correctly
- QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() == 11);
+ QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").size() == 11);
for (int i = 0; i < 11; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -2071,7 +2071,7 @@ void tst_QQuickListView::spacing()
listview->setSpacing(0);
// Confirm items positioned correctly
- QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() >= 16);
+ QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").size() >= 16);
for (int i = 0; i < 16; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -2105,7 +2105,7 @@ void tst_QQuickListView::sections(const QUrl &source)
QVERIFY(QQuickTest::qWaitForPolish(listview));
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY(item);
@@ -2159,12 +2159,12 @@ void tst_QQuickListView::sections(const QUrl &source)
listview->setContentY(140);
QTRY_COMPARE(listview->currentSection(), QString("1"));
- QTRY_COMPARE(currentSectionChangedSpy.count(), 1);
+ QTRY_COMPARE(currentSectionChangedSpy.size(), 1);
listview->setContentY(20);
QTRY_COMPARE(listview->currentSection(), QString("0"));
- QTRY_COMPARE(currentSectionChangedSpy.count(), 2);
+ QTRY_COMPARE(currentSectionChangedSpy.size(), 2);
item = findItem<QQuickItem>(contentItem, "wrapper", 1);
QTRY_VERIFY(item);
@@ -2214,7 +2214,7 @@ void tst_QQuickListView::sectionsDelegate()
QVERIFY(QQuickTest::qWaitForPolish(listview));
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QTRY_VERIFY(item);
@@ -2256,7 +2256,7 @@ void tst_QQuickListView::sectionsDelegate()
// QTBUG-17606
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "sect_1");
- QCOMPARE(items.count(), 1);
+ QCOMPARE(items.size(), 1);
// QTBUG-17759
model.modifyItem(0, "One", "aaa");
@@ -2272,10 +2272,10 @@ void tst_QQuickListView::sectionsDelegate()
model.modifyItem(10, "Two", "aaa");
model.modifyItem(11, "Two", "aaa");
QVERIFY(QQuickTest::qWaitForPolish(listview));
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_aaa").count(), 1);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_aaa").size(), 1);
window->rootObject()->setProperty("sectionProperty", "name");
// ensure view has settled.
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_Four").count(), 1);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_Four").size(), 1);
for (int i = 0; i < 4; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem,
"sect_" + model.name(i*3));
@@ -2631,8 +2631,8 @@ void tst_QQuickListView::sectionDelegateChange()
QQuickTest::qWaitForPolish(listview);
- QVERIFY(findItems<QQuickItem>(contentItem, "section1").count() > 0);
- QCOMPARE(findItems<QQuickItem>(contentItem, "section2").count(), 0);
+ QVERIFY(findItems<QQuickItem>(contentItem, "section1").size() > 0);
+ QCOMPARE(findItems<QQuickItem>(contentItem, "section2").size(), 0);
for (int i = 0; i < 3; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "item", i);
@@ -2643,8 +2643,8 @@ void tst_QQuickListView::sectionDelegateChange()
QMetaObject::invokeMethod(window->rootObject(), "switchDelegates");
QQuickTest::qWaitForPolish(listview);
- QCOMPARE(findItems<QQuickItem>(contentItem, "section1").count(), 0);
- QVERIFY(findItems<QQuickItem>(contentItem, "section2").count() > 0);
+ QCOMPARE(findItems<QQuickItem>(contentItem, "section1").size(), 0);
+ QVERIFY(findItems<QQuickItem>(contentItem, "section2").size() > 0);
for (int i = 0; i < 3; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "item", i);
@@ -2691,7 +2691,7 @@ void tst_QQuickListView::sectionsItemInsertion()
QVERIFY(QQuickTest::qWaitForPolish(listview));
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
QVERIFY(itemCount > 10);
// Verify that the new items are postioned correctly, and have the correct attached section properties
@@ -2791,7 +2791,7 @@ void tst_QQuickListView::currentIndex_delayedItemCreation()
QSignalSpy spy(listview, SIGNAL(currentItemChanged()));
//QCOMPARE(listview->currentIndex(), 0);
listview->forceLayout();
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
releaseView(window);
}
@@ -3193,7 +3193,7 @@ void tst_QQuickListView::cacheBuffer()
QTRY_VERIFY(listview->highlight() != nullptr);
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -3224,7 +3224,7 @@ void tst_QQuickListView::cacheBuffer()
}
int newItemCount = 0;
- newItemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ newItemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
// Confirm items positioned correctly
for (int i = 0; i < model.count() && i < newItemCount; ++i) {
@@ -3360,7 +3360,7 @@ void tst_QQuickListView::positionViewAtIndex()
QTRY_COMPARE(listview->contentY(), contentY);
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = index; i < model.count() && i < itemCount-index-1; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -3493,13 +3493,13 @@ void tst_QQuickListView::propertyChanges()
QTRY_COMPARE(listView->cacheBuffer(), 3);
QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapOneItem);
- QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
- QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
- QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
- QTRY_COMPARE(highlightRangeModeSpy.count(),1);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(snapModeSpy.count(),1);
+ QTRY_COMPARE(highlightFollowsCurrentItemSpy.size(),1);
+ QTRY_COMPARE(preferredHighlightBeginSpy.size(),1);
+ QTRY_COMPARE(preferredHighlightEndSpy.size(),1);
+ QTRY_COMPARE(highlightRangeModeSpy.size(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.size(),1);
+ QTRY_COMPARE(cacheBufferSpy.size(),1);
+ QTRY_COMPARE(snapModeSpy.size(),1);
listView->setHighlightFollowsCurrentItem(false);
listView->setPreferredHighlightBegin(1.0);
@@ -3509,13 +3509,13 @@ void tst_QQuickListView::propertyChanges()
listView->setCacheBuffer(3);
listView->setSnapMode(QQuickListView::SnapOneItem);
- QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
- QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
- QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
- QTRY_COMPARE(highlightRangeModeSpy.count(),1);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(snapModeSpy.count(),1);
+ QTRY_COMPARE(highlightFollowsCurrentItemSpy.size(),1);
+ QTRY_COMPARE(preferredHighlightBeginSpy.size(),1);
+ QTRY_COMPARE(preferredHighlightEndSpy.size(),1);
+ QTRY_COMPARE(highlightRangeModeSpy.size(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.size(),1);
+ QTRY_COMPARE(cacheBufferSpy.size(),1);
+ QTRY_COMPARE(snapModeSpy.size(),1);
}
void tst_QQuickListView::componentChanges()
@@ -3547,20 +3547,20 @@ void tst_QQuickListView::componentChanges()
QTRY_COMPARE(listView->footer(), &component);
QTRY_COMPARE(listView->delegate(), &delegateComponent);
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
+ QTRY_COMPARE(highlightSpy.size(),1);
+ QTRY_COMPARE(delegateSpy.size(),1);
+ QTRY_COMPARE(headerSpy.size(),1);
+ QTRY_COMPARE(footerSpy.size(),1);
listView->setHighlight(&component);
listView->setHeader(&component);
listView->setFooter(&component);
listView->setDelegate(&delegateComponent);
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
+ QTRY_COMPARE(highlightSpy.size(),1);
+ QTRY_COMPARE(delegateSpy.size(),1);
+ QTRY_COMPARE(headerSpy.size(),1);
+ QTRY_COMPARE(footerSpy.size(),1);
}
void tst_QQuickListView::modelChanges()
@@ -3578,13 +3578,13 @@ void tst_QQuickListView::modelChanges()
listView->setModel(modelVariant);
QTRY_COMPARE(listView->model(), modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
+ QTRY_COMPARE(modelSpy.size(),1);
listView->setModel(modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
+ QTRY_COMPARE(modelSpy.size(),1);
listView->setModel(QVariant());
- QTRY_COMPARE(modelSpy.count(),2);
+ QTRY_COMPARE(modelSpy.size(),2);
}
void tst_QQuickListView::QTBUG_9791()
@@ -3606,7 +3606,7 @@ void tst_QQuickListView::QTBUG_9791()
qApp->processEvents();
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).size();
QCOMPARE(itemCount, 3);
for (int i = 0; i < itemCount; ++i) {
@@ -3635,12 +3635,12 @@ void tst_QQuickListView::QTBUG_33568()
listview->incrementCurrentIndex();
QTRY_COMPARE(listview->contentY(), -100.0);
- QVERIFY(spy.count() > 1);
+ QVERIFY(spy.size() > 1);
spy.clear();
listview->incrementCurrentIndex();
QTRY_COMPARE(listview->contentY(), -50.0);
- QVERIFY(spy.count() > 1);
+ QVERIFY(spy.size() > 1);
}
void tst_QQuickListView::manualHighlight()
@@ -3702,7 +3702,7 @@ void tst_QQuickListView::QTBUG_11105()
QVERIFY(QQuickTest::qWaitForPolish(listview));
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -3719,7 +3719,7 @@ void tst_QQuickListView::QTBUG_11105()
ctxt->setContextProperty("testModel", &model2);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
QCOMPARE(itemCount, 5);
}
@@ -3827,7 +3827,7 @@ void tst_QQuickListView::header()
QSignalSpy headerItemSpy(listview, SIGNAL(headerItemChanged()));
QMetaObject::invokeMethod(window->rootObject(), "changeHeader");
- QCOMPARE(headerItemSpy.count(), 1);
+ QCOMPARE(headerItemSpy.size(), 1);
header = findItem<QQuickText>(contentItem, "header");
QVERIFY(!header);
@@ -4086,7 +4086,7 @@ void tst_QQuickListView::footer()
QSignalSpy footerItemSpy(listview, SIGNAL(footerItemChanged()));
QMetaObject::invokeMethod(window->rootObject(), "changeFooter");
- QCOMPARE(footerItemSpy.count(), 1);
+ QCOMPARE(footerItemSpy.size(), 1);
footer = findItem<QQuickText>(contentItem, "footer");
QVERIFY(!footer);
@@ -4285,26 +4285,24 @@ void tst_QQuickListView::extents_data()
QTest::newRow("Vertical, TopToBottom")
<< QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom
- << QPointF(0, -20) << QPointF(0, 0)
- << QPointF(0, 20) << QPointF(240, 20)
+ << QPointF(0, -20) << QPointF(0, 0) << QPointF(0, 20) << QPointF(0, 20)
<< QPointF(0, -20) << QPointF(0, -20) << QPointF(0, -20);
QTest::newRow("Vertical, BottomToTop")
<< QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop
- << QPointF(0, 0) << QPointF(0, -30)
- << QPointF(0, 320 - 20) << QPointF(240, 320 - 20) // content flow is reversed
+ << QPointF(0, 0) << QPointF(0, -30) << QPointF(0, 320 - 20)
+ << QPointF(0, 320 - 20) // content flow is reversed
<< QPointF(0, -30) << QPointF(0, (-30.0 * 3) - 30) << QPointF(0, (-30.0 * 30) - 30);
QTest::newRow("Horizontal, LeftToRight")
<< QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom
- << QPointF(-20, 0) << QPointF(0, 0)
- << QPointF(20, 0) << QPointF(20, 320)
+ << QPointF(-20, 0) << QPointF(0, 0) << QPointF(20, 0) << QPointF(20, 0)
<< QPointF(-20, 0) << QPointF(-20, 0) << QPointF(-20, 0);
QTest::newRow("Horizontal, RightToLeft")
<< QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom
- << QPointF(0, 0) << QPointF(-30, 0)
- << QPointF(240 - 20, 0) << QPointF(240 - 20, 320) // content flow is reversed
+ << QPointF(0, 0) << QPointF(-30, 0) << QPointF(240 - 20, 0)
+ << QPointF(240 - 20, 0) // content flow is reversed
<< QPointF(-30, 0) << QPointF((-240.0 * 3) - 30, 0) << QPointF((-240.0 * 30) - 30, 0);
}
@@ -4373,7 +4371,7 @@ void tst_QQuickListView::resizeView()
QVERIFY(QQuickTest::qWaitForPolish(listview));
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -4393,16 +4391,16 @@ void tst_QQuickListView::resizeView()
// Ensure we handle -ve sizes
listview->setHeight(-100);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 1);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 1);
listview->setCacheBuffer(200);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 11);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 11);
// ensure items in cache become visible
listview->setHeight(200);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 21);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 21);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -4413,9 +4411,9 @@ void tst_QQuickListView::resizeView()
// ensure items outside view become invisible
listview->setHeight(100);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 16);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).size(), 16);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -4484,7 +4482,7 @@ void tst_QQuickListView::sizeLessThan1()
QVERIFY(QQuickTest::qWaitForPolish(listview));
// Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -4629,7 +4627,7 @@ void tst_QQuickListView::resizeFirstDelegate()
QCOMPARE(listview->contentY(), 0.0);
QSignalSpy spy(listview, SIGNAL(contentYChanged()));
QTest::qWait(100);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
for (int i = 1; i < model.count(); ++i) {
item = findItem<QQuickItem>(contentItem, "wrapper", i);
@@ -4697,13 +4695,13 @@ void tst_QQuickListView::repositionResizedDelegate()
listview->setContentX(contentPos_itemFirstHalfVisible.x());
listview->setContentY(contentPos_itemFirstHalfVisible.y());
QVERIFY(QQuickTest::qWaitForPolish(listview));
- prevSpyCount = spy.count();
+ prevSpyCount = spy.size();
QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "incrementRepeater"));
QTRY_COMPARE(positioner->boundingRect().size(), resizedPositionerRect.size());
QTRY_COMPARE(positioner->position(), resizedPositionerRect.topLeft());
QCOMPARE(listview->contentX(), contentPos_itemFirstHalfVisible.x());
QCOMPARE(listview->contentY(), contentPos_itemFirstHalfVisible.y());
- QCOMPARE(spy.count(), prevSpyCount);
+ QCOMPARE(spy.size(), prevSpyCount);
QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "decrementRepeater"));
QTRY_COMPARE(positioner->boundingRect().size(), origPositionerRect.size());
@@ -4714,7 +4712,7 @@ void tst_QQuickListView::repositionResizedDelegate()
listview->setContentX(contentPos_itemSecondHalfVisible.x());
listview->setContentY(contentPos_itemSecondHalfVisible.y());
QVERIFY(QQuickTest::qWaitForPolish(listview));
- prevSpyCount = spy.count();
+ prevSpyCount = spy.size();
QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "incrementRepeater"));
positioner = findItem<QQuickItem>(window->rootObject(), "positioner");
@@ -4723,7 +4721,7 @@ void tst_QQuickListView::repositionResizedDelegate()
QCOMPARE(listview->contentX(), contentPos_itemSecondHalfVisible.x());
QCOMPARE(listview->contentY(), contentPos_itemSecondHalfVisible.y());
qApp->processEvents();
- QCOMPARE(spy.count(), prevSpyCount);
+ QCOMPARE(spy.size(), prevSpyCount);
releaseView(window);
}
@@ -4913,8 +4911,8 @@ void tst_QQuickListView::onAdd()
QTRY_COMPARE(listview->property("count").toInt(), model.count());
QVariantList result = listview->property("addedDelegates").toList();
- QCOMPARE(result.count(), items.count());
- for (int i=0; i<items.count(); i++)
+ QCOMPARE(result.size(), items.size());
+ for (int i=0; i<items.size(); i++)
QCOMPARE(result[i].toString(), items[i].first);
}
@@ -6021,7 +6019,7 @@ void tst_QQuickListView::snapOneItemResize_QTBUG_43555()
QVERIFY(QQuickTest::qWaitForPolish(listview));
QTRY_COMPARE(listview->currentIndex(), 5);
- QCOMPARE(currentIndexSpy.count(), 0);
+ QCOMPARE(currentIndexSpy.size(), 0);
}
void tst_QQuickListView::qAbstractItemModel_package_items()
@@ -6345,7 +6343,7 @@ void tst_QQuickListView::snapOneItem()
if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
QCOMPARE(listview->currentIndex(), 1);
- QCOMPARE(currentIndexSpy.count(), 1);
+ QCOMPARE(currentIndexSpy.size(), 1);
}
// flick to end
@@ -6363,7 +6361,7 @@ void tst_QQuickListView::snapOneItem()
if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
QCOMPARE(listview->currentIndex(), 3);
- QCOMPARE(currentIndexSpy.count(), 3);
+ QCOMPARE(currentIndexSpy.size(), 3);
}
// flick to start
@@ -6381,7 +6379,7 @@ void tst_QQuickListView::snapOneItem()
if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
QCOMPARE(listview->currentIndex(), 0);
- QCOMPARE(currentIndexSpy.count(), 6);
+ QCOMPARE(currentIndexSpy.size(), 6);
}
releaseView(window);
@@ -6407,7 +6405,7 @@ void tst_QQuickListView::snapOneItemCurrentIndexRemoveAnimation()
QVERIFY(QQuickTest::qWaitForPolish(listview));
QCOMPARE(listview->currentIndex(), 0);
- QCOMPARE(currentIndexSpy.count(), 0);
+ QCOMPARE(currentIndexSpy.size(), 0);
}
void tst_QQuickListView::snapOneItemWrongDirection()
@@ -6711,7 +6709,7 @@ void tst_QQuickListView::populateTransitions()
QCOMPARE(listview->property("countAddTransitions").toInt(), 0);
}
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
@@ -6734,7 +6732,7 @@ void tst_QQuickListView::populateTransitions()
window->rootContext()->setContextProperty("testModel", QVariant());
listview->forceLayout();
QTRY_COMPARE(listview->count(), 0);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").size(), 0);
listview->setProperty("countPopulateTransitions", 0);
listview->setProperty("countAddTransitions", 0);
@@ -6746,7 +6744,7 @@ void tst_QQuickListView::populateTransitions()
QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 16 : 0);
QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
@@ -6764,7 +6762,7 @@ void tst_QQuickListView::populateTransitions()
QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 16 : 0);
QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i=0; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
@@ -6903,7 +6901,7 @@ void tst_QQuickListView::addTransitions()
targetIndexes << i;
}
}
- QVERIFY(expectedTargetData.count() > 0);
+ QVERIFY(expectedTargetData.size() > 0);
}
// start animation
@@ -6916,7 +6914,7 @@ void tst_QQuickListView::addTransitions()
QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
if (shouldAnimateTargets) {
- QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.size());
QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
@@ -6943,8 +6941,8 @@ void tst_QQuickListView::addTransitions()
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
- int itemCount = items.count();
- for (int i=0; i<items.count(); i++) {
+ int itemCount = items.size();
+ for (int i=0; i<items.size(); i++) {
if (items[i]->y() >= contentY) {
QQmlExpression e(qmlContext(items[i]), items[i], "index");
firstVisibleIndex = e.evaluate().toInt();
@@ -7103,7 +7101,7 @@ void tst_QQuickListView::moveTransitions()
// start animation
model.moveItems(moveFrom, moveTo, moveCount);
- QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.size());
QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
@@ -7127,7 +7125,7 @@ void tst_QQuickListView::moveTransitions()
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
if (items[i]->y() >= contentY) {
QQmlExpression e(qmlContext(items[i]), items[i], "index");
firstVisibleIndex = e.evaluate().toInt();
@@ -7137,7 +7135,7 @@ void tst_QQuickListView::moveTransitions()
QVERIFY2(firstVisibleIndex >= 0, QByteArray::number(firstVisibleIndex));
// verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").size();
for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
@@ -7297,13 +7295,13 @@ void tst_QQuickListView::removeTransitions()
targetIndexes << i;
}
}
- QVERIFY(expectedTargetData.count() > 0);
+ QVERIFY(expectedTargetData.size() > 0);
}
// calculate targetItems and expectedTargets before model changes
QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
QVariantMap expectedTargets;
- for (int i=0; i<targetIndexes.count(); i++)
+ for (int i=0; i<targetIndexes.size(); i++)
expectedTargets[model.name(targetIndexes[i])] = targetIndexes[i];
// start animation
@@ -7311,7 +7309,7 @@ void tst_QQuickListView::removeTransitions()
QTRY_COMPARE(model.count(), listview->count());
if (shouldAnimateTargets) {
- QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.size());
QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
@@ -7337,9 +7335,9 @@ void tst_QQuickListView::removeTransitions()
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
- int itemCount = items.count();
+ int itemCount = items.size();
- for (int i=0; i<items.count(); i++) {
+ for (int i=0; i<items.size(); i++) {
QQmlExpression e(qmlContext(items[i]), items[i], "index");
int index = e.evaluate().toInt();
if (firstVisibleIndex < 0 && items[i]->y() >= contentY)
@@ -7528,15 +7526,15 @@ void tst_QQuickListView::displacedTransitions()
QTRY_VERIFY(listview->property("displaceTransitionsDone").toBool());
// check the correct number of target items and indexes were received
- QCOMPARE(resultTargetIndexes.count(), expectedDisplacedIndexes.count());
- for (int i=0; i<resultTargetIndexes.count(); i++)
- QCOMPARE(resultTargetIndexes[i].value<QList<int> >().count(), change.count);
- QCOMPARE(resultTargetItems.count(), expectedDisplacedIndexes.count());
- for (int i=0; i<resultTargetItems.count(); i++)
- QCOMPARE(resultTargetItems[i].toList().count(), change.count);
+ QCOMPARE(resultTargetIndexes.size(), expectedDisplacedIndexes.count());
+ for (int i=0; i<resultTargetIndexes.size(); i++)
+ QCOMPARE(resultTargetIndexes[i].value<QList<int> >().size(), change.count);
+ QCOMPARE(resultTargetItems.size(), expectedDisplacedIndexes.count());
+ for (int i=0; i<resultTargetItems.size(); i++)
+ QCOMPARE(resultTargetItems[i].toList().size(), change.count);
} else {
- QCOMPARE(resultTargetIndexes.count(), 0);
- QCOMPARE(resultTargetItems.count(), 0);
+ QCOMPARE(resultTargetIndexes.size(), 0);
+ QCOMPARE(resultTargetItems.size(), 0);
}
if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled)
@@ -7563,7 +7561,7 @@ void tst_QQuickListView::displacedTransitions()
// verify all items moved to the correct final positions
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i < model.count() && i < items.count(); ++i) {
+ for (int i=0; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QCOMPARE(item->x(), 0.0);
@@ -7717,7 +7715,7 @@ void tst_QQuickListView::multipleTransitions()
int timeBetweenActions = window->rootObject()->property("timeBetweenActions").toInt();
- for (int i=0; i<changes.count(); i++) {
+ for (int i=0; i<changes.size(); i++) {
switch (changes[i].type) {
case ListChange::Inserted:
{
@@ -7726,7 +7724,7 @@ void tst_QQuickListView::multipleTransitions()
targetItems << qMakePair(QString("new item %1").arg(j), QString::number(j));
model.insertItems(changes[i].index, targetItems);
QTRY_COMPARE(model.count(), listview->count());
- if (i == changes.count() - 1) {
+ if (i == changes.size() - 1) {
QTRY_VERIFY(!listview->property("runningAddTargets").toBool());
QTRY_VERIFY(!listview->property("runningAddDisplaced").toBool());
} else {
@@ -7737,7 +7735,7 @@ void tst_QQuickListView::multipleTransitions()
case ListChange::Removed:
model.removeItems(changes[i].index, changes[i].count);
QTRY_COMPARE(model.count(), listview->count());
- if (i == changes.count() - 1) {
+ if (i == changes.size() - 1) {
QTRY_VERIFY(!listview->property("runningRemoveTargets").toBool());
QTRY_VERIFY(!listview->property("runningRemoveDisplaced").toBool());
} else {
@@ -7747,7 +7745,7 @@ void tst_QQuickListView::multipleTransitions()
case ListChange::Moved:
model.moveItems(changes[i].index, changes[i].to, changes[i].count);
QVERIFY(QQuickTest::qWaitForPolish(listview));
- if (i == changes.count() - 1) {
+ if (i == changes.size() - 1) {
QTRY_VERIFY(!listview->property("runningMoveTargets").toBool());
QTRY_VERIFY(!listview->property("runningMoveDisplaced").toBool());
} else {
@@ -7771,7 +7769,7 @@ void tst_QQuickListView::multipleTransitions()
// verify all items moved to the correct final positions
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i < model.count() && i < items.count(); ++i) {
+ for (int i=0; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->x(), 0.0);
@@ -7880,7 +7878,7 @@ void tst_QQuickListView::multipleDisplaced()
// verify all items moved to the correct final positions
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i < model.count() && i < items.count(); ++i) {
+ for (int i=0; i < model.count() && i < items.size(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, qPrintable(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->x(), 0.0);
@@ -7897,7 +7895,7 @@ QList<int> tst_QQuickListView::toIntList(const QVariantList &list)
{
QList<int> ret;
bool ok = true;
- for (int i=0; i<list.count(); i++) {
+ for (int i=0; i<list.size(); i++) {
ret << list[i].toInt(&ok);
if (!ok)
qWarning() << "tst_QQuickListView::toIntList(): not a number:" << list[i];
@@ -7909,7 +7907,7 @@ QList<int> tst_QQuickListView::toIntList(const QVariantList &list)
void tst_QQuickListView::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
{
const QSet<int> expectedIndexSet(expectedIndexes.cbegin(), expectedIndexes.cend());
- for (int i=0; i<indexLists.count(); i++) {
+ for (int i=0; i<indexLists.size(); i++) {
const auto &currentList = indexLists[i].value<QList<int> >();
const QSet<int> current(currentList.cbegin(), currentList.cend());
if (current != expectedIndexSet)
@@ -7929,20 +7927,20 @@ void tst_QQuickListView::matchItemsAndIndexes(const QVariantMap &items, const Qa
qDebug() << itemIndex;
QCOMPARE(model.name(itemIndex), name);
}
- QCOMPARE(items.count(), expectedIndexes.count());
+ QCOMPARE(items.size(), expectedIndexes.size());
}
void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
{
- for (int i=0; i<itemLists.count(); i++) {
+ for (int i=0; i<itemLists.size(); i++) {
QCOMPARE(itemLists[i].typeId(), QMetaType::QVariantList);
QVariantList current = itemLists[i].toList();
- for (int j=0; j<current.count(); j++) {
+ for (int j=0; j<current.size(); j++) {
QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
QVERIFY2(o, qPrintable(QString("Invalid actual item at %1").arg(j)));
QVERIFY2(expectedItems.contains(o), qPrintable(QString("Cannot match item %1").arg(j)));
}
- QCOMPARE(current.count(), expectedItems.count());
+ QCOMPARE(current.size(), expectedItems.size());
}
}
@@ -7972,7 +7970,7 @@ void tst_QQuickListView::flickBeyondBounds()
// We're really testing that we don't get stuck in a loop,
// but also confirm items positioned correctly.
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 2);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").size(), 2);
for (int i = 0; i < 2; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
@@ -8079,7 +8077,7 @@ void tst_QQuickListView::destroyItemOnCreation()
model.addItem("new item", "");
QTRY_COMPARE(window->rootObject()->property("createdIndex").toInt(), 0);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").size(), 0);
QCOMPARE(model.count(), 0);
}
@@ -9070,11 +9068,11 @@ void tst_QQuickListView::jsArrayChange()
}
view->setModel(QVariant::fromValue(array1));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// no change
view->setModel(QVariant::fromValue(array2));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
static bool compareObjectModel(QQuickListView *listview, QQmlObjectModel *model)
@@ -9259,7 +9257,7 @@ void tst_QQuickListView::keyNavigationEnabled()
// of disabling both mouse and keyboard interaction.
QSignalSpy enabledSpy(listView, SIGNAL(keyNavigationEnabledChanged()));
listView->setInteractive(false);
- QCOMPARE(enabledSpy.count(), 1);
+ QCOMPARE(enabledSpy.size(), 1);
QCOMPARE(listView->isKeyNavigationEnabled(), false);
flick(window.data(), QPoint(200, 200), QPoint(200, 50), 100);
@@ -9272,17 +9270,17 @@ void tst_QQuickListView::keyNavigationEnabled()
// Check that isKeyNavigationEnabled implicitly follows the value of interactive.
listView->setInteractive(true);
- QCOMPARE(enabledSpy.count(), 2);
+ QCOMPARE(enabledSpy.size(), 2);
QCOMPARE(listView->isKeyNavigationEnabled(), true);
// Change it back again for the next check.
listView->setInteractive(false);
- QCOMPARE(enabledSpy.count(), 3);
+ QCOMPARE(enabledSpy.size(), 3);
QCOMPARE(listView->isKeyNavigationEnabled(), false);
// Setting keyNavigationEnabled to true shouldn't enable mouse interaction.
listView->setKeyNavigationEnabled(true);
- QCOMPARE(enabledSpy.count(), 4);
+ QCOMPARE(enabledSpy.size(), 4);
flick(window.data(), QPoint(200, 200), QPoint(200, 50), 100);
QVERIFY(!listView->isMoving());
QCOMPARE(listView->contentY(), 0.0);
@@ -9296,7 +9294,7 @@ void tst_QQuickListView::keyNavigationEnabled()
// Changing interactive now shouldn't result in keyNavigationEnabled changing,
// since we broke the "binding".
listView->setInteractive(true);
- QCOMPARE(enabledSpy.count(), 4);
+ QCOMPARE(enabledSpy.size(), 4);
// Keyboard interaction shouldn't work now.
listView->setKeyNavigationEnabled(false);
@@ -9473,7 +9471,7 @@ void tst_QQuickListView::QTBUG_66163_setModelViewPortSizeChange()
delegate: Rectangle {
color: index % 2 ? "green" : "orange"
- width: parent.width
+ width: view.width
height: 50
}
@@ -9504,7 +9502,7 @@ void tst_QQuickListView::QTBUG_66163_setModelViewPortSizeChange()
QTest::qWait(1100); // animation takes 1000ms, + 10% extra delay
/* the viewport should not have changed, thus there should not have
been any contentYChanged signal*/
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
void tst_QQuickListView::itemFiltered()
@@ -9575,7 +9573,7 @@ void tst_QQuickListView::QTBUG_34576_velocityZero()
window->rootObject()->setProperty("horizontalVelocityZeroCount", QVariant(0));
listview->setCurrentIndex(2);
QTRY_COMPARE(window->rootObject()->property("current").toInt(), 2);
- QCOMPARE(horizontalVelocitySpy.count(), 0);
+ QCOMPARE(horizontalVelocitySpy.size(), 0);
QCOMPARE(window->rootObject()->property("horizontalVelocityZeroCount").toInt(), 0);
QSignalSpy currentIndexChangedSpy(listview, SIGNAL(currentIndexChanged()));
@@ -9585,11 +9583,11 @@ void tst_QQuickListView::QTBUG_34576_velocityZero()
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(295,215));
// verify that currentIndexChanged is triggered
- QTRY_VERIFY(currentIndexChangedSpy.count() > 0);
+ QTRY_VERIFY(currentIndexChangedSpy.size() > 0);
// since we have set currentIndex to an item out of view, the listview will scroll
QTRY_COMPARE(window->rootObject()->property("current").toInt(), 3);
- QTRY_VERIFY(horizontalVelocitySpy.count() > 0);
+ QTRY_VERIFY(horizontalVelocitySpy.size() > 0);
// velocity should be always > 0.0
QTRY_COMPARE(window->rootObject()->property("horizontalVelocityZeroCount").toInt(), 0);
@@ -9618,7 +9616,7 @@ void tst_QQuickListView::QTBUG_61537_modelChangesAsync()
// Check that the number of delegates we expect to be visible in
// the listview matches the number of items we find if we count.
int reportedCount = listView->count();
- int actualCount = findItems<QQuickItem>(listView, "delegate").count();
+ int actualCount = findItems<QQuickItem>(listView, "delegate").size();
QCOMPARE(reportedCount, actualCount);
}
@@ -9749,7 +9747,7 @@ public:
m_animals.push_back(Animal {5, QLatin1String("Cherry")});
}
- int rowCount(const QModelIndex & = QModelIndex()) const override {return m_animals.count();}
+ int rowCount(const QModelIndex & = QModelIndex()) const override {return m_animals.size();}
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override {
if (!checkIndex(index))
@@ -9865,14 +9863,14 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused()
QVERIFY(listView->reuseItems());
auto items = findItems<QQuickItem>(listView, "delegate");
- const int initialItemCount = items.count();
+ const int initialItemCount = items.size();
QVERIFY(initialItemCount > 0);
// Sanity check that the size of the initial list of items match the count we tracked from QML
QCOMPARE(listView->property("delegatesCreatedCount").toInt(), initialItemCount);
// Go through all the initial items and check that they have not been reused yet
- for (const auto item : qAsConst(items))
+ for (const auto item : std::as_const(items))
QCOMPARE(item->property("reusedCount").toInt(), 0);
// Flick one page down and count how many items we have created thus
@@ -9896,7 +9894,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused()
// QML model classes, we need to catch it through a binding instead (which is
// OK, since then we can also check that bindings are updated when reused).
items = findItems<QQuickItem>(listView, "delegate");
- for (const auto item : qAsConst(items)) {
+ for (const auto item : std::as_const(items)) {
const QString display = item->property("displayBinding").toString();
const int modelIndex = item->property("modelIndex").toInt();
QVERIFY(modelIndex >= initialItemCount);
@@ -9918,7 +9916,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused()
// (except for ListView.currentItem, which was never released).
const auto listViewCurrentItem = listView->currentItem();
items = findItems<QQuickItem>(listView, "delegate");
- for (const auto item : qAsConst(items)) {
+ for (const auto item : std::as_const(items)) {
const int reusedCount = item->property("reusedCount").toInt();
if (item == listViewCurrentItem)
QCOMPARE(reusedCount, 0);
@@ -9929,7 +9927,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused()
// Go through all items again and check that all model data inside the delegate
// have correct values now that they have been reused.
items = findItems<QQuickItem>(listView, "delegate");
- for (const auto item : qAsConst(items)) {
+ for (const auto item : std::as_const(items)) {
const QString display = item->property("displayBinding").toString();
const int modelIndex = item->property("modelIndex").toInt();
QVERIFY(modelIndex < initialItemCount);
@@ -10090,9 +10088,9 @@ void tst_QQuickListView::requiredObjectListModel()
const auto *root = qobject_cast<QQuickListView *>(view.rootObject());
QVERIFY(root);
- QCOMPARE(root->count(), dataList.count());
+ QCOMPARE(root->count(), dataList.size());
- for (int i = 0, end = dataList.count(); i != end; ++i) {
+ for (int i = 0, end = dataList.size(); i != end; ++i) {
const auto *rect = qobject_cast<QQuickRectangle *>(root->itemAtIndex(i));
QVERIFY(rect);
const auto *data = qobject_cast<DataObject *>(dataList.at(i));
diff --git a/tests/auto/quick/qquicklistview2/data/maxXExtent.qml b/tests/auto/quick/qquicklistview2/data/maxXExtent.qml
new file mode 100644
index 0000000000..b9e88cfc9e
--- /dev/null
+++ b/tests/auto/quick/qquicklistview2/data/maxXExtent.qml
@@ -0,0 +1,29 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+
+Item {
+ property alias view: view
+
+ ListView {
+ id: view
+ model: 10
+ width: 200
+ height: 200
+
+ Rectangle {
+ anchors.fill: parent
+ color: "transparent"
+ border.color: "darkorange"
+ }
+
+ delegate: Rectangle {
+ width: 100
+ height: 100
+ Text {
+ text: modelData
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview2/data/maxYExtent.qml b/tests/auto/quick/qquicklistview2/data/maxYExtent.qml
new file mode 100644
index 0000000000..3be8948691
--- /dev/null
+++ b/tests/auto/quick/qquicklistview2/data/maxYExtent.qml
@@ -0,0 +1,30 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+
+Item {
+ property alias view: view
+
+ ListView {
+ id: view
+ model: 10
+ width: 200
+ height: 200
+ orientation: ListView.Horizontal
+
+ Rectangle {
+ anchors.fill: parent
+ color: "transparent"
+ border.color: "darkorange"
+ }
+
+ delegate: Rectangle {
+ width: 100
+ height: 100
+ Text {
+ text: modelData
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview2/data/qtbug104679_footer.qml b/tests/auto/quick/qquicklistview2/data/qtbug104679_footer.qml
new file mode 100644
index 0000000000..919cf4d2ec
--- /dev/null
+++ b/tests/auto/quick/qquicklistview2/data/qtbug104679_footer.qml
@@ -0,0 +1,21 @@
+import QtQuick
+
+Rectangle {
+ width: 640
+ height: 480
+
+ ListView {
+ anchors.fill: parent
+ spacing: 5
+
+ footerPositioning: ListView.PullBackFooter
+ footer: Rectangle { width: ListView.view.width; color: "blue"; implicitHeight: 46 }
+
+ model: 3 // crashed if less items than a full list page
+ delegate: Rectangle {
+ width: ListView.view.width
+ height: 50
+ color: index % 2 ? "black" : "gray"
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview2/data/qtbug104679_header.qml b/tests/auto/quick/qquicklistview2/data/qtbug104679_header.qml
new file mode 100644
index 0000000000..40ddf27988
--- /dev/null
+++ b/tests/auto/quick/qquicklistview2/data/qtbug104679_header.qml
@@ -0,0 +1,21 @@
+import QtQuick
+
+Rectangle {
+ width: 640
+ height: 480
+
+ ListView {
+ anchors.fill: parent
+ spacing: 5
+
+ headerPositioning: ListView.PullBackHeader
+ header: Rectangle { width: ListView.view.width; color: "red"; implicitHeight: 46 }
+
+ model: 3 // crashed if less items than a full list page
+ delegate: Rectangle {
+ width: ListView.view.width
+ height: 50
+ color: index % 2 ? "black" : "gray"
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview2/data/qtbug86744.qml b/tests/auto/quick/qquicklistview2/data/qtbug86744.qml
new file mode 100644
index 0000000000..c69a4f7ec6
--- /dev/null
+++ b/tests/auto/quick/qquicklistview2/data/qtbug86744.qml
@@ -0,0 +1,25 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQml.Models
+
+Item {
+ height: 200
+ width: 100
+ DelegateModel {
+ id: dm
+ model: 2
+ delegate: Item {
+ width: 100
+ height: 20
+ property bool isCurrent: ListView.isCurrentItem
+ }
+ }
+ ListView {
+ objectName: "listView"
+ model: dm
+ currentIndex: 1
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/quick/qquicklistview2/data/qtbug98315.qml b/tests/auto/quick/qquicklistview2/data/qtbug98315.qml
new file mode 100644
index 0000000000..bf2ed857b1
--- /dev/null
+++ b/tests/auto/quick/qquicklistview2/data/qtbug98315.qml
@@ -0,0 +1,98 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQml.Models
+
+Item {
+ width: 500
+ height: 200
+
+ property list<QtObject> myModel: [
+ QtObject {
+ objectName: "Item 0"
+ property bool selected: true
+ },
+ QtObject {
+ objectName: "Item 1"
+ property bool selected: false
+ },
+ QtObject {
+ objectName: "Item 2"
+ property bool selected: false
+ },
+ QtObject {
+ objectName: "Item 3"
+ property bool selected: true
+ },
+ QtObject {
+ objectName: "Item 4"
+ property bool selected: true
+ },
+ QtObject {
+ objectName: "Item 5"
+ property bool selected: true
+ },
+ QtObject {
+ objectName: "Item 6"
+ property bool selected: false
+ }
+ ]
+
+ ListView {
+ objectName: "listView"
+ id: listview
+ width: 500
+ height: 200
+
+ focus: true
+ clip: true
+ spacing: 2
+ orientation: ListView.Horizontal
+ highlightMoveDuration: 300
+ highlightMoveVelocity: -1
+ preferredHighlightBegin: (500 - 100) / 2
+ preferredHighlightEnd: (500 + 100) / 2
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ cacheBuffer: 500
+ currentIndex: 1
+
+ model: DelegateModel {
+ id: delegateModel
+ filterOnGroup: "visible"
+ model: myModel
+ groups: [
+ DelegateModelGroup {
+ name: "visible"
+ includeByDefault: true
+ }
+ ]
+ delegate: Rectangle {
+ id: tile
+ objectName: model.modelData.objectName
+
+ width: 100
+ height: 100
+ border.width: 0
+ anchors.verticalCenter: parent.verticalCenter
+
+ visible: model.modelData.selected
+ Component.onCompleted: {
+ DelegateModel.inPersistedItems = true
+ DelegateModel.inVisible = Qt.binding(function () {
+ return model.modelData.selected
+ })
+ }
+
+ property bool isCurrent: ListView.isCurrentItem
+ color: isCurrent ? "red" : "green"
+
+ Text {
+ id: valueText
+ anchors.centerIn: parent
+ text: model.modelData.objectName
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview2/data/snapOneItem.qml b/tests/auto/quick/qquicklistview2/data/snapOneItem.qml
new file mode 100644
index 0000000000..a27f220865
--- /dev/null
+++ b/tests/auto/quick/qquicklistview2/data/snapOneItem.qml
@@ -0,0 +1,34 @@
+import QtQuick
+
+ListView {
+ id: list
+ snapMode: ListView.SnapOneItem
+ model: 4
+ width: 200
+ height: 200
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ highlight: Rectangle { width: 200; height: 200; color: "yellow" }
+ delegate: Rectangle {
+ id: wrapper
+ width: list.width
+ height: list.height
+ Column {
+ Text {
+ text: index
+ }
+ Text {
+ text: wrapper.x + ", " + wrapper.y
+ }
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "transparent"
+ }
+ // speed up test runs
+ flickDeceleration: 5000
+ rebound: Transition {
+ NumberAnimation {
+ properties: "x,y"
+ duration: 30
+ easing.type: Easing.OutBounce
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview2/tst_qquicklistview2.cpp b/tests/auto/quick/qquicklistview2/tst_qquicklistview2.cpp
index 8684439d24..98cb3cc20c 100644
--- a/tests/auto/quick/qquicklistview2/tst_qquicklistview2.cpp
+++ b/tests/auto/quick/qquicklistview2/tst_qquicklistview2.cpp
@@ -33,6 +33,8 @@ private slots:
void footerUpdate();
void singletonModelLifetime();
void delegateModelRefresh();
+ void wheelSnap();
+ void wheelSnap_data();
void sectionsNoOverlap();
void metaSequenceAsModel();
@@ -43,6 +45,12 @@ private slots:
void tapDelegateDuringFlicking();
void flickDuringFlicking_data();
void flickDuringFlicking();
+ void maxExtent_data();
+ void maxExtent();
+ void isCurrentItem_DelegateModel();
+ void isCurrentItem_NoRegressionWithDelegateModelGroups();
+
+ void pullbackSparseList();
private:
void flickWithTouch(QQuickWindow *window, const QPoint &from, const QPoint &to);
@@ -273,7 +281,7 @@ void tst_QQuickListView2::metaSequenceAsModel()
QScopedPointer<QObject> o(c.create());
QVERIFY(!o.isNull());
QStringList strings = qvariant_cast<QStringList>(o->property("texts"));
- QCOMPARE(strings.length(), 2);
+ QCOMPARE(strings.size(), 2);
QCOMPARE(strings[0], QStringLiteral("1/2"));
QCOMPARE(strings[1], QStringLiteral("5/6"));
}
@@ -430,7 +438,7 @@ void tst_QQuickListView2::tapDelegateDuringFlicking() // QTBUG-103832
QVERIFY(lastPressed > 5);
QCOMPARE(releasedDelegates.last(), lastPressed);
QCOMPARE(tappedDelegates.last(), lastPressed);
- QCOMPARE(canceledDelegates.count(), 1); // only the first press was canceled, not the second
+ QCOMPARE(canceledDelegates.size(), 1); // only the first press was canceled, not the second
}
void tst_QQuickListView2::flickDuringFlicking_data()
@@ -539,6 +547,391 @@ void tst_QQuickListView2::delegateModelRefresh()
QTRY_VERIFY(engine.rootObjects().first()->property("done").toBool());
}
+void tst_QQuickListView2::wheelSnap()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(QQuickItemView::VerticalLayoutDirection, verticalLayoutDirection);
+ QFETCH(QQuickItemView::HighlightRangeMode, highlightRangeMode);
+ QFETCH(QPoint, forwardAngleDelta);
+ QFETCH(qreal, snapAlignment);
+ QFETCH(qreal, endExtent);
+ QFETCH(qreal, startExtent);
+ QFETCH(qreal, preferredHighlightBegin);
+ QFETCH(qreal, preferredHighlightEnd);
+
+ // Helpers begin
+ quint64 timestamp = 10;
+ auto sendWheelEvent = [&timestamp](QQuickView *window, const QPoint &angleDelta) {
+ QPoint pos(100, 100);
+ QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), angleDelta, Qt::NoButton,
+ Qt::NoModifier, Qt::NoScrollPhase, false);
+ event.setAccepted(false);
+ event.setTimestamp(timestamp);
+ QGuiApplication::sendEvent(window, &event);
+ timestamp += 50;
+ };
+
+ auto atEnd = [&layoutDirection, &orientation,
+ &verticalLayoutDirection](QQuickListView *listview) {
+ if (orientation == QQuickListView::Horizontal) {
+ if (layoutDirection == Qt::LeftToRight)
+ return listview->isAtXEnd();
+
+ return listview->isAtXBeginning();
+ } else {
+ if (verticalLayoutDirection == QQuickItemView::VerticalLayoutDirection::TopToBottom)
+ return listview->isAtYEnd();
+
+ return listview->isAtYBeginning();
+ }
+ };
+
+ auto atBegin = [&layoutDirection, &orientation,
+ &verticalLayoutDirection](QQuickListView *listview) {
+ if (orientation == QQuickListView::Horizontal) {
+ if (layoutDirection == Qt::LeftToRight)
+ return listview->isAtXBeginning();
+
+ return listview->isAtXEnd();
+ } else {
+ if (verticalLayoutDirection == QQuickItemView::VerticalLayoutDirection::TopToBottom)
+ return listview->isAtYBeginning();
+
+ return listview->isAtYEnd();
+ }
+ };
+ // Helpers end
+
+ QScopedPointer<QQuickView> window(createView());
+ QTRY_VERIFY(window);
+ QQuickViewTestUtils::moveMouseAway(window.data());
+ window->setSource(testFileUrl("snapOneItem.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickListView *listview = qobject_cast<QQuickListView *>(window->rootObject());
+ QTRY_VERIFY(listview);
+
+ listview->setOrientation(orientation);
+ listview->setVerticalLayoutDirection(verticalLayoutDirection);
+ listview->setLayoutDirection(layoutDirection);
+ listview->setHighlightRangeMode(highlightRangeMode);
+ listview->setPreferredHighlightBegin(preferredHighlightBegin);
+ listview->setPreferredHighlightEnd(preferredHighlightEnd);
+ QVERIFY(QQuickTest::qWaitForPolish(listview));
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem);
+
+ QSignalSpy currentIndexSpy(listview, &QQuickListView::currentIndexChanged);
+
+ // confirm that a flick hits the next item boundary
+ int indexCounter = 0;
+ sendWheelEvent(window.data(), forwardAngleDelta);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), snapAlignment);
+ else
+ QCOMPARE(listview->contentX(), snapAlignment);
+
+ if (highlightRangeMode == QQuickItemView::StrictlyEnforceRange) {
+ ++indexCounter;
+ QTRY_VERIFY(listview->currentIndex() == indexCounter);
+ }
+
+ // flick to end
+ do {
+ sendWheelEvent(window.data(), forwardAngleDelta);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ if (highlightRangeMode == QQuickItemView::StrictlyEnforceRange) {
+ ++indexCounter;
+ QTRY_VERIFY(listview->currentIndex() == indexCounter);
+ }
+ } while (!atEnd(listview));
+
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), endExtent);
+ else
+ QCOMPARE(listview->contentX(), endExtent);
+
+ if (highlightRangeMode == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(listview->currentIndex(), listview->count() - 1);
+ QCOMPARE(currentIndexSpy.size(), listview->count() - 1);
+ }
+
+ // flick to start
+ const QPoint backwardAngleDelta(-forwardAngleDelta.x(), -forwardAngleDelta.y());
+ do {
+ sendWheelEvent(window.data(), backwardAngleDelta);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ if (highlightRangeMode == QQuickItemView::StrictlyEnforceRange) {
+ --indexCounter;
+ QTRY_VERIFY(listview->currentIndex() == indexCounter);
+ }
+ } while (!atBegin(listview));
+
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), startExtent);
+ else
+ QCOMPARE(listview->contentX(), startExtent);
+
+ if (highlightRangeMode == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(listview->currentIndex(), 0);
+ QCOMPARE(currentIndexSpy.size(), (listview->count() - 1) * 2);
+ }
+}
+
+void tst_QQuickListView2::wheelSnap_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<QQuickItemView::VerticalLayoutDirection>("verticalLayoutDirection");
+ QTest::addColumn<QQuickItemView::HighlightRangeMode>("highlightRangeMode");
+ QTest::addColumn<QPoint>("forwardAngleDelta");
+ QTest::addColumn<qreal>("snapAlignment");
+ QTest::addColumn<qreal>("endExtent");
+ QTest::addColumn<qreal>("startExtent");
+ QTest::addColumn<qreal>("preferredHighlightBegin");
+ QTest::addColumn<qreal>("preferredHighlightEnd");
+
+ QTest::newRow("vertical, top to bottom")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::NoHighlightRange << QPoint(20, -120) << 200.0 << 600.0 << 0.0 << 0.0
+ << 0.0;
+
+ QTest::newRow("vertical, bottom to top")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop
+ << QQuickItemView::NoHighlightRange << QPoint(20, 120) << -400.0 << -800.0 << -200.0
+ << 0.0 << 0.0;
+
+ QTest::newRow("horizontal, left to right")
+ << QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::NoHighlightRange << QPoint(-120, 20) << 200.0 << 600.0 << 0.0 << 0.0
+ << 0.0;
+
+ QTest::newRow("horizontal, right to left")
+ << QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom
+ << QQuickItemView::NoHighlightRange << QPoint(120, 20) << -400.0 << -800.0 << -200.0
+ << 0.0 << 0.0;
+
+ QTest::newRow("vertical, top to bottom, enforce range")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::StrictlyEnforceRange << QPoint(20, -120) << 200.0 << 600.0 << 0.0
+ << 0.0 << 0.0;
+
+ QTest::newRow("vertical, bottom to top, enforce range")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop
+ << QQuickItemView::StrictlyEnforceRange << QPoint(20, 120) << -400.0 << -800.0 << -200.0
+ << 0.0 << 0.0;
+
+ QTest::newRow("horizontal, left to right, enforce range")
+ << QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::StrictlyEnforceRange << QPoint(-120, 20) << 200.0 << 600.0 << 0.0
+ << 0.0 << 0.0;
+
+ QTest::newRow("horizontal, right to left, enforce range")
+ << QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom
+ << QQuickItemView::StrictlyEnforceRange << QPoint(120, 20) << -400.0 << -800.0 << -200.0
+ << 0.0 << 0.0;
+
+ QTest::newRow("vertical, top to bottom, apply range")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::ApplyRange << QPoint(20, -120) << 200.0 << 600.0 << 0.0 << 0.0
+ << 0.0;
+
+ QTest::newRow("vertical, bottom to top, apply range")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop
+ << QQuickItemView::ApplyRange << QPoint(20, 120) << -400.0 << -800.0 << -200.0 << 0.0
+ << 0.0;
+
+ QTest::newRow("horizontal, left to right, apply range")
+ << QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::ApplyRange << QPoint(-120, 20) << 200.0 << 600.0 << 0.0 << 0.0
+ << 0.0;
+
+ QTest::newRow("horizontal, right to left, apply range")
+ << QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom
+ << QQuickItemView::ApplyRange << QPoint(120, 20) << -400.0 << -800.0 << -200.0 << 0.0
+ << 0.0;
+
+ QTest::newRow("vertical, top to bottom with highlightRange")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::NoHighlightRange << QPoint(20, -120) << 190.0 << 600.0 << 0.0 << 10.0
+ << 210.0;
+
+ QTest::newRow("vertical, bottom to top with highlightRange")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop
+ << QQuickItemView::NoHighlightRange << QPoint(20, 120) << -390.0 << -800.0 << -200.0
+ << 10.0 << 210.0;
+
+ QTest::newRow("horizontal, left to right with highlightRange")
+ << QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::NoHighlightRange << QPoint(-120, 20) << 190.0 << 600.0 << 0.0 << 10.0
+ << 210.0;
+
+ QTest::newRow("horizontal, right to left with highlightRange")
+ << QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom
+ << QQuickItemView::NoHighlightRange << QPoint(120, 20) << -390.0 << -800.0 << -200.0
+ << 10.0 << 210.0;
+
+ QTest::newRow("vertical, top to bottom, enforce range with highlightRange")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::StrictlyEnforceRange << QPoint(20, -120) << 190.0 << 590.0 << -10.0
+ << 10.0 << 210.0;
+
+ QTest::newRow("vertical, bottom to top, enforce range with highlightRange")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop
+ << QQuickItemView::StrictlyEnforceRange << QPoint(20, 120) << -390.0 << -790.0 << -190.0
+ << 10.0 << 210.0;
+
+ QTest::newRow("horizontal, left to right, enforce range with highlightRange")
+ << QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::StrictlyEnforceRange << QPoint(-120, 20) << 190.0 << 590.0 << -10.0
+ << 10.0 << 210.0;
+
+ QTest::newRow("horizontal, right to left, enforce range with highlightRange")
+ << QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom
+ << QQuickItemView::StrictlyEnforceRange << QPoint(120, 20) << -390.0 << -790.0 << -190.0
+ << 10.0 << 210.0;
+
+ QTest::newRow("vertical, top to bottom, apply range with highlightRange")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::ApplyRange << QPoint(20, -120) << 190.0 << 600.0 << 0.0 << 10.0
+ << 210.0;
+
+ QTest::newRow("vertical, bottom to top, apply range with highlightRange")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop
+ << QQuickItemView::ApplyRange << QPoint(20, 120) << -390.0 << -800.0 << -200.0 << 10.0
+ << 210.0;
+
+ QTest::newRow("horizontal, left to right, apply range with highlightRange")
+ << QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom
+ << QQuickItemView::ApplyRange << QPoint(-120, 20) << 190.0 << 600.0 << 0.0 << 10.0
+ << 210.0;
+
+ QTest::newRow("horizontal, right to left, apply range with highlightRange")
+ << QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom
+ << QQuickItemView::ApplyRange << QPoint(120, 20) << -390.0 << -800.0 << -200.0 << 10.0
+ << 210.0;
+}
+
+class FriendlyItemView : public QQuickItemView
+{
+ friend class ItemViewAccessor;
+};
+
+class ItemViewAccessor
+{
+public:
+ ItemViewAccessor(QQuickItemView *itemView) :
+ mItemView(reinterpret_cast<FriendlyItemView*>(itemView))
+ {
+ }
+
+ qreal maxXExtent() const
+ {
+ return mItemView->maxXExtent();
+ }
+
+ qreal maxYExtent() const
+ {
+ return mItemView->maxYExtent();
+ }
+
+private:
+ FriendlyItemView *mItemView = nullptr;
+};
+
+void tst_QQuickListView2::maxExtent_data()
+{
+ QTest::addColumn<QString>("qmlFilePath");
+ QTest::addRow("maxXExtent") << "maxXExtent.qml";
+ QTest::addRow("maxYExtent") << "maxYExtent.qml";
+}
+
+void tst_QQuickListView2::maxExtent()
+{
+ QFETCH(QString, qmlFilePath);
+
+ QScopedPointer<QQuickView> window(createView());
+ QVERIFY(window);
+ window->setSource(testFileUrl(qmlFilePath));
+ QVERIFY2(window->status() == QQuickView::Ready, qPrintable(QDebug::toString(window->errors())));
+ window->resize(640, 480);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickListView *view = window->rootObject()->property("view").value<QQuickListView*>();
+ QVERIFY(view);
+ ItemViewAccessor viewAccessor(view);
+ if (view->orientation() == QQuickListView::Vertical)
+ QCOMPARE(viewAccessor.maxXExtent(), 0);
+ else if (view->orientation() == QQuickListView::Horizontal)
+ QCOMPARE(viewAccessor.maxYExtent(), 0);
+}
+
+void tst_QQuickListView2::isCurrentItem_DelegateModel()
+{
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("qtbug86744.qml"));
+ window->resize(640, 480);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QQuickListView* listView = window->rootObject()->findChild<QQuickListView*>("listView");
+ QVERIFY(listView);
+ QVariant value = listView->itemAtIndex(1)->property("isCurrent");
+ QVERIFY(value.toBool() == true);
+}
+
+void tst_QQuickListView2::isCurrentItem_NoRegressionWithDelegateModelGroups()
+{
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("qtbug98315.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QQuickListView* listView = window->rootObject()->findChild<QQuickListView*>("listView");
+ QVERIFY(listView);
+
+ QQuickItem *item3 = listView->itemAtIndex(1);
+ QVERIFY(item3);
+ QCOMPARE(item3->property("isCurrent").toBool(), true);
+
+ QObject *item0 = listView->itemAtIndex(0);
+ QVERIFY(item0);
+ QCOMPARE(item0->property("isCurrent").toBool(), false);
+
+ // Press left arrow key -> Item 1 should become current, Item 3 should not
+ // be current anymore. After a previous fix of QTBUG-86744 it was working
+ // incorrectly - see QTBUG-98315
+ QTest::keyPress(window.get(), Qt::Key_Left);
+
+ QTRY_COMPARE(item0->property("isCurrent").toBool(), true);
+ QCOMPARE(item3->property("isCurrent").toBool(), false);
+}
+
+void tst_QQuickListView2::pullbackSparseList() // QTBUG_104679
+{
+ // check if PullbackHeader crashes
+ QScopedPointer<QQuickView> window(createView());
+ QVERIFY(window);
+ window->setSource(testFileUrl("qtbug104679_header.qml"));
+ QVERIFY2(window->status() == QQuickView::Ready, qPrintable(QDebug::toString(window->errors())));
+ window->resize(640, 480);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ // check if PullbackFooter crashes
+ window.reset(createView());
+ QVERIFY(window);
+ window->setSource(testFileUrl("qtbug104679_footer.qml"));
+ QVERIFY2(window->status() == QQuickView::Ready, qPrintable(QDebug::toString(window->errors())));
+ window->resize(640, 480);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+}
+
QTEST_MAIN(tst_QQuickListView2)
#include "tst_qquicklistview2.moc"
diff --git a/tests/auto/quick/qquickloader/data/overflow.qml b/tests/auto/quick/qquickloader/data/overflow.qml
new file mode 100644
index 0000000000..e5fdfee182
--- /dev/null
+++ b/tests/auto/quick/qquickloader/data/overflow.qml
@@ -0,0 +1,5 @@
+import QtQuick
+
+Loader {
+ source: "overflow.qml"
+}
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
index b9c6eaab17..94fca41a02 100644
--- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -108,8 +108,11 @@ private slots:
void statusChangeOnlyEmittedOnce();
void setSourceAndCheckStatus();
+ void loadComponentWithStates();
void asyncLoaderRace();
void noEngine();
+
+ void stackOverflow();
};
Q_DECLARE_METATYPE(QList<QQmlError>)
@@ -161,7 +164,7 @@ void tst_QQuickLoader::sourceOrComponent()
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(loader->status(), error ? QQuickLoader::Error : QQuickLoader::Ready);
- QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().count(), error ? 0: 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().size(), error ? 0: 1);
if (!error) {
bool sourceComponentIsChildOfLoader = false;
@@ -222,12 +225,12 @@ void tst_QQuickLoader::clear()
QVERIFY(loader != nullptr);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().count(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().size(), 1);
QTRY_VERIFY(!loader->item());
QCOMPARE(loader->progress(), 0.0);
QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().count(), 0);
+ QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().size(), 0);
}
{
QQmlComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
@@ -238,14 +241,14 @@ void tst_QQuickLoader::clear()
QVERIFY(loader);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().size(), 1);
loader->setSourceComponent(nullptr);
QVERIFY(!loader->item());
QCOMPARE(loader->progress(), 0.0);
QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().size(), 0);
}
{
QQmlComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
@@ -256,14 +259,14 @@ void tst_QQuickLoader::clear()
QVERIFY(loader);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().size(), 1);
QMetaObject::invokeMethod(item.data(), "clear");
QVERIFY(!loader->item());
QCOMPARE(loader->progress(), 0.0);
QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().size(), 0);
}
}
@@ -284,7 +287,7 @@ void tst_QQuickLoader::urlToComponent()
QTRY_VERIFY(loader != nullptr);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().count(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().size(), 1);
QCOMPARE(loader->width(), 10.0);
QCOMPARE(loader->height(), 10.0);
}
@@ -300,12 +303,12 @@ void tst_QQuickLoader::componentToUrl()
QVERIFY(loader);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().size(), 1);
loader->setSource(testFileUrl("/Rect120x60.qml"));
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().size(), 1);
QCOMPARE(loader->width(), 120.0);
QCOMPARE(loader->height(), 60.0);
}
@@ -435,7 +438,7 @@ void tst_QQuickLoader::networkRequestUrl()
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(loader->property("signalCount").toInt(), 1);
- QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().count(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().size(), 1);
}
/* XXX Component waits until all dependencies are loaded. Is this actually possible? */
@@ -466,7 +469,7 @@ void tst_QQuickLoader::networkComponent()
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(loader->status(), QQuickLoader::Ready);
- QCOMPARE(static_cast<QQuickItem*>(loader)->children().count(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->children().size(), 1);
}
@@ -489,7 +492,7 @@ void tst_QQuickLoader::failNetworkRequest()
QVERIFY(!loader->item());
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(loader->property("did_load").toInt(), 123);
- QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().count(), 0);
+ QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().size(), 0);
}
void tst_QQuickLoader::active()
@@ -789,7 +792,7 @@ void tst_QQuickLoader::deleteComponentCrash()
QCOMPARE(loader->status(), QQuickLoader::Ready);
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
QCoreApplication::processEvents();
- QTRY_COMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QTRY_COMPARE(static_cast<QQuickItem*>(loader)->childItems().size(), 1);
QCOMPARE(loader->source(), QUrl("BlueRect.qml"));
}
@@ -866,8 +869,8 @@ void tst_QQuickLoader::implicitSize()
QCOMPARE(loader->property("implicitWidth").toReal(), 200.);
QCOMPARE(loader->property("implicitHeight").toReal(), 300.);
- QCOMPARE(implWidthSpy.count(), 1);
- QCOMPARE(implHeightSpy.count(), 1);
+ QCOMPARE(implWidthSpy.size(), 1);
+ QCOMPARE(implHeightSpy.size(), 1);
}
void tst_QQuickLoader::QTBUG_17114()
@@ -970,7 +973,7 @@ void tst_QQuickLoader::asynchronous_clear()
QCOMPARE(loader->progress(), 0.0);
QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().size(), 0);
// check loading component
root->setProperty("comp", "BigComponent.qml");
@@ -983,7 +986,7 @@ void tst_QQuickLoader::asynchronous_clear()
QTRY_VERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(loader->status(), QQuickLoader::Ready);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().size(), 1);
}
void tst_QQuickLoader::simultaneousSyncAsync()
@@ -1047,7 +1050,7 @@ void tst_QQuickLoader::asyncToSync1()
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(loader->status(), QQuickLoader::Ready);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().size(), 1);
}
void tst_QQuickLoader::asyncToSync2()
@@ -1079,7 +1082,7 @@ void tst_QQuickLoader::asyncToSync2()
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(loader->status(), QQuickLoader::Ready);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().size(), 1);
}
void tst_QQuickLoader::loadedSignal()
@@ -1287,7 +1290,7 @@ void tst_QQuickLoader::sourceComponentGarbageCollection()
if (spy.isEmpty())
QVERIFY(spy.wait());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
// QTBUG-51995
@@ -1491,6 +1494,26 @@ void tst_QQuickLoader::setSourceAndCheckStatus()
QCOMPARE(loader->status(), QQuickLoader::Null);
}
+void tst_QQuickLoader::loadComponentWithStates()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick\n"
+ "Loader {\n"
+ "id: loader\n"
+ "property int createdObjCount: 0\n"
+ "states: [ State { when: true; PropertyChanges { target: loader; sourceComponent: myComp } } ]\n"
+ "Component { id: myComp; Item { Component.onCompleted: { ++createdObjCount } } }\n"
+ "}" )
+ , dataDirectoryUrl());
+ QScopedPointer<QQuickLoader> loader(qobject_cast<QQuickLoader*>(component.create()));
+ QTest::qWait(200);
+ QTRY_VERIFY(loader != nullptr);
+ QVERIFY(loader->item());
+ QCOMPARE(static_cast<QQuickItem*>(loader.data())->childItems().size(), 1);
+ QCOMPARE(loader->property("createdObjCount").toInt(), 1);
+}
+
void tst_QQuickLoader::asyncLoaderRace()
{
QQmlApplicationEngine engine;
@@ -1523,6 +1546,17 @@ void tst_QQuickLoader::noEngine()
QTRY_COMPARE(o->property("changes").toInt(), 1);
}
+void tst_QQuickLoader::stackOverflow()
+{
+ QQmlEngine engine;
+ const QUrl url = testFileUrl("overflow.qml");
+ QQmlComponent component(&engine, url);
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ const QString message = url.toString() + QStringLiteral(": Maximum call stack size exceeded.");
+ QTest::ignoreMessage(QtCriticalMsg, qPrintable(message));
+ QScopedPointer<QObject> o(component.create());
+}
+
QTEST_MAIN(tst_QQuickLoader)
#include "tst_qquickloader.moc"
diff --git a/tests/auto/quick/qquickmousearea/data/containsMouseAndHoverDisabled.qml b/tests/auto/quick/qquickmousearea/data/containsMouseAndHoverDisabled.qml
new file mode 100644
index 0000000000..d98ef85c55
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/data/containsMouseAndHoverDisabled.qml
@@ -0,0 +1,15 @@
+import QtQuick
+
+Rectangle {
+ width: 200
+ height: 200
+ visible: true
+ MouseArea {
+ id: mouseArea
+ objectName: "mouseArea"
+ anchors.fill: parent
+ hoverEnabled: false
+ onPressed: function(mouse) { mouse.accepted = false }
+ }
+}
+
diff --git a/tests/auto/quick/qquickmousearea/data/containsMouseMasked.qml b/tests/auto/quick/qquickmousearea/data/containsMouseMasked.qml
new file mode 100644
index 0000000000..35cfd4b7ef
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/data/containsMouseMasked.qml
@@ -0,0 +1,24 @@
+import QtQuick
+
+Rectangle {
+ width: 200
+ height: 200
+ visible: true
+ MouseArea {
+ id: mouseArea1
+ objectName: "mouseArea1"
+ anchors.fill: parent
+ hoverEnabled: true
+ visible: true
+ }
+
+ MouseArea {
+ id: mouseArea2
+ objectName: "mouseArea2"
+ anchors.centerIn: mouseArea1
+ width: 50
+ height: 50
+ hoverEnabled: true
+ visible: true
+ }
+}
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index f07a7ba221..44aa28f3f9 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -108,6 +108,7 @@ private slots:
void hoverVisible();
void hoverAfterPress();
void subtreeHoverEnabled();
+ void hoverWhenDisabled();
void disableAfterPress();
void onWheel();
void transformedMouseArea_data();
@@ -135,6 +136,8 @@ private slots:
void settingHiddenInPressUngrabs();
void negativeZStackingOrder();
void containsMouseAndVisibility();
+ void containsMouseAndVisibilityMasked();
+ void containsMouseAndHoverDisabled();
void doubleClickToHide();
void releaseFirstTouchAfterSecond();
#if QT_CONFIG(tabletevent)
@@ -195,18 +198,18 @@ void tst_QQuickMouseArea::dragProperties()
QVERIFY(rootItem != nullptr);
QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
drag->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
+ QCOMPARE(targetSpy.size(),1);
drag->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
+ QCOMPARE(targetSpy.size(),1);
// axis
QCOMPARE(drag->axis(), QQuickDrag::XAndYAxis);
QSignalSpy axisSpy(drag, SIGNAL(axisChanged()));
drag->setAxis(QQuickDrag::XAxis);
QCOMPARE(drag->axis(), QQuickDrag::XAxis);
- QCOMPARE(axisSpy.count(),1);
+ QCOMPARE(axisSpy.size(),1);
drag->setAxis(QQuickDrag::XAxis);
- QCOMPARE(axisSpy.count(),1);
+ QCOMPARE(axisSpy.size(),1);
// minimum and maximum properties
QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged()));
@@ -229,20 +232,20 @@ void tst_QQuickMouseArea::dragProperties()
QCOMPARE(drag->ymin(), 10.0);
QCOMPARE(drag->ymax(), 10.0);
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
+ QCOMPARE(xminSpy.size(),1);
+ QCOMPARE(xmaxSpy.size(),1);
+ QCOMPARE(yminSpy.size(),1);
+ QCOMPARE(ymaxSpy.size(),1);
drag->setXmin(10);
drag->setXmax(10);
drag->setYmin(10);
drag->setYmax(10);
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
+ QCOMPARE(xminSpy.size(),1);
+ QCOMPARE(xmaxSpy.size(),1);
+ QCOMPARE(yminSpy.size(),1);
+ QCOMPARE(ymaxSpy.size(),1);
// filterChildren
QSignalSpy filterChildrenSpy(drag, SIGNAL(filterChildrenChanged()));
@@ -250,24 +253,24 @@ void tst_QQuickMouseArea::dragProperties()
drag->setFilterChildren(true);
QVERIFY(drag->filterChildren());
- QCOMPARE(filterChildrenSpy.count(), 1);
+ QCOMPARE(filterChildrenSpy.size(), 1);
drag->setFilterChildren(true);
- QCOMPARE(filterChildrenSpy.count(), 1);
+ QCOMPARE(filterChildrenSpy.size(), 1);
// threshold
QCOMPARE(int(drag->threshold()), qApp->styleHints()->startDragDistance());
QSignalSpy thresholdSpy(drag, SIGNAL(thresholdChanged()));
drag->setThreshold(0.0);
QCOMPARE(drag->threshold(), 0.0);
- QCOMPARE(thresholdSpy.count(), 1);
+ QCOMPARE(thresholdSpy.size(), 1);
drag->setThreshold(99);
- QCOMPARE(thresholdSpy.count(), 2);
+ QCOMPARE(thresholdSpy.size(), 2);
drag->setThreshold(99);
- QCOMPARE(thresholdSpy.count(), 2);
+ QCOMPARE(thresholdSpy.size(), 2);
drag->resetThreshold();
QCOMPARE(int(drag->threshold()), qApp->styleHints()->startDragDistance());
- QCOMPARE(thresholdSpy.count(), 3);
+ QCOMPARE(thresholdSpy.size(), 3);
}
void tst_QQuickMouseArea::resetDrag()
@@ -292,7 +295,7 @@ void tst_QQuickMouseArea::resetDrag()
auto root = window.rootObject();
QQmlProperty haveTarget {root, "haveTarget"};
haveTarget.write(false);
- QCOMPARE(targetSpy.count(),1);
+ QCOMPARE(targetSpy.size(),1);
QVERIFY(!drag->target());
}
@@ -1049,7 +1052,7 @@ void tst_QQuickMouseArea::preventStealing()
QTest::mouseMove(&window, p);
// We should have received all four move events
- QTRY_COMPARE(mousePositionSpy.count(), 4);
+ QTRY_COMPARE(mousePositionSpy.size(), 4);
mousePositionSpy.clear();
QVERIFY(mouseArea->pressed());
@@ -1078,7 +1081,7 @@ void tst_QQuickMouseArea::preventStealing()
QTest::mouseMove(&window, p);
// We should only have received the first move event
- QTRY_COMPARE(mousePositionSpy.count(), 1);
+ QTRY_COMPARE(mousePositionSpy.size(), 1);
// Our press should be taken away
QVERIFY(!mouseArea->pressed());
@@ -1319,12 +1322,12 @@ void tst_QQuickMouseArea::hoverVisible()
QTest::mouseMove(&window,QPoint(11,33));
QCOMPARE(mouseTracker->hovered(), false);
- QCOMPARE(enteredSpy.count(), 0);
+ QCOMPARE(enteredSpy.size(), 0);
mouseTracker->setVisible(true);
QCOMPARE(mouseTracker->hovered(), true);
- QCOMPARE(enteredSpy.count(), 1);
+ QCOMPARE(enteredSpy.size(), 1);
QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(11,33));
@@ -1399,6 +1402,37 @@ void tst_QQuickMouseArea::subtreeHoverEnabled()
QCOMPARE(mouseArea->hovered(), false);
}
+void tst_QQuickMouseArea::hoverWhenDisabled()
+{
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("hoverVisible.qml")));
+ QQuickItem *root = window.rootObject();
+ QVERIFY(root);
+
+ QQuickMouseArea *mouseArea = root->findChild<QQuickMouseArea*>();
+ QVERIFY(mouseArea);
+ mouseArea->setVisible(true);
+
+ QTest::mouseMove(&window, QPoint(50, 50));
+ QVERIFY(mouseArea->hovered());
+
+ mouseArea->setEnabled(false);
+ QTest::mouseMove(&window, QPoint(51, 50));
+ QVERIFY(!mouseArea->hovered());
+
+ mouseArea->setEnabled(true);
+ QTest::mouseMove(&window, QPoint(50, 50));
+ QVERIFY(mouseArea->hovered());
+
+ mouseArea->setHoverEnabled(false);
+ QTest::mouseMove(&window, QPoint(51, 50));
+ QVERIFY(!mouseArea->hovered());
+
+ mouseArea->setHoverEnabled(true);
+ QTest::mouseMove(&window, QPoint(50, 50));
+ QVERIFY(mouseArea->hovered());
+}
+
void tst_QQuickMouseArea::disableAfterPress()
{
QQuickView window;
@@ -1423,7 +1457,7 @@ void tst_QQuickMouseArea::disableAfterPress()
QVERIFY(!drag->active());
QPoint p = QPoint(100,100);
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p);
- QTRY_COMPARE(mousePressSpy.count(), 1);
+ QTRY_COMPARE(mousePressSpy.size(), 1);
QVERIFY(!drag->active());
QCOMPARE(blackRect->x(), 50.0);
@@ -1437,7 +1471,7 @@ void tst_QQuickMouseArea::disableAfterPress()
p += QPoint(11, 11);
QTest::mouseMove(&window, p);
- QTRY_COMPARE(mousePositionSpy.count(), 2);
+ QTRY_COMPARE(mousePositionSpy.size(), 2);
QTRY_VERIFY(drag->active());
QTRY_COMPARE(blackRect->x(), 61.0);
@@ -1451,7 +1485,7 @@ void tst_QQuickMouseArea::disableAfterPress()
p += QPoint(11, 11);
QTest::mouseMove(&window, p);
- QTRY_COMPARE(mousePositionSpy.count(), 4);
+ QTRY_COMPARE(mousePositionSpy.size(), 4);
QVERIFY(drag->active());
QCOMPARE(blackRect->x(), 83.0);
@@ -1462,7 +1496,7 @@ void tst_QQuickMouseArea::disableAfterPress()
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p);
- QTRY_COMPARE(mouseReleaseSpy.count(), 1);
+ QTRY_COMPARE(mouseReleaseSpy.size(), 1);
QVERIFY(!drag->active());
QCOMPARE(blackRect->x(), 83.0);
@@ -1481,14 +1515,14 @@ void tst_QQuickMouseArea::disableAfterPress()
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, QPoint(100,100));
QTest::qWait(50);
- QCOMPARE(mousePressSpy.count(), 0);
+ QCOMPARE(mousePressSpy.size(), 0);
QTest::mouseMove(&window, QPoint(111,111));
QTest::qWait(50);
QTest::mouseMove(&window, QPoint(122,122));
QTest::qWait(50);
- QCOMPARE(mousePositionSpy.count(), 0);
+ QCOMPARE(mousePositionSpy.size(), 0);
QVERIFY(!drag->active());
QCOMPARE(blackRect->x(), 50.0);
@@ -1497,7 +1531,7 @@ void tst_QQuickMouseArea::disableAfterPress()
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(122,122));
QTest::qWait(50);
- QCOMPARE(mouseReleaseSpy.count(), 0);
+ QCOMPARE(mouseReleaseSpy.size(), 0);
}
void tst_QQuickMouseArea::onWheel()
@@ -1660,7 +1694,7 @@ void tst_QQuickMouseArea::pressedMultipleButtons()
mouseArea->setAcceptedMouseButtons(accepted);
QPoint point(10, 10);
- for (int i = 0; i < mouseEvents.count(); ++i) {
+ for (int i = 0; i < mouseEvents.size(); ++i) {
const MouseEvent mouseEvent = mouseEvents.at(i);
if (mouseEvent.type == QEvent::MouseButtonPress)
QTest::mousePress(&window, mouseEvent.button, Qt::NoModifier, point);
@@ -1670,8 +1704,8 @@ void tst_QQuickMouseArea::pressedMultipleButtons()
QCOMPARE(mouseArea->pressedButtons(), pressedButtons.at(i));
}
- QCOMPARE(pressedSpy.count(), 2);
- QCOMPARE(pressedButtonsSpy.count(), changeCount);
+ QCOMPARE(pressedSpy.size(), 2);
+ QCOMPARE(pressedButtonsSpy.size(), changeCount);
}
void tst_QQuickMouseArea::changeAxis()
@@ -1751,15 +1785,15 @@ void tst_QQuickMouseArea::cursorShape()
mouseArea->setCursorShape(Qt::IBeamCursor);
QCOMPARE(mouseArea->cursorShape(), Qt::IBeamCursor);
QCOMPARE(mouseArea->cursor().shape(), Qt::IBeamCursor);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
mouseArea->setCursorShape(Qt::IBeamCursor);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
mouseArea->setCursorShape(Qt::WaitCursor);
QCOMPARE(mouseArea->cursorShape(), Qt::WaitCursor);
QCOMPARE(mouseArea->cursor().shape(), Qt::WaitCursor);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
#endif
@@ -1972,25 +2006,25 @@ void tst_QQuickMouseArea::containsPress()
QCOMPARE(mouseArea->hovered(), true);
QTRY_COMPARE(mouseArea->pressed(), true);
QCOMPARE(mouseArea->containsPress(), true);
- QCOMPARE(containsPressSpy.count(), 1);
+ QCOMPARE(containsPressSpy.size(), 1);
QTest::mouseMove(&window, QPoint(22,33));
QCOMPARE(mouseArea->hovered(), false);
QCOMPARE(mouseArea->pressed(), true);
QCOMPARE(mouseArea->containsPress(), false);
- QCOMPARE(containsPressSpy.count(), 2);
+ QCOMPARE(containsPressSpy.size(), 2);
QTest::mouseMove(&window, QPoint(200,200));
QCOMPARE(mouseArea->hovered(), true);
QCOMPARE(mouseArea->pressed(), true);
QCOMPARE(mouseArea->containsPress(), true);
- QCOMPARE(containsPressSpy.count(), 3);
+ QCOMPARE(containsPressSpy.size(), 3);
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(200,200));
QCOMPARE(mouseArea->hovered(), hoverEnabled);
QCOMPARE(mouseArea->pressed(), false);
QCOMPARE(mouseArea->containsPress(), false);
- QCOMPARE(containsPressSpy.count(), 4);
+ QCOMPARE(containsPressSpy.size(), 4);
}
void tst_QQuickMouseArea::ignoreBySource()
@@ -2312,8 +2346,8 @@ void tst_QQuickMouseArea::negativeZStackingOrder() // QTBUG-83114
QSignalSpy clickSpyChild(childMouseArea, &QQuickMouseArea::clicked);
QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, QPoint(150, 100));
- QCOMPARE(clickSpyChild.count(), 1);
- QCOMPARE(clickSpyParent.count(), 0);
+ QCOMPARE(clickSpyChild.size(), 1);
+ QCOMPARE(clickSpyParent.size(), 0);
auto order = root->property("clicks").toList();
QVERIFY(order.at(0) == "childMouseArea");
@@ -2321,8 +2355,8 @@ void tst_QQuickMouseArea::negativeZStackingOrder() // QTBUG-83114
childMouseArea->parentItem()->setZ(-1);
root->setProperty("clicks", QVariantList());
QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, QPoint(150, 100));
- QCOMPARE(clickSpyChild.count(), 1);
- QCOMPARE(clickSpyParent.count(), 1);
+ QCOMPARE(clickSpyChild.size(), 1);
+ QCOMPARE(clickSpyParent.size(), 1);
order = root->property("clicks").toList();
QVERIFY(order.at(0) == "parentMouseArea");
}
@@ -2372,6 +2406,68 @@ void tst_QQuickMouseArea::containsMouseAndVisibility()
QVERIFY(!mouseArea->hovered());
}
+// QTBUG-109567
+void tst_QQuickMouseArea::containsMouseAndVisibilityMasked()
+{
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("containsMouseMasked.qml")));
+
+ QQuickMouseArea *mouseArea1 = window.rootObject()->findChild<QQuickMouseArea *>("mouseArea1");
+ QVERIFY(mouseArea1 != nullptr);
+ QVERIFY(mouseArea1->isVisible());
+
+ QQuickMouseArea *mouseArea2 = window.rootObject()->findChild<QQuickMouseArea *>("mouseArea2");
+ QVERIFY(mouseArea2 != nullptr);
+ QVERIFY(mouseArea2->isVisible());
+
+ QTest::mouseMove(&window, QPoint(window.width() / 2, window.height() / 2));
+
+ // Check that mouseArea" (i.e. the masking MouseArea) is the only hovered MouseArea.
+ QTRY_VERIFY(!mouseArea1->hovered());
+ QTRY_VERIFY(mouseArea2->hovered());
+
+ // Toggle the visibility of the masked MouseArea (mouseArea1).
+ mouseArea1->setVisible(false);
+ QVERIFY(!mouseArea1->isVisible());
+
+ mouseArea1->setVisible(true);
+ QVERIFY(mouseArea1->isVisible());
+
+ // Check that the masked MouseArea is not now hovered depite being under the mouse after
+ // changing the visibility to visible. mouseArea2 should be the only hovered MouseArea still.
+ QTRY_VERIFY(!mouseArea1->hovered());
+ QTRY_VERIFY(mouseArea2->hovered());
+
+ QTest::mouseMove(&window, QPoint(10, 10));
+
+ QTRY_VERIFY(mouseArea1->hovered());
+ QTRY_VERIFY(!mouseArea2->hovered());
+
+ // Toggle the visibility of the masked MouseArea (mouseArea1).
+ mouseArea1->setVisible(false);
+ QVERIFY(!mouseArea1->isVisible());
+
+ mouseArea1->setVisible(true);
+ QVERIFY(mouseArea1->isVisible());
+
+ QTRY_VERIFY(mouseArea1->hovered());
+ QTRY_VERIFY(!mouseArea2->hovered());
+}
+
+// QTBUG-110594
+void tst_QQuickMouseArea::containsMouseAndHoverDisabled()
+{
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("containsMouseAndHoverDisabled.qml")));
+
+ QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea *>("mouseArea");
+ QVERIFY(mouseArea != nullptr);
+ QVERIFY(!mouseArea->hoverEnabled());
+
+ QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, QPoint(100, 100));
+ QTRY_VERIFY(!mouseArea->hovered());
+}
+
// QTBUG-35995 and QTBUG-102158
void tst_QQuickMouseArea::doubleClickToHide()
{
@@ -2405,13 +2501,13 @@ void tst_QQuickMouseArea::releaseFirstTouchAfterSecond() // QTBUG-103766
QSignalSpy releaseSpy(mouseArea, &QQuickMouseArea::released);
QTest::touchEvent(&window, device).press(0, {20, 20});
- QTRY_COMPARE(pressSpy.count(), 1);
+ QTRY_COMPARE(pressSpy.size(), 1);
QTest::touchEvent(&window, device).stationary(0).press(1, {100, 20});
- QCOMPARE(pressSpy.count(), 1); // touchpoint 0 is the touchmouse, touchpoint 1 is ignored
+ QCOMPARE(pressSpy.size(), 1); // touchpoint 0 is the touchmouse, touchpoint 1 is ignored
QTest::touchEvent(&window, device).stationary(0).release(1, {100, 20});
- QCOMPARE(releaseSpy.count(), 0); // touchpoint 0 is the touchmouse, and remains pressed
+ QCOMPARE(releaseSpy.size(), 0); // touchpoint 0 is the touchmouse, and remains pressed
QTest::touchEvent(&window, device).release(0, {20, 20});
- QTRY_COMPARE(releaseSpy.count(), 1);
+ QTRY_COMPARE(releaseSpy.size(), 1);
}
#if QT_CONFIG(tabletevent)
@@ -2433,15 +2529,15 @@ void tst_QQuickMouseArea::tabletStylusTap()
Qt::LeftButton, 0.5, 0, 0, 0, 0, 0, stylusId, Qt::NoModifier);
if (QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse)
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, point); // simulate what the platform does
- QTRY_COMPARE(pressSpy.count(), 1);
+ QTRY_COMPARE(pressSpy.size(), 1);
QWindowSystemInterface::handleTabletEvent(&window, point, window.mapToGlobal(point),
int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen),
Qt::NoButton, 0.5, 0, 0, 0, 0, 0, stylusId, Qt::NoModifier);
if (QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse)
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, point);
- QTRY_COMPARE(releaseSpy.count(), 1);
- QCOMPARE(clickSpy.count(), 1);
- QCOMPARE(pressSpy.count(), 1);
+ QTRY_COMPARE(releaseSpy.size(), 1);
+ QCOMPARE(clickSpy.size(), 1);
+ QCOMPARE(pressSpy.size(), 1);
}
#endif
diff --git a/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST b/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST
index abe504d20c..2488eff270 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST
+++ b/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST
@@ -1,4 +1,6 @@
[nonOverlapping]
ubuntu-20.04
+ubuntu-22.04
[nested]
ubuntu-20.04
+ubuntu-22.04
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
index 5da20ce9a2..509465b174 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -1243,22 +1243,22 @@ void tst_QQuickMultiPointTouchArea::mouseGestureStarted() // QTBUG-70258
QPoint p1 = QPoint(distanceFromOrigin, distanceFromOrigin);
QTest::mousePress(view.data(), Qt::LeftButton, Qt::NoModifier, p1);
- QCOMPARE(gestureStartedSpy.count(), 0);
+ QCOMPARE(gestureStartedSpy.size(), 0);
p1 += QPoint(dragThreshold, dragThreshold);
QTest::mouseMove(view.data(), p1);
- QCOMPARE(gestureStartedSpy.count(), 0);
+ QCOMPARE(gestureStartedSpy.size(), 0);
p1 += QPoint(1, 1);
QTest::mouseMove(view.data(), p1);
- QTRY_COMPARE(gestureStartedSpy.count(), 1);
+ QTRY_COMPARE(gestureStartedSpy.size(), 1);
QTRY_COMPARE(area->property("gestureStartedX").toInt(), distanceFromOrigin);
QCOMPARE(area->property("gestureStartedY").toInt(), distanceFromOrigin);
p1 += QPoint(10, 10);
QTest::mouseMove(view.data(), p1);
// if nobody called gesteure->grab(), gestureStarted will keep happening
- QTRY_COMPARE(gestureStartedSpy.count(), grabGesture ? 1 : 2);
+ QTRY_COMPARE(gestureStartedSpy.size(), grabGesture ? 1 : 2);
QCOMPARE(area->property("gestureStartedX").toInt(), distanceFromOrigin);
QCOMPARE(area->property("gestureStartedY").toInt(), distanceFromOrigin);
@@ -1370,7 +1370,7 @@ void tst_QQuickMultiPointTouchArea::touchFiltering() // QTBUG-74028
QQuickTouchUtils::flush(window.data());
QTRY_COMPARE(mpta->parentItem()->property("mptaPoint").toPoint(), pt);
QCOMPARE(mpta->parentItem()->property("maPoint").toPoint(), ma->boundingRect().center().toPoint());
- QCOMPARE(mptaSpy.count(), 1);
+ QCOMPARE(mptaSpy.size(), 1);
}
void tst_QQuickMultiPointTouchArea::nestedPinchAreaMouse() // QTBUG-83662
@@ -1391,32 +1391,32 @@ void tst_QQuickMultiPointTouchArea::nestedPinchAreaMouse() // QTBUG-83662
QTest::mousePress(window.data(), Qt::LeftButton, Qt::NoModifier, p1);
QCOMPARE(point1->pressed(), true);
QCOMPARE(point2->pressed(), false);
- QCOMPARE(pressedSpy.count(), 1);
+ QCOMPARE(pressedSpy.size(), 1);
QCOMPARE(mpta->property("pressedCount").toInt(), 1);
- QCOMPARE(updatedSpy.count(), 0);
+ QCOMPARE(updatedSpy.size(), 0);
QCOMPARE(mpta->property("updatedCount").toInt(), 0);
- QCOMPARE(releasedSpy.count(), 0);
+ QCOMPARE(releasedSpy.size(), 0);
QCOMPARE(mpta->property("releasedCount").toInt(), 0);
p1 += QPoint(0, 15);
QTest::mouseMove(window.data(), p1);
QCOMPARE(point1->pressed(), true);
QCOMPARE(point2->pressed(), false);
- QCOMPARE(pressedSpy.count(), 1);
+ QCOMPARE(pressedSpy.size(), 1);
QCOMPARE(mpta->property("pressedCount").toInt(), 1);
- QCOMPARE(updatedSpy.count(), 1);
+ QCOMPARE(updatedSpy.size(), 1);
QCOMPARE(mpta->property("updatedCount").toInt(), 1);
- QCOMPARE(releasedSpy.count(), 0);
+ QCOMPARE(releasedSpy.size(), 0);
QCOMPARE(mpta->property("releasedCount").toInt(), 0);
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, p1);
QCOMPARE(point1->pressed(), false);
QCOMPARE(point2->pressed(), false);
- QCOMPARE(pressedSpy.count(), 1);
+ QCOMPARE(pressedSpy.size(), 1);
QCOMPARE(mpta->property("pressedCount").toInt(), 1);
- QCOMPARE(updatedSpy.count(), 1);
+ QCOMPARE(updatedSpy.size(), 1);
QCOMPARE(mpta->property("updatedCount").toInt(), 1);
- QCOMPARE(releasedSpy.count(), 1);
+ QCOMPARE(releasedSpy.size(), 1);
QCOMPARE(mpta->property("releasedCount").toInt(), 1);
}
diff --git a/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp b/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp
index f002de0e3d..56ebfdbd48 100644
--- a/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp
+++ b/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp
@@ -282,24 +282,24 @@ void tst_QQuickPaintedItem::contentsSize()
item.setContentsSize(QSize());
QCOMPARE(item.contentsSize(), QSize());
QCOMPARE(hasDirtyContentFlag(&item), false);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
item.setContentsSize(QSize(320, 240));
QCOMPARE(item.contentsSize(), QSize(320, 240));
QCOMPARE(hasDirtyContentFlag(&item), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
clearDirtyContentFlag(&item);
item.setContentsSize(QSize(320, 240));
QCOMPARE(item.contentsSize(), QSize(320, 240));
QCOMPARE(hasDirtyContentFlag(&item), false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
item.resetContentsSize();
QCOMPARE(item.contentsSize(), QSize());
QCOMPARE(hasDirtyContentFlag(&item), true);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QQuickPaintedItem::contentScale()
@@ -315,7 +315,7 @@ void tst_QQuickPaintedItem::contentScale()
item.setContentsScale(1.);
QCOMPARE(item.contentsScale(), 1.);
QCOMPARE(hasDirtyContentFlag(&item), false);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
item.update();
QTRY_COMPARE(hasDirtyContentFlag(&item), false);
@@ -325,7 +325,7 @@ void tst_QQuickPaintedItem::contentScale()
item.setContentsScale(0.4);
QCOMPARE(item.contentsScale(), 0.4);
QCOMPARE(hasDirtyContentFlag(&item), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTRY_COMPARE(hasDirtyContentFlag(&item), false);
QVERIFY(item.paintNode);
@@ -334,12 +334,12 @@ void tst_QQuickPaintedItem::contentScale()
item.setContentsScale(0.4);
QCOMPARE(item.contentsScale(), 0.4);
QCOMPARE(hasDirtyContentFlag(&item), false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
item.setContentsScale(2.5);
QCOMPARE(item.contentsScale(), 2.5);
QCOMPARE(hasDirtyContentFlag(&item), true);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QTRY_COMPARE(hasDirtyContentFlag(&item), false);
QVERIFY(item.paintNode);
@@ -397,7 +397,7 @@ void tst_QQuickPaintedItem::fillColor()
item.setFillColor(QColor(Qt::transparent));
QCOMPARE(item.fillColor(), QColor(Qt::transparent));
QCOMPARE(hasDirtyContentFlag(&item), false);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
item.update();
QTRY_COMPARE(hasDirtyContentFlag(&item), false);
@@ -407,7 +407,7 @@ void tst_QQuickPaintedItem::fillColor()
item.setFillColor(QColor(Qt::green));
QCOMPARE(item.fillColor(), QColor(Qt::green));
QCOMPARE(hasDirtyContentFlag(&item), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTRY_COMPARE(hasDirtyContentFlag(&item), false);
QVERIFY(item.paintNode);
@@ -416,12 +416,12 @@ void tst_QQuickPaintedItem::fillColor()
item.setFillColor(QColor(Qt::green));
QCOMPARE(item.fillColor(), QColor(Qt::green));
QCOMPARE(hasDirtyContentFlag(&item), false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
item.setFillColor(QColor(Qt::blue));
QCOMPARE(item.fillColor(), QColor(Qt::blue));
QCOMPARE(hasDirtyContentFlag(&item), true);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QTRY_COMPARE(hasDirtyContentFlag(&item), false);
QVERIFY(item.paintNode);
@@ -440,24 +440,24 @@ void tst_QQuickPaintedItem::renderTarget()
item.setRenderTarget(QQuickPaintedItem::Image);
QCOMPARE(item.renderTarget(), QQuickPaintedItem::Image);
QCOMPARE(hasDirtyContentFlag(&item), false);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
item.setRenderTarget(QQuickPaintedItem::FramebufferObject);
QCOMPARE(item.renderTarget(), QQuickPaintedItem::FramebufferObject);
QCOMPARE(hasDirtyContentFlag(&item), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
clearDirtyContentFlag(&item);
item.setRenderTarget(QQuickPaintedItem::FramebufferObject);
QCOMPARE(item.renderTarget(), QQuickPaintedItem::FramebufferObject);
QCOMPARE(hasDirtyContentFlag(&item), false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
item.setRenderTarget(QQuickPaintedItem::InvertedYFramebufferObject);
QCOMPARE(item.renderTarget(), QQuickPaintedItem::InvertedYFramebufferObject);
QCOMPARE(hasDirtyContentFlag(&item), true);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
QTEST_MAIN(tst_QQuickPaintedItem)
diff --git a/tests/auto/quick/qquickpalette/tst_qquickpalette.cpp b/tests/auto/quick/qquickpalette/tst_qquickpalette.cpp
index 90d850ce8a..53fa22dba5 100644
--- a/tests/auto/quick/qquickpalette/tst_qquickpalette.cpp
+++ b/tests/auto/quick/qquickpalette/tst_qquickpalette.cpp
@@ -117,8 +117,8 @@ void tst_QQuickPalette::newColorSubgroup()
anotherPalette.fromQPalette(Qt::red);
(p.*setter)((anotherPalette.*getter)());
- QCOMPARE(subgroupChanged.count(), 1);
- QCOMPARE(paletteChanged.count(), 1);
+ QCOMPARE(subgroupChanged.size(), 1);
+ QCOMPARE(paletteChanged.size(), 1);
}
}
@@ -161,7 +161,7 @@ void tst_QQuickPalette::paletteChangedWhenColorGroupChanged()
p.inactive()->setMid(Qt::green);
p.disabled()->setMid(Qt::blue);
- QCOMPARE(sp.count(), 3);
+ QCOMPARE(sp.size(), 3);
}
void tst_QQuickPalette::createDefault()
@@ -182,7 +182,7 @@ void tst_QQuickPalette::changeCurrentColorGroup()
palette.setCurrentGroup(QPalette::Disabled);
QCOMPARE(palette.currentColorGroup(), QPalette::Disabled);
- QCOMPARE(ss.count(), 1);
+ QCOMPARE(ss.size(), 1);
}
void tst_QQuickPalette::inheritColor()
@@ -266,10 +266,10 @@ void tst_QQuickPalette::createFromQtPalette()
QSignalSpy sp(&palette, &QQuickColorGroup::changed);
palette.fromQPalette(QPalette());
- QCOMPARE(sp.count(), 0);
+ QCOMPARE(sp.size(), 0);
palette.fromQPalette(somePalette);
- QCOMPARE(sp.count(), 1);
+ QCOMPARE(sp.size(), 1);
}
void tst_QQuickPalette::convertToQtPalette()
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 0d894c8581..98085002ea 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -129,6 +129,10 @@ private slots:
void objectModelMove();
void requiredPropertiesInDelegate();
void requiredPropertiesInDelegatePreventUnrelated();
+ void touchMove();
+
+private:
+ QScopedPointer<QPointingDevice> touchDevice = QScopedPointer<QPointingDevice>(QTest::createTouchDevice());
};
class TestObject : public QObject
@@ -207,7 +211,7 @@ void tst_QQuickPathView::items()
QCOMPARE(pathview->count(), model.count());
QCOMPARE(window->rootObject()->property("count").toInt(), model.count());
- QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight
+ QCOMPARE(pathview->childItems().size(), model.count()+1); // assumes all are visible, including highlight
for (int i = 0; i < model.count(); ++i) {
QQuickText *name = findItem<QQuickText>(pathview, "textName", i);
@@ -677,7 +681,7 @@ void tst_QQuickPathView::consecutiveModelChanges()
else
pathview->setOffset(4);
- for (int i=0; i<changes.count(); i++) {
+ for (int i=0; i<changes.size(); i++) {
switch (changes[i].type) {
case ListChange::Inserted:
{
@@ -705,7 +709,7 @@ void tst_QQuickPathView::consecutiveModelChanges()
}
QQuickTest::qWaitForPolish(pathview);
- QCOMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), count);
+ QCOMPARE(findItems<QQuickItem>(pathview, "wrapper").size(), count);
QCOMPARE(pathview->count(), count);
QTRY_COMPARE(pathview->offset(), offset);
@@ -808,7 +812,7 @@ void tst_QQuickPathView::dataModel()
QTest::qWait(100);
QCOMPARE(window->rootObject()->property("viewCount").toInt(), model.count());
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 14);
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").size(), 14);
QCOMPARE(pathview->currentIndex(), 0);
QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 0));
@@ -828,7 +832,7 @@ void tst_QQuickPathView::dataModel()
QMetaObject::invokeMethod(window->rootObject(), "checkProperties");
QVERIFY(!testObject->error());
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").size(), 5);
QQuickRectangle *testItem = findItem<QQuickRectangle>(pathview, "wrapper", 4);
QVERIFY(testItem != nullptr);
@@ -841,7 +845,7 @@ void tst_QQuickPathView::dataModel()
model.insertItem(2, "pink", "2");
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").size(), 5);
QCOMPARE(pathview->currentIndex(), 1);
QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
@@ -849,14 +853,14 @@ void tst_QQuickPathView::dataModel()
QCOMPARE(text->text(), model.name(2));
model.removeItem(3);
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").size(), 5);
text = findItem<QQuickText>(pathview, "myText", 3);
QVERIFY(text);
QCOMPARE(text->text(), model.name(3));
QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
model.moveItem(3, 5);
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").size(), 5);
QList<QQuickItem*> items = findItems<QQuickItem>(pathview, "wrapper");
foreach (QQuickItem *item, items) {
QVERIFY(item->property("onPath").toBool());
@@ -866,7 +870,7 @@ void tst_QQuickPathView::dataModel()
// QTBUG-14199
pathview->setOffset(7);
pathview->setOffset(0);
- QCOMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+ QCOMPARE(findItems<QQuickItem>(pathview, "wrapper").size(), 5);
pathview->setCurrentIndex(model.count()-1);
QTRY_COMPARE(pathview->offset(), 1.0);
@@ -1117,7 +1121,7 @@ void tst_QQuickPathView::setCurrentIndex()
pathview->setSnapMode(QQuickPathView::SnapToItem);
pathview->setCurrentIndex(3);
QTRY_COMPARE(pathview->currentIndex(), 3);
- QCOMPARE(currentIndexSpy.count(), 1);
+ QCOMPARE(currentIndexSpy.size(), 1);
}
void tst_QQuickPathView::setCurrentIndexWrap()
@@ -1138,8 +1142,8 @@ void tst_QQuickPathView::setCurrentIndexWrap()
pathview->setCurrentIndex(0);
pathview->setCurrentIndex(4);
QCOMPARE(pathview->currentIndex(), 4);
- QCOMPARE(currentIndexSpy.count(), 2);
- QCOMPARE(movementStartedSpy.count(), 0);
+ QCOMPARE(currentIndexSpy.size(), 2);
+ QCOMPARE(movementStartedSpy.size(), 0);
}
void tst_QQuickPathView::resetModel()
@@ -1204,21 +1208,21 @@ void tst_QQuickPathView::propertyChanges()
QCOMPARE(pathView->preferredHighlightEnd(), 0.4);
QCOMPARE(pathView->dragMargin(), 20.0);
- QCOMPARE(snapPositionSpy.count(), 1);
- QCOMPARE(dragMarginSpy.count(), 1);
+ QCOMPARE(snapPositionSpy.size(), 1);
+ QCOMPARE(dragMarginSpy.size(), 1);
pathView->setPreferredHighlightBegin(0.4);
pathView->setPreferredHighlightEnd(0.4);
pathView->setDragMargin(20.0);
- QCOMPARE(snapPositionSpy.count(), 1);
- QCOMPARE(dragMarginSpy.count(), 1);
+ QCOMPARE(snapPositionSpy.size(), 1);
+ QCOMPARE(dragMarginSpy.size(), 1);
QSignalSpy maximumFlickVelocitySpy(pathView, SIGNAL(maximumFlickVelocityChanged()));
pathView->setMaximumFlickVelocity(1000);
- QCOMPARE(maximumFlickVelocitySpy.count(), 1);
+ QCOMPARE(maximumFlickVelocitySpy.size(), 1);
pathView->setMaximumFlickVelocity(1000);
- QCOMPARE(maximumFlickVelocitySpy.count(), 1);
+ QCOMPARE(maximumFlickVelocitySpy.size(), 1);
}
@@ -1246,14 +1250,14 @@ void tst_QQuickPathView::pathChanges()
QCOMPARE(path->startX(), 240.0);
QCOMPARE(path->startY(), 220.0);
- QCOMPARE(startXSpy.count(),1);
- QCOMPARE(startYSpy.count(),1);
+ QCOMPARE(startXSpy.size(),1);
+ QCOMPARE(startYSpy.size(),1);
path->setStartX(240);
path->setStartY(220);
- QCOMPARE(startXSpy.count(),1);
- QCOMPARE(startYSpy.count(),1);
+ QCOMPARE(startXSpy.size(),1);
+ QCOMPARE(startYSpy.size(),1);
QQuickPath *alternatePath = window->rootObject()->findChild<QQuickPath*>("alternatePath");
QVERIFY(alternatePath);
@@ -1264,10 +1268,10 @@ void tst_QQuickPathView::pathChanges()
pathView->setPath(alternatePath);
QCOMPARE(pathView->path(), alternatePath);
- QCOMPARE(pathSpy.count(),1);
+ QCOMPARE(pathSpy.size(),1);
pathView->setPath(alternatePath);
- QCOMPARE(pathSpy.count(),1);
+ QCOMPARE(pathSpy.size(),1);
QQuickPathAttribute *pathAttribute = window->rootObject()->findChild<QQuickPathAttribute*>("pathAttribute");
QVERIFY(pathAttribute);
@@ -1277,10 +1281,10 @@ void tst_QQuickPathView::pathChanges()
pathAttribute->setName("scale");
QCOMPARE(pathAttribute->name(), QString("scale"));
- QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(nameSpy.size(),1);
pathAttribute->setName("scale");
- QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(nameSpy.size(),1);
}
void tst_QQuickPathView::componentChanges()
@@ -1299,10 +1303,10 @@ void tst_QQuickPathView::componentChanges()
pathView->setDelegate(&delegateComponent);
QCOMPARE(pathView->delegate(), &delegateComponent);
- QCOMPARE(delegateSpy.count(),1);
+ QCOMPARE(delegateSpy.size(),1);
pathView->setDelegate(&delegateComponent);
- QCOMPARE(delegateSpy.count(),1);
+ QCOMPARE(delegateSpy.size(),1);
}
void tst_QQuickPathView::modelChanges()
@@ -1325,17 +1329,17 @@ void tst_QQuickPathView::modelChanges()
QCOMPARE(pathView->currentIndex(), 3);
pathView->setModel(modelVariant);
QCOMPARE(pathView->model(), modelVariant);
- QCOMPARE(modelSpy.count(),1);
+ QCOMPARE(modelSpy.size(),1);
QCOMPARE(pathView->currentIndex(), 0);
- QCOMPARE(currentIndexSpy.count(), 1);
+ QCOMPARE(currentIndexSpy.size(), 1);
pathView->setModel(modelVariant);
- QCOMPARE(modelSpy.count(),1);
+ QCOMPARE(modelSpy.size(),1);
pathView->setModel(QVariant());
- QCOMPARE(modelSpy.count(),2);
+ QCOMPARE(modelSpy.size(),2);
QCOMPARE(pathView->currentIndex(), 0);
- QCOMPARE(currentIndexSpy.count(), 1);
+ QCOMPARE(currentIndexSpy.size(), 1);
}
@@ -1519,12 +1523,12 @@ void tst_QQuickPathView::mouseDrag()
// first move beyond threshold does not trigger drag
QVERIFY(!pathview->isMoving());
QVERIFY(!pathview->isDragging());
- QCOMPARE(movingSpy.count(), 0);
- QCOMPARE(moveStartedSpy.count(), 0);
- QCOMPARE(moveEndedSpy.count(), 0);
- QCOMPARE(draggingSpy.count(), 0);
- QCOMPARE(dragStartedSpy.count(), 0);
- QCOMPARE(dragEndedSpy.count(), 0);
+ QCOMPARE(movingSpy.size(), 0);
+ QCOMPARE(moveStartedSpy.size(), 0);
+ QCOMPARE(moveEndedSpy.size(), 0);
+ QCOMPARE(draggingSpy.size(), 0);
+ QCOMPARE(dragStartedSpy.size(), 0);
+ QCOMPARE(dragEndedSpy.size(), 0);
{
QMouseEvent mv(QEvent::MouseMove, QPoint(90,100), window->mapToGlobal(QPoint(90,100)),
@@ -1538,23 +1542,23 @@ void tst_QQuickPathView::mouseDrag()
#endif // Q_OS_WIN
QVERIFY(pathview->isMoving());
QVERIFY(pathview->isDragging());
- QCOMPARE(movingSpy.count(), 1);
- QCOMPARE(moveStartedSpy.count(), 1);
- QCOMPARE(moveEndedSpy.count(), 0);
- QCOMPARE(draggingSpy.count(), 1);
- QCOMPARE(dragStartedSpy.count(), 1);
- QCOMPARE(dragEndedSpy.count(), 0);
+ QCOMPARE(movingSpy.size(), 1);
+ QCOMPARE(moveStartedSpy.size(), 1);
+ QCOMPARE(moveEndedSpy.size(), 0);
+ QCOMPARE(draggingSpy.size(), 1);
+ QCOMPARE(dragStartedSpy.size(), 1);
+ QCOMPARE(dragEndedSpy.size(), 0);
QVERIFY(pathview->currentIndex() != current);
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(40,100));
QVERIFY(!pathview->isDragging());
- QCOMPARE(draggingSpy.count(), 2);
- QCOMPARE(dragStartedSpy.count(), 1);
- QCOMPARE(dragEndedSpy.count(), 1);
- QTRY_COMPARE(movingSpy.count(), 2);
- QTRY_COMPARE(moveEndedSpy.count(), 1);
- QCOMPARE(moveStartedSpy.count(), 1);
+ QCOMPARE(draggingSpy.size(), 2);
+ QCOMPARE(dragStartedSpy.size(), 1);
+ QCOMPARE(dragEndedSpy.size(), 1);
+ QTRY_COMPARE(movingSpy.size(), 2);
+ QTRY_COMPARE(moveEndedSpy.size(), 1);
+ QCOMPARE(moveStartedSpy.size(), 1);
}
@@ -1613,30 +1617,30 @@ void tst_QQuickPathView::flickNClick() // QTBUG-77173
// Dragging the child mouse area should animate the PathView (MA has no drag target)
flick(window.data(), QPoint(199,199), QPoint(399,199), duration);
QVERIFY(pathview->isMoving());
- QCOMPARE(movingChangedSpy.count(), 1);
- QCOMPARE(draggingSpy.count(), 2);
- QCOMPARE(dragStartedSpy.count(), 1);
- QCOMPARE(dragEndedSpy.count(), 1);
- QVERIFY(currentIndexSpy.count() > 0);
- QCOMPARE(moveStartedSpy.count(), 1);
- QCOMPARE(moveEndedSpy.count(), 0);
- QCOMPARE(flickingSpy.count(), 1);
- QCOMPARE(flickStartedSpy.count(), 1);
- QCOMPARE(flickEndedSpy.count(), 0);
+ QCOMPARE(movingChangedSpy.size(), 1);
+ QCOMPARE(draggingSpy.size(), 2);
+ QCOMPARE(dragStartedSpy.size(), 1);
+ QCOMPARE(dragEndedSpy.size(), 1);
+ QVERIFY(currentIndexSpy.size() > 0);
+ QCOMPARE(moveStartedSpy.size(), 1);
+ QCOMPARE(moveEndedSpy.size(), 0);
+ QCOMPARE(flickingSpy.size(), 1);
+ QCOMPARE(flickStartedSpy.size(), 1);
+ QCOMPARE(flickEndedSpy.size(), 0);
// Now while it's still moving, click it.
// The PathView should stop at a position such that offset is a whole number.
QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(200, 200));
QTRY_VERIFY(!pathview->isMoving());
- QCOMPARE(movingChangedSpy.count(), 2); // QTBUG-78926
- QCOMPARE(draggingSpy.count(), 2);
- QCOMPARE(dragStartedSpy.count(), 1);
- QCOMPARE(dragEndedSpy.count(), 1);
- QCOMPARE(moveStartedSpy.count(), 1);
- QCOMPARE(moveEndedSpy.count(), 1);
- QCOMPARE(flickingSpy.count(), 2);
- QCOMPARE(flickStartedSpy.count(), 1);
- QCOMPARE(flickEndedSpy.count(), 1);
+ QCOMPARE(movingChangedSpy.size(), 2); // QTBUG-78926
+ QCOMPARE(draggingSpy.size(), 2);
+ QCOMPARE(dragStartedSpy.size(), 1);
+ QCOMPARE(dragEndedSpy.size(), 1);
+ QCOMPARE(moveStartedSpy.size(), 1);
+ QCOMPARE(moveEndedSpy.size(), 1);
+ QCOMPARE(flickingSpy.size(), 2);
+ QCOMPARE(flickStartedSpy.size(), 1);
+ QCOMPARE(flickEndedSpy.size(), 1);
QVERIFY(qFuzzyIsNull(pathview->offset() - int(pathview->offset())));
}
}
@@ -1758,7 +1762,7 @@ void tst_QQuickPathView::currentOffsetOnInsertion()
model.insertItem(0, "item1", "1");
qApp->processEvents();
- QCOMPARE(currentIndexSpy.count(), 1);
+ QCOMPARE(currentIndexSpy.size(), 1);
// currentIndex is now 1
item = findItem<QQuickRectangle>(pathview, "wrapper", 1);
@@ -1771,7 +1775,7 @@ void tst_QQuickPathView::currentOffsetOnInsertion()
model.insertItem(0, "item2", "2");
qApp->processEvents();
- QCOMPARE(currentIndexSpy.count(), 2);
+ QCOMPARE(currentIndexSpy.size(), 2);
// currentIndex is now 2
item = findItem<QQuickRectangle>(pathview, "wrapper", 2);
@@ -1784,7 +1788,7 @@ void tst_QQuickPathView::currentOffsetOnInsertion()
model.removeItem(0);
qApp->processEvents();
- QCOMPARE(currentIndexSpy.count(), 3);
+ QCOMPARE(currentIndexSpy.size(), 3);
// currentIndex is now 1
item = findItem<QQuickRectangle>(pathview, "wrapper", 1);
@@ -1892,9 +1896,9 @@ void tst_QQuickPathView::cancelDrag()
QTRY_VERIFY(hasFraction(pathview->offset()));
QTRY_VERIFY(pathview->isMoving());
QVERIFY(pathview->isDragging());
- QCOMPARE(draggingSpy.count(), 1);
- QCOMPARE(dragStartedSpy.count(), 1);
- QCOMPARE(dragEndedSpy.count(), 0);
+ QCOMPARE(draggingSpy.size(), 1);
+ QCOMPARE(dragStartedSpy.size(), 1);
+ QCOMPARE(dragEndedSpy.size(), 0);
// steal mouse grab - cancels PathView dragging
auto mouse = QPointingDevice::primaryPointingDevice();
@@ -1907,9 +1911,9 @@ void tst_QQuickPathView::cancelDrag()
QTRY_COMPARE(pathview->offset(), qreal(qFloor(pathview->offset())));
QTRY_VERIFY(!pathview->isMoving());
QVERIFY(!pathview->isDragging());
- QCOMPARE(draggingSpy.count(), 2);
- QCOMPARE(dragStartedSpy.count(), 1);
- QCOMPARE(dragEndedSpy.count(), 1);
+ QCOMPARE(draggingSpy.size(), 2);
+ QCOMPARE(dragStartedSpy.size(), 1);
+ QCOMPARE(dragEndedSpy.size(), 1);
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(40,100));
}
@@ -2017,7 +2021,7 @@ void tst_QQuickPathView::snapOneItem()
QSignalSpy snapModeSpy(pathview, SIGNAL(snapModeChanged()));
window->rootObject()->setProperty("snapOne", true);
- QCOMPARE(snapModeSpy.count(), 1);
+ QCOMPARE(snapModeSpy.size(), 1);
QTRY_VERIFY(!pathview->isMoving()); // ensure stable
int currentIndex = pathview->currentIndex();
@@ -2298,22 +2302,22 @@ void tst_QQuickPathView::nestedinFlickable()
// first move beyond threshold does not trigger drag
QVERIFY(!pathview->isMoving());
QVERIFY(!pathview->isDragging());
- QCOMPARE(movingSpy.count(), 0);
- QCOMPARE(moveStartedSpy.count(), 0);
- QCOMPARE(moveEndedSpy.count(), 0);
- QCOMPARE(fflickingSpy.count(), 0);
- QCOMPARE(fflickStartedSpy.count(), 0);
- QCOMPARE(fflickEndedSpy.count(), 0);
+ QCOMPARE(movingSpy.size(), 0);
+ QCOMPARE(moveStartedSpy.size(), 0);
+ QCOMPARE(moveEndedSpy.size(), 0);
+ QCOMPARE(fflickingSpy.size(), 0);
+ QCOMPARE(fflickStartedSpy.size(), 0);
+ QCOMPARE(fflickEndedSpy.size(), 0);
// no further moves after the initial move beyond threshold
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(73,219));
- QTRY_COMPARE(movingSpy.count(), 2);
- QTRY_COMPARE(moveEndedSpy.count(), 1);
- QCOMPARE(moveStartedSpy.count(), 1);
+ QTRY_COMPARE(movingSpy.size(), 2);
+ QTRY_COMPARE(moveEndedSpy.size(), 1);
+ QCOMPARE(moveStartedSpy.size(), 1);
// Flickable should not handle this
- QCOMPARE(fflickingSpy.count(), 0);
- QCOMPARE(fflickStartedSpy.count(), 0);
- QCOMPARE(fflickEndedSpy.count(), 0);
+ QCOMPARE(fflickingSpy.size(), 0);
+ QCOMPARE(fflickStartedSpy.size(), 0);
+ QCOMPARE(fflickEndedSpy.size(), 0);
// now test that two quick flicks are both handled by the pathview
movingSpy.clear();
@@ -2347,25 +2351,25 @@ void tst_QQuickPathView::nestedinFlickable()
// we allow the multiple signal count case, rather than simply:
// QTRY_COMPARE(moveEndedSpy.count(), 1);
// QCOMPARE(moveStartedSpy.count(), 1);
- QTRY_VERIFY(moveEndedSpy.count() > 0);
+ QTRY_VERIFY(moveEndedSpy.size() > 0);
qCDebug(lcTests) << "After receiving moveEnded signal:"
- << "moveEndedSpy.count():" << moveEndedSpy.count()
- << "moveStartedSpy.count():" << moveStartedSpy.count()
- << "fflickingSpy.count():" << fflickingSpy.count()
- << "fflickStartedSpy.count():" << fflickStartedSpy.count()
- << "fflickEndedSpy.count():" << fflickEndedSpy.count();
- QTRY_COMPARE(moveStartedSpy.count(), moveEndedSpy.count());
+ << "moveEndedSpy.count():" << moveEndedSpy.size()
+ << "moveStartedSpy.count():" << moveStartedSpy.size()
+ << "fflickingSpy.count():" << fflickingSpy.size()
+ << "fflickStartedSpy.count():" << fflickStartedSpy.size()
+ << "fflickEndedSpy.count():" << fflickEndedSpy.size();
+ QTRY_COMPARE(moveStartedSpy.size(), moveEndedSpy.size());
qCDebug(lcTests) << "After receiving matched moveEnded signal(s):"
- << "moveEndedSpy.count():" << moveEndedSpy.count()
- << "moveStartedSpy.count():" << moveStartedSpy.count()
- << "fflickingSpy.count():" << fflickingSpy.count()
- << "fflickStartedSpy.count():" << fflickStartedSpy.count()
- << "fflickEndedSpy.count():" << fflickEndedSpy.count();
- QVERIFY(moveStartedSpy.count() <= 2);
+ << "moveEndedSpy.count():" << moveEndedSpy.size()
+ << "moveStartedSpy.count():" << moveStartedSpy.size()
+ << "fflickingSpy.count():" << fflickingSpy.size()
+ << "fflickStartedSpy.count():" << fflickStartedSpy.size()
+ << "fflickEndedSpy.count():" << fflickEndedSpy.size();
+ QVERIFY(moveStartedSpy.size() <= 2);
// Flickable should not handle this
- QCOMPARE(fflickingSpy.count(), 0);
- QCOMPARE(fflickStartedSpy.count(), 0);
- QCOMPARE(fflickEndedSpy.count(), 0);
+ QCOMPARE(fflickingSpy.size(), 0);
+ QCOMPARE(fflickStartedSpy.size(), 0);
+ QCOMPARE(fflickEndedSpy.size(), 0);
}
@@ -2436,22 +2440,22 @@ void tst_QQuickPathView::flickableDelegate()
// first move beyond threshold does not trigger drag
QVERIFY(!flickable->isMoving());
QVERIFY(!flickable->isDragging());
- QCOMPARE(movingSpy.count(), 0);
- QCOMPARE(moveStartedSpy.count(), 0);
- QCOMPARE(moveEndedSpy.count(), 0);
- QCOMPARE(fflickingSpy.count(), 0);
- QCOMPARE(fflickStartedSpy.count(), 0);
- QCOMPARE(fflickEndedSpy.count(), 0);
+ QCOMPARE(movingSpy.size(), 0);
+ QCOMPARE(moveStartedSpy.size(), 0);
+ QCOMPARE(moveEndedSpy.size(), 0);
+ QCOMPARE(fflickingSpy.size(), 0);
+ QCOMPARE(fflickStartedSpy.size(), 0);
+ QCOMPARE(fflickEndedSpy.size(), 0);
// no further moves after the initial move beyond threshold
QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(53,100));
- QTRY_COMPARE(fflickingSpy.count(), 2);
- QTRY_COMPARE(fflickStartedSpy.count(), 1);
- QCOMPARE(fflickEndedSpy.count(), 1);
+ QTRY_COMPARE(fflickingSpy.size(), 2);
+ QTRY_COMPARE(fflickStartedSpy.size(), 1);
+ QCOMPARE(fflickEndedSpy.size(), 1);
// PathView should not handle this
- QTRY_COMPARE(movingSpy.count(), 0);
- QTRY_COMPARE(moveEndedSpy.count(), 0);
- QCOMPARE(moveStartedSpy.count(), 0);
+ QTRY_COMPARE(movingSpy.size(), 0);
+ QTRY_COMPARE(moveEndedSpy.size(), 0);
+ QCOMPARE(moveStartedSpy.size(), 0);
}
void tst_QQuickPathView::jsArrayChange()
@@ -2474,11 +2478,11 @@ void tst_QQuickPathView::jsArrayChange()
}
view->setModel(QVariant::fromValue(array1));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// no change
view->setModel(QVariant::fromValue(array2));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QQuickPathView::qtbug37815()
@@ -2688,7 +2692,7 @@ void tst_QQuickPathView::objectModelMove()
QVector<QString> itemObjectNames;
itemObjectNames << QLatin1String("red") << QLatin1String("green") << QLatin1String("blue");
QVector<QQuickItem*> childItems;
- for (const QString &itemObjectName : qAsConst(itemObjectNames)) {
+ for (const QString &itemObjectName : std::as_const(itemObjectNames)) {
QQuickItem *childItem = findItem<QQuickItem>(pathView, itemObjectName);
QVERIFY(childItem);
childItems.append(childItem);
@@ -2701,7 +2705,7 @@ void tst_QQuickPathView::objectModelMove()
QTRY_VERIFY(pathView.isNull());
// By this point, all of its cached items should have been released,
// which means none of the items should have any listeners.
- for (const auto childItem : qAsConst(childItems)) {
+ for (const auto childItem : std::as_const(childItems)) {
const QQuickItemPrivate *childItemPrivate = QQuickItemPrivate::get(childItem);
QCOMPARE(childItemPrivate->changeListeners.size(), 0);
}
@@ -2741,6 +2745,112 @@ void tst_QQuickPathView::requiredPropertiesInDelegatePreventUnrelated()
window->show();
}
+void tst_QQuickPathView::touchMove()
+{
+ QScopedPointer<QQuickView> window(createView());
+ QQuickVisualTestUtils::moveMouseAway(window.data());
+ window->setSource(testFileUrl("dragpath.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject());
+ QVERIFY(pathview != nullptr);
+
+ QSignalSpy movingSpy(pathview, SIGNAL(movingChanged()));
+ QSignalSpy moveStartedSpy(pathview, SIGNAL(movementStarted()));
+ QSignalSpy moveEndedSpy(pathview, SIGNAL(movementEnded()));
+ QSignalSpy draggingSpy(pathview, SIGNAL(draggingChanged()));
+ QSignalSpy dragStartedSpy(pathview, SIGNAL(dragStarted()));
+ QSignalSpy dragEndedSpy(pathview, SIGNAL(dragEnded()));
+ QSignalSpy flickStartedSpy(pathview, SIGNAL(flickStarted()));
+ QSignalSpy flickEndedSpy(pathview, SIGNAL(flickEnded()));
+
+ int current = pathview->currentIndex();
+
+ // touch move from left to right
+ QPoint from(250, 100);
+ QPoint to(10, 100);
+
+ QTest::touchEvent(window.data(), touchDevice.data()).press(0, from, window.data());
+ QQuickTouchUtils::flush(window.data());
+
+ QVERIFY(!pathview->isMoving());
+ QVERIFY(!pathview->isDragging());
+ QCOMPARE(movingSpy.size(), 0);
+ QCOMPARE(moveStartedSpy.size(), 0);
+ QCOMPARE(moveEndedSpy.size(), 0);
+ QCOMPARE(draggingSpy.size(), 0);
+ QCOMPARE(dragStartedSpy.size(), 0);
+ QCOMPARE(dragEndedSpy.size(), 0);
+ QCOMPARE(flickStartedSpy.size(), 0);
+ QCOMPARE(flickEndedSpy.size(), 0);
+
+ from -= QPoint(QGuiApplication::styleHints()->startDragDistance() + 1, 0);
+ QTest::touchEvent(window.data(), touchDevice.data()).move(0, from, window.data());
+ QQuickTouchUtils::flush(window.data());
+
+ // first move does not trigger move/drag
+ QVERIFY(!pathview->isMoving());
+ QVERIFY(!pathview->isDragging());
+ QCOMPARE(movingSpy.size(), 0);
+ QCOMPARE(moveStartedSpy.size(), 0);
+ QCOMPARE(moveEndedSpy.size(), 0);
+ QCOMPARE(draggingSpy.size(), 0);
+ QCOMPARE(dragStartedSpy.size(), 0);
+ QCOMPARE(dragEndedSpy.size(), 0);
+ QCOMPARE(flickStartedSpy.size(), 0);
+ QCOMPARE(flickEndedSpy.size(), 0);
+
+ QPoint diff = from - to;
+ int moveCount = 4;
+ for (int i = 1; i <= moveCount; ++i) {
+ QTest::touchEvent(window.data(), touchDevice.data()).move(0, from - i * diff / moveCount, window.data());
+ QQuickTouchUtils::flush(window.data());
+
+ QVERIFY(pathview->isMoving());
+ QVERIFY(pathview->isDragging());
+ QCOMPARE(movingSpy.size(), 1);
+ QCOMPARE(moveStartedSpy.size(), 1);
+ QCOMPARE(moveEndedSpy.size(), 0);
+ QCOMPARE(draggingSpy.size(), 1);
+ QCOMPARE(dragStartedSpy.size(), 1);
+ QCOMPARE(dragEndedSpy.size(), 0);
+ QCOMPARE(flickStartedSpy.size(), 0);
+ QCOMPARE(flickEndedSpy.size(), 0);
+ }
+ QVERIFY(pathview->currentIndex() != current);
+
+ QTest::touchEvent(window.data(), touchDevice.data()).release(0, to, window.data());
+ QQuickTouchUtils::flush(window.data());
+
+ QVERIFY(pathview->isMoving());
+ QVERIFY(!pathview->isDragging());
+ QCOMPARE(movingSpy.size(), 1);
+ QCOMPARE(moveStartedSpy.size(), 1);
+ QCOMPARE(moveEndedSpy.size(), 0);
+ QCOMPARE(draggingSpy.size(), 2);
+ QCOMPARE(dragStartedSpy.size(), 1);
+ QCOMPARE(dragEndedSpy.size(), 1);
+ QCOMPARE(flickStartedSpy.size(), 1);
+ QCOMPARE(flickEndedSpy.size(), 0);
+
+ // Wait for the flick to finish
+ QVERIFY(QTest::qWaitFor([&]()
+ { return !pathview->isFlicking(); }
+ ));
+ QVERIFY(!pathview->isMoving());
+ QVERIFY(!pathview->isDragging());
+ QCOMPARE(movingSpy.size(), 2);
+ QCOMPARE(moveStartedSpy.size(), 1);
+ QCOMPARE(moveEndedSpy.size(), 1);
+ QCOMPARE(draggingSpy.size(), 2);
+ QCOMPARE(dragStartedSpy.size(), 1);
+ QCOMPARE(dragEndedSpy.size(), 1);
+ QCOMPARE(flickStartedSpy.size(), 1);
+ QCOMPARE(flickEndedSpy.size(), 1);
+
+}
+
QTEST_MAIN(tst_QQuickPathView)
#include "tst_qquickpathview.moc"
diff --git a/tests/auto/quick/qquickpincharea/data/pinchAreaInPathView.qml b/tests/auto/quick/qquickpincharea/data/pinchAreaInPathView.qml
new file mode 100644
index 0000000000..dc909c2c7c
--- /dev/null
+++ b/tests/auto/quick/qquickpincharea/data/pinchAreaInPathView.qml
@@ -0,0 +1,48 @@
+import QtQuick
+
+PathView {
+ width: 600
+ height: 200
+
+ model: 3
+ delegate: Rectangle {
+ width: 200
+ height: 200
+ color: "salmon"
+ opacity: PathView.isCurrentItem ? 1 : 0.5
+
+ property alias pinchArea: pinchArea
+
+ Text {
+ text: "Test"
+ font.pixelSize: 100
+ anchors.fill: parent
+ fontSizeMode: Text.Fit
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ PinchArea {
+ id: pinchArea
+ anchors.fill: parent
+ pinch.target: parent
+ pinch.dragAxis: Pinch.XAndYAxis
+ pinch.minimumScale: 1.0
+ pinch.maximumScale: 5.0
+
+ onPinchFinished: (pinch) => {
+ parent.scale = 1
+ parent.x = 0
+ parent.y = 0
+ }
+ }
+ }
+ path: Path {
+ startX: 100
+ startY: 100
+ PathLine {
+ x: 700
+ y: 100
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
index d23f804690..800d7211fb 100644
--- a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
+++ b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
@@ -1,6 +1,7 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#include <QtCore/private/qvariantanimation_p.h>
#include <QtTest/QtTest>
#include <QtTest/QSignalSpy>
#include <QtGui/QStyleHints>
@@ -8,6 +9,7 @@
#include <QtGui/private/qeventpoint_p.h>
#include <qpa/qwindowsysteminterface.h>
#include <private/qquickpincharea_p.h>
+#include <QtQuick/private/qquickpathview_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuick/qquickview.h>
#include <QtQml/qqmlcontext.h>
@@ -30,6 +32,8 @@ private slots:
void transformedPinchArea();
void dragTransformedPinchArea_data();
void dragTransformedPinchArea();
+ void pinchAreaKeepsDragInView();
+ void pinchInPathView();
private:
QQuickView *createView();
@@ -60,18 +64,18 @@ void tst_QQuickPinchArea::pinchProperties()
QVERIFY(rootItem != nullptr);
QSignalSpy targetSpy(pinch, SIGNAL(targetChanged()));
pinch->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
+ QCOMPARE(targetSpy.size(),1);
pinch->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
+ QCOMPARE(targetSpy.size(),1);
// axis
QCOMPARE(pinch->axis(), QQuickPinch::XAndYAxis);
QSignalSpy axisSpy(pinch, SIGNAL(dragAxisChanged()));
pinch->setAxis(QQuickPinch::XAxis);
QCOMPARE(pinch->axis(), QQuickPinch::XAxis);
- QCOMPARE(axisSpy.count(),1);
+ QCOMPARE(axisSpy.size(),1);
pinch->setAxis(QQuickPinch::XAxis);
- QCOMPARE(axisSpy.count(),1);
+ QCOMPARE(axisSpy.size(),1);
// minimum and maximum drag properties
QSignalSpy xminSpy(pinch, SIGNAL(minimumXChanged()));
@@ -94,20 +98,20 @@ void tst_QQuickPinchArea::pinchProperties()
QCOMPARE(pinch->ymin(), 10.0);
QCOMPARE(pinch->ymax(), 10.0);
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
+ QCOMPARE(xminSpy.size(),1);
+ QCOMPARE(xmaxSpy.size(),1);
+ QCOMPARE(yminSpy.size(),1);
+ QCOMPARE(ymaxSpy.size(),1);
pinch->setXmin(10);
pinch->setXmax(10);
pinch->setYmin(10);
pinch->setYmax(10);
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
+ QCOMPARE(xminSpy.size(),1);
+ QCOMPARE(xmaxSpy.size(),1);
+ QCOMPARE(yminSpy.size(),1);
+ QCOMPARE(ymaxSpy.size(),1);
// minimum and maximum scale properties
QSignalSpy scaleMinSpy(pinch, SIGNAL(minimumScaleChanged()));
@@ -122,14 +126,14 @@ void tst_QQuickPinchArea::pinchProperties()
QCOMPARE(pinch->minimumScale(), 0.5);
QCOMPARE(pinch->maximumScale(), 1.5);
- QCOMPARE(scaleMinSpy.count(),1);
- QCOMPARE(scaleMaxSpy.count(),1);
+ QCOMPARE(scaleMinSpy.size(),1);
+ QCOMPARE(scaleMaxSpy.size(),1);
pinch->setMinimumScale(0.5);
pinch->setMaximumScale(1.5);
- QCOMPARE(scaleMinSpy.count(),1);
- QCOMPARE(scaleMaxSpy.count(),1);
+ QCOMPARE(scaleMinSpy.size(),1);
+ QCOMPARE(scaleMaxSpy.size(),1);
// minimum and maximum rotation properties
QSignalSpy rotMinSpy(pinch, SIGNAL(minimumRotationChanged()));
@@ -144,14 +148,14 @@ void tst_QQuickPinchArea::pinchProperties()
QCOMPARE(pinch->minimumRotation(), -90.0);
QCOMPARE(pinch->maximumRotation(), 45.0);
- QCOMPARE(rotMinSpy.count(),1);
- QCOMPARE(rotMaxSpy.count(),1);
+ QCOMPARE(rotMinSpy.size(),1);
+ QCOMPARE(rotMaxSpy.size(),1);
pinch->setMinimumRotation(-90.0);
pinch->setMaximumRotation(45.0);
- QCOMPARE(rotMinSpy.count(),1);
- QCOMPARE(rotMaxSpy.count(),1);
+ QCOMPARE(rotMinSpy.size(),1);
+ QCOMPARE(rotMaxSpy.size(),1);
}
QEventPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickItem *i)
@@ -384,7 +388,7 @@ void tst_QQuickPinchArea::retouch()
pinchSequence.move(0, p1,window).move(1, p2,window).commit();
QQuickTouchUtils::flush(window);
- QCOMPARE(startedSpy.count(), 1);
+ QCOMPARE(startedSpy.size(), 1);
QCOMPARE(root->property("scale").toReal(), 1.5);
QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
@@ -392,15 +396,15 @@ void tst_QQuickPinchArea::retouch()
QCOMPARE(window->rootObject()->property("pointCount").toInt(), 2);
- QCOMPARE(startedSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(startedSpy.size(), 1);
+ QCOMPARE(finishedSpy.size(), 0);
// Hold down the first finger but release the second one
pinchSequence.stationary(0).release(1, p2, window).commit();
QQuickTouchUtils::flush(window);
- QCOMPARE(startedSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(startedSpy.size(), 1);
+ QCOMPARE(finishedSpy.size(), 0);
QCOMPARE(window->rootObject()->property("pointCount").toInt(), 1);
@@ -413,8 +417,8 @@ void tst_QQuickPinchArea::retouch()
QQuickTouchUtils::flush(window);
// Lifting and retouching results in onPinchStarted being called again
- QCOMPARE(startedSpy.count(), 2);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(startedSpy.size(), 2);
+ QCOMPARE(finishedSpy.size(), 0);
QCOMPARE(window->rootObject()->property("pointCount").toInt(), 2);
@@ -422,8 +426,8 @@ void tst_QQuickPinchArea::retouch()
QQuickTouchUtils::flush(window);
QVERIFY(!root->property("pinchActive").toBool());
- QCOMPARE(startedSpy.count(), 2);
- QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(startedSpy.size(), 2);
+ QCOMPARE(finishedSpy.size(), 1);
}
}
@@ -618,6 +622,147 @@ void tst_QQuickPinchArea::dragTransformedPinchArea() // QTBUG-63673
QCOMPARE(pinchArea->pinch()->active(), false);
}
+template<typename F>
+void forEachLerpStep(int steps, F &&func)
+{
+ for (int i = 0; i < steps; ++i) {
+ const qreal t = qreal(i) / steps;
+ func(t);
+ }
+}
+
+QPoint lerpPoints(const QPoint &point1, const QPoint &point2, qreal t)
+{
+ return QPoint(_q_interpolate(point1.x(), point2.x(), t), _q_interpolate(point1.y(), point2.y(), t));
+};
+
+// QTBUG-105058
+void tst_QQuickPinchArea::pinchAreaKeepsDragInView()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("pinchAreaInPathView.qml"));
+ QVERIFY(view.rootObject());
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ QQuickPathView *pathView = qobject_cast<QQuickPathView*>(view.rootObject());
+ QVERIFY(pathView);
+ QCOMPARE(pathView->count(), 3);
+
+ const QQuickItem *pinchDelegateItem = pathView->itemAtIndex(0);
+ QQuickPinchArea *pinchArea = pinchDelegateItem->property("pinchArea").value<QQuickPinchArea*>();
+ QVERIFY(pinchArea);
+
+ // Press.
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&view, device);
+ QPoint point1Start = { 80, 120 };
+ QPoint point2Start = { 120, 80 };
+ const int dragThreshold = qApp->styleHints()->startDragDistance();
+ pinchSequence.press(1, pinchArea->mapToScene(point1Start).toPoint(), &view)
+ .press(2, pinchArea->mapToScene(point2Start).toPoint(), &view).commit();
+ QQuickTouchUtils::flush(&view);
+
+ // Move past the drag threshold to begin the pinch.
+ const int steps = 30;
+ QPoint point1End = point1Start + QPoint(-dragThreshold, dragThreshold);
+ QPoint point2End = point2Start + QPoint(dragThreshold, -dragThreshold);
+ forEachLerpStep(steps, [&](qreal t) {
+ pinchSequence.move(1, lerpPoints(point1Start, point1End, t), &view)
+ .move(2, lerpPoints(point2Start, point2End, t), &view).commit();
+ QQuickTouchUtils::flush(&view);
+ QTest::qWait(5);
+ });
+ QCOMPARE(pinchArea->pinch()->active(), true);
+ QVERIFY2(pinchDelegateItem->scale() > 1.0, qPrintable(QString::number(pinchDelegateItem->scale())));
+ // The PathView contents shouldn't have moved.
+ QCOMPARE(pathView->offset(), 0);
+
+ // Release a touch point.
+ pinchSequence.stationary(1).release(2, point2End, &view).commit();
+ QQuickTouchUtils::flush(&view);
+
+ // Press it again.
+ pinchSequence.stationary(1).press(2, point2End, &view).commit();
+ QQuickTouchUtils::flush(&view);
+ QCOMPARE(pinchArea->pinch()->active(), true);
+
+ // Drag to the right; the PathView still shouldn't move.
+ point1Start = point1End;
+ point2Start = point2End;
+ point1End = point1Start + QPoint(100, 0);
+ point2End = point2Start + QPoint(100, 0);
+ forEachLerpStep(steps, [&](qreal t) {
+ pinchSequence.move(1, lerpPoints(point1Start, point1End, t), &view)
+ .move(2, lerpPoints(point2Start, point2End, t), &view).commit();
+ QQuickTouchUtils::flush(&view);
+ QTest::qWait(5);
+ });
+ QCOMPARE(pinchArea->pinch()->active(), true);
+ QVERIFY2(pinchDelegateItem->scale() > 1.0, qPrintable(QString::number(pinchDelegateItem->scale())));
+ QCOMPARE(pathView->offset(), 0);
+
+ // Release pinch.
+ pinchSequence.release(1, point1End, &view).release(2, point2End, &view).commit();
+ QQuickTouchUtils::flush(&view);
+ QCOMPARE(pinchArea->pinch()->active(), false);
+ QCOMPARE(pathView->offset(), 0);
+}
+
+void tst_QQuickPinchArea::pinchInPathView()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("pinchAreaInPathView.qml"));
+ QVERIFY(view.rootObject());
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ QQuickPathView *pathView = qobject_cast<QQuickPathView*>(view.rootObject());
+ QVERIFY(pathView);
+ QCOMPARE(pathView->count(), 3);
+
+ const QQuickItem *pinchDelegateItem = pathView->itemAtIndex(0);
+ QQuickPinchArea *pinchArea = pinchDelegateItem->property("pinchArea").value<QQuickPinchArea*>();
+ QVERIFY(pinchArea);
+
+ // press
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&view, device);
+ QPoint point1Start = { 10, 10 };
+ QPoint point2Start = { 100, 100 };
+ const int dragThreshold = qApp->styleHints()->startDragDistance();
+ pinchSequence.press(0, point1Start, &view)
+ .press(1, point2Start, &view)
+ .commit();
+ QQuickTouchUtils::flush(&view);
+ QTest::qWait(20);
+
+ // move
+ QPoint moveDistance = QPoint(dragThreshold * 3, dragThreshold * 3);
+ QPoint point2End = point2Start + moveDistance;
+ pinchSequence.stationary(0)
+ .move(1, point2End, &view)
+ .commit();
+ QQuickTouchUtils::flush(&view);
+ QTest::qWait(20);
+
+ point2End += moveDistance;
+ pinchSequence.stationary(0)
+ .move(1, point2End, &view)
+ .commit();
+ QQuickTouchUtils::flush(&view);
+ QTest::qWait(20);
+
+ QCOMPARE(pinchArea->pinch()->active(), true);
+ QVERIFY2(pinchDelegateItem->scale() > 1.0, qPrintable(QString::number(pinchDelegateItem->scale())));
+ // PathView shouldn't have moved.
+ QCOMPARE(pathView->offset(), 0);
+
+ // release pinch.
+ pinchSequence.release(0, point1Start, &view).release(1, point2End, &view).commit();
+ QQuickTouchUtils::flush(&view);
+ QCOMPARE(pinchArea->pinch()->active(), false);
+ QCOMPARE(pathView->offset(), 0);
+}
+
QQuickView *tst_QQuickPinchArea::createView()
{
QQuickView *window = new QQuickView(nullptr);
diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
index dbcb502653..590f022e4e 100644
--- a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
+++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
@@ -203,7 +203,7 @@ void tst_qquickpixmapcache::parallel()
QList<bool> pending;
QList<Slotter*> getters;
- for (int i=0; i<targets.count(); ++i) {
+ for (int i=0; i<targets.size(); ++i) {
QUrl target = targets.at(i);
QQuickPixmap *pixmap = new QQuickPixmap;
@@ -223,9 +223,9 @@ void tst_qquickpixmapcache::parallel()
}
}
- if (incache + slotters != targets.count())
+ if (incache + slotters != targets.size())
QFAIL(QString::fromLatin1("pixmap counts don't add up: %1 incache, %2 slotters, %3 total")
- .arg(incache).arg(slotters).arg(targets.count()).toLatin1().constData());
+ .arg(incache).arg(slotters).arg(targets.size()).toLatin1().constData());
if (cancel >= 0) {
pixmaps.at(cancel)->clear(getters[cancel]);
@@ -237,7 +237,7 @@ void tst_qquickpixmapcache::parallel()
QVERIFY(!QTestEventLoop::instance().timeout());
}
- for (int i=0; i<targets.count(); ++i) {
+ for (int i=0; i<targets.size(); ++i) {
QQuickPixmap *pixmap = pixmaps[i];
if (i == cancel) {
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
index ab8e83b488..317694f06c 100644
--- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -1149,7 +1149,7 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
targetItems = findItems<QQuickItem>(positioner, "wrapper", targetIndexes);
- QTRY_COMPARE(window->rootObject()->property("addTransitionsDone").toInt(), targetData.count());
+ QTRY_COMPARE(window->rootObject()->property("addTransitionsDone").toInt(), targetData.size());
QTRY_COMPARE(window->rootObject()->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.count());
// check the target and displaced items were animated
@@ -1262,9 +1262,9 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
// check attached properties
- QCOMPARE(window->rootObject()->property("targetTrans_items").toMap().count(), 0);
- QCOMPARE(window->rootObject()->property("targetTrans_targetIndexes").toList().count(), 0);
- QCOMPARE(window->rootObject()->property("targetTrans_targetItems").toList().count(), 0);
+ QCOMPARE(window->rootObject()->property("targetTrans_items").toMap().size(), 0);
+ QCOMPARE(window->rootObject()->property("targetTrans_targetIndexes").toList().size(), 0);
+ QCOMPARE(window->rootObject()->property("targetTrans_targetItems").toList().size(), 0);
if (expectedDisplacedIndexes.isValid()) {
// adjust expectedDisplacedIndexes to their final values after the move
QList<int> displacedIndexes;
@@ -1279,12 +1279,12 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
matchItemsAndIndexes(window->rootObject()->property("displacedTrans_items").toMap(), model, displacedIndexes);
QVariantList listOfEmptyIntLists;
- for (int i=0; i<displacedIndexes.count(); i++)
+ for (int i=0; i<displacedIndexes.size(); i++)
listOfEmptyIntLists << QVariant::fromValue(QList<int>());
QCOMPARE(window->rootObject()->property("displacedTrans_targetIndexes").toList(), listOfEmptyIntLists);
QVariantList listOfEmptyObjectLists;
- for (int i=0; i<displacedIndexes.count(); i++)
- listOfEmptyObjectLists.insert(listOfEmptyObjectLists.count(), QVariantList());
+ for (int i=0; i<displacedIndexes.size(); i++)
+ listOfEmptyObjectLists.insert(listOfEmptyObjectLists.size(), QVariantList());
QCOMPARE(window->rootObject()->property("displacedTrans_targetItems").toList(), listOfEmptyObjectLists);
}
@@ -2938,37 +2938,37 @@ void tst_qquickpositioners::test_propertychanges()
grid->setMove(rowTransition);
QCOMPARE(grid->add(), rowTransition);
QCOMPARE(grid->move(), rowTransition);
- QCOMPARE(addSpy.count(),1);
- QCOMPARE(moveSpy.count(),1);
+ QCOMPARE(addSpy.size(),1);
+ QCOMPARE(moveSpy.size(),1);
grid->setAdd(rowTransition);
grid->setMove(rowTransition);
- QCOMPARE(addSpy.count(),1);
- QCOMPARE(moveSpy.count(),1);
+ QCOMPARE(addSpy.size(),1);
+ QCOMPARE(moveSpy.size(),1);
grid->setAdd(nullptr);
grid->setMove(nullptr);
- QCOMPARE(addSpy.count(),2);
- QCOMPARE(moveSpy.count(),2);
+ QCOMPARE(addSpy.size(),2);
+ QCOMPARE(moveSpy.size(),2);
grid->setColumns(-1);
grid->setRows(3);
QCOMPARE(grid->columns(), -1);
QCOMPARE(grid->rows(), 3);
- QCOMPARE(columnsSpy.count(),1);
- QCOMPARE(rowsSpy.count(),1);
+ QCOMPARE(columnsSpy.size(),1);
+ QCOMPARE(rowsSpy.size(),1);
grid->setColumns(-1);
grid->setRows(3);
- QCOMPARE(columnsSpy.count(),1);
- QCOMPARE(rowsSpy.count(),1);
+ QCOMPARE(columnsSpy.size(),1);
+ QCOMPARE(rowsSpy.size(),1);
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*QML Grid: Grid contains more visible items \\(20\\) than rows\\*columns \\(6\\)"));
grid->setColumns(2);
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*QML Grid: Grid contains more visible items \\(20\\) than rows\\*columns \\(4\\)"));
grid->setRows(2);
- QCOMPARE(columnsSpy.count(),2);
- QCOMPARE(rowsSpy.count(),2);
+ QCOMPARE(columnsSpy.size(),2);
+ QCOMPARE(rowsSpy.size(),2);
}
@@ -4012,7 +4012,7 @@ QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait
void tst_qquickpositioners::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
{
const QSet<int> expectedIndexSet(expectedIndexes.cbegin(), expectedIndexes.cend());
- for (int i=0; i<indexLists.count(); i++) {
+ for (int i=0; i<indexLists.size(); i++) {
const auto &currentList = indexLists[i].value<QList<int> >();
const QSet<int> current(currentList.cbegin(), currentList.cend());
if (current != expectedIndexSet)
@@ -4032,20 +4032,20 @@ void tst_qquickpositioners::matchItemsAndIndexes(const QVariantMap &items, const
qDebug() << itemIndex;
QCOMPARE(model.name(itemIndex), name);
}
- QCOMPARE(items.count(), expectedIndexes.count());
+ QCOMPARE(items.size(), expectedIndexes.size());
}
void tst_qquickpositioners::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
{
- for (int i=0; i<itemLists.count(); i++) {
+ for (int i=0; i<itemLists.size(); i++) {
QCOMPARE(itemLists[i].typeId(), QMetaType::QVariantList);
QVariantList current = itemLists[i].toList();
- for (int j=0; j<current.count(); j++) {
+ for (int j=0; j<current.size(); j++) {
QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
}
- QCOMPARE(current.count(), expectedItems.count());
+ QCOMPARE(current.size(), expectedItems.size());
}
}
diff --git a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
index 644e698647..d5520de682 100644
--- a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
+++ b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
@@ -75,7 +75,7 @@ void tst_qquickrectangle::gradient()
QCOMPARE(stops.at(&stops, 1)->color(), QColor("white"));
QGradientStops gradientStops = grad->gradientStops();
- QCOMPARE(gradientStops.count(), 2);
+ QCOMPARE(gradientStops.size(), 2);
QCOMPARE(gradientStops.at(0).first, 0.0);
QCOMPARE(gradientStops.at(0).second, QColor("gray"));
QCOMPARE(gradientStops.at(1).first, 1.0);
@@ -189,46 +189,46 @@ void tst_qquickrectangle::antialiasing()
rect->setAntialiasing(true);
QCOMPARE(rect->antialiasing(), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
rect->setAntialiasing(true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
rect->resetAntialiasing();
QCOMPARE(rect->antialiasing(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
rect->setRadius(5);
QCOMPARE(rect->antialiasing(), true);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
rect->resetAntialiasing();
QCOMPARE(rect->antialiasing(), true);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
rect->setRadius(0);
QCOMPARE(rect->antialiasing(), false);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
rect->resetAntialiasing();
QCOMPARE(rect->antialiasing(), false);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
rect->setRadius(5);
QCOMPARE(rect->antialiasing(), true);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
rect->resetAntialiasing();
QCOMPARE(rect->antialiasing(), true);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
rect->setAntialiasing(false);
QCOMPARE(rect->antialiasing(), false);
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
rect->resetAntialiasing();
QCOMPARE(rect->antialiasing(), true);
- QCOMPARE(spy.count(), 7);
+ QCOMPARE(spy.size(), 7);
}
QTEST_MAIN(tst_qquickrectangle)
diff --git a/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp b/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp
index b1cc9563eb..2d56312f9d 100644
--- a/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp
+++ b/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp
@@ -388,7 +388,7 @@ void tst_RenderControl::renderAndReadBackWithVulkanNative()
f->vkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueCount, queueFamilyProps.data());
int gfxQueueFamilyIdx = -1;
- for (int i = 0; i < queueFamilyProps.count(); ++i) {
+ for (int i = 0; i < queueFamilyProps.size(); ++i) {
if (queueFamilyProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
gfxQueueFamilyIdx = i;
break;
diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
index befa16b632..5a6498a5d7 100644
--- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
+++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
@@ -106,7 +106,7 @@ void tst_QQuickRepeater::numberModel()
QQuickRepeater *repeater = findItem<QQuickRepeater>(window->rootObject(), "repeater");
QVERIFY(repeater != nullptr);
- QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
+ QCOMPARE(repeater->parentItem()->childItems().size(), 5+1);
QVERIFY(!repeater->itemAt(-1));
for (int i=0; i<repeater->count(); i++)
@@ -117,10 +117,10 @@ void tst_QQuickRepeater::numberModel()
QVERIFY(!testObject->error());
ctxt->setContextProperty("testData", std::numeric_limits<int>::max());
- QCOMPARE(repeater->parentItem()->childItems().count(), 1);
+ QCOMPARE(repeater->parentItem()->childItems().size(), 1);
ctxt->setContextProperty("testData", -1234);
- QCOMPARE(repeater->parentItem()->childItems().count(), 1);
+ QCOMPARE(repeater->parentItem()->childItems().size(), 1);
delete testObject;
delete window;
@@ -166,15 +166,15 @@ void tst_QQuickRepeater::objectList()
QCOMPARE(repeater->property("instantiated").toInt(), 100);
QVERIFY(!repeater->itemAt(-1));
- for (int i=0; i<data.count(); i++)
+ for (int i=0; i<data.size(); i++)
QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i));
- QVERIFY(!repeater->itemAt(data.count()));
+ QVERIFY(!repeater->itemAt(data.size()));
QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
ctxt->setContextProperty("testData", QVariant::fromValue(data));
- QCOMPARE(addedSpy.count(), data.count());
- QCOMPARE(removedSpy.count(), data.count());
+ QCOMPARE(addedSpy.size(), data.size());
+ QCOMPARE(removedSpy.size(), data.size());
qDeleteAll(data);
delete window;
@@ -207,22 +207,22 @@ void tst_QQuickRepeater::stringList()
QQuickItem *container = findItem<QQuickItem>(window->rootObject(), "container");
QVERIFY(container != nullptr);
- QCOMPARE(container->childItems().count(), data.count() + 3);
+ QCOMPARE(container->childItems().size(), data.size() + 3);
bool saw_repeater = false;
- for (int i = 0; i < container->childItems().count(); ++i) {
+ for (int i = 0; i < container->childItems().size(); ++i) {
if (i == 0) {
QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
QVERIFY(name != nullptr);
QCOMPARE(name->text(), QLatin1String("Zero"));
- } else if (i == container->childItems().count() - 2) {
+ } else if (i == container->childItems().size() - 2) {
// The repeater itself
QQuickRepeater *rep = qobject_cast<QQuickRepeater*>(container->childItems().at(i));
QCOMPARE(rep, repeater);
saw_repeater = true;
continue;
- } else if (i == container->childItems().count() - 1) {
+ } else if (i == container->childItems().size() - 1) {
QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
QVERIFY(name != nullptr);
QCOMPARE(name->text(), QLatin1String("Last"));
@@ -262,8 +262,8 @@ void tst_QQuickRepeater::dataModel_adding()
// add to empty model
testModel.addItem("two", "2");
QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(countSpy.size(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.size(), 1);
QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(0));
addedSpy.clear();
@@ -271,8 +271,8 @@ void tst_QQuickRepeater::dataModel_adding()
// insert at start
testModel.insertItem(0, "one", "1");
QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(countSpy.size(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.size(), 1);
QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(0));
addedSpy.clear();
@@ -280,8 +280,8 @@ void tst_QQuickRepeater::dataModel_adding()
// insert at end
testModel.insertItem(2, "four", "4");
QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(countSpy.size(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.size(), 1);
QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(2));
addedSpy.clear();
@@ -289,8 +289,8 @@ void tst_QQuickRepeater::dataModel_adding()
// insert in middle
testModel.insertItem(2, "three", "3");
QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(countSpy.size(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.size(), 1);
QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(2));
addedSpy.clear();
@@ -300,8 +300,8 @@ void tst_QQuickRepeater::dataModel_adding()
QList<QPair<QString, QString> > multiData;
multiData << qMakePair(QStringLiteral("five"), QStringLiteral("5")) << qMakePair(QStringLiteral("six"), QStringLiteral("6")) << qMakePair(QStringLiteral("seven"), QStringLiteral("7"));
testModel.insertItems(1, multiData);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(addedSpy.count(), 3);
+ QCOMPARE(countSpy.size(), 1);
+ QCOMPARE(addedSpy.size(), 3);
QCOMPARE(container->childItems().size(), childItemsSize + 3);
QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
addedSpy.clear();
@@ -335,7 +335,7 @@ void tst_QQuickRepeater::dataModel_removing()
QVERIFY(repeater != nullptr);
QQuickItem *container = findItem<QQuickItem>(window->rootObject(), "container");
QVERIFY(container != nullptr);
- QCOMPARE(container->childItems().count(), repeater->count()+1);
+ QCOMPARE(container->childItems().size(), repeater->count()+1);
QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
@@ -346,8 +346,8 @@ void tst_QQuickRepeater::dataModel_removing()
testModel.removeItem(0);
QVERIFY(repeater->itemAt(0) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
+ QCOMPARE(countSpy.size(), 1); countSpy.clear();
+ QCOMPARE(removedSpy.size(), 1);
QCOMPARE(removedSpy.at(0).at(0).toInt(), 0);
QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
removedSpy.clear();
@@ -359,8 +359,8 @@ void tst_QQuickRepeater::dataModel_removing()
testModel.removeItem(lastIndex);
QVERIFY(repeater->itemAt(lastIndex) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
+ QCOMPARE(countSpy.size(), 1); countSpy.clear();
+ QCOMPARE(removedSpy.size(), 1);
QCOMPARE(removedSpy.at(0).at(0).toInt(), lastIndex);
QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
removedSpy.clear();
@@ -371,8 +371,8 @@ void tst_QQuickRepeater::dataModel_removing()
testModel.removeItem(1);
QVERIFY(repeater->itemAt(lastIndex) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
+ QCOMPARE(countSpy.size(), 1); countSpy.clear();
+ QCOMPARE(removedSpy.size(), 1);
QCOMPARE(removedSpy.at(0).at(0).toInt(), 1);
QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
removedSpy.clear();
@@ -401,7 +401,7 @@ void tst_QQuickRepeater::dataModel_changes()
QVERIFY(repeater != nullptr);
QQuickItem *container = findItem<QQuickItem>(window->rootObject(), "container");
QVERIFY(container != nullptr);
- QCOMPARE(container->childItems().count(), repeater->count()+1);
+ QCOMPARE(container->childItems().size(), repeater->count()+1);
// Check that model changes are propagated
QQuickText *text = findItem<QQuickText>(window->rootObject(), "myName", 1);
@@ -437,7 +437,7 @@ void tst_QQuickRepeater::itemModel()
QQuickItem *container = findItem<QQuickItem>(window->rootObject(), "container");
QVERIFY(container != nullptr);
- QCOMPARE(container->childItems().count(), 1);
+ QCOMPARE(container->childItems().size(), 1);
testObject->setUseModel(true);
QMetaObject::invokeMethod(window->rootObject(), "checkProperties");
@@ -450,20 +450,20 @@ void tst_QQuickRepeater::itemModel()
window->dumpObjectTree();
}
- QCOMPARE(container->childItems().count(), 4);
+ QCOMPARE(container->childItems().size(), 4);
QCOMPARE(qobject_cast<QObject*>(container->childItems().at(0))->objectName(), QLatin1String("item1"));
QCOMPARE(qobject_cast<QObject*>(container->childItems().at(1))->objectName(), QLatin1String("item2"));
QCOMPARE(qobject_cast<QObject*>(container->childItems().at(2))->objectName(), QLatin1String("item3"));
QCOMPARE(container->childItems().at(3), repeater);
QMetaObject::invokeMethod(window->rootObject(), "switchModel");
- QCOMPARE(container->childItems().count(), 3);
+ QCOMPARE(container->childItems().size(), 3);
QCOMPARE(qobject_cast<QObject*>(container->childItems().at(0))->objectName(), QLatin1String("item4"));
QCOMPARE(qobject_cast<QObject*>(container->childItems().at(1))->objectName(), QLatin1String("item5"));
QCOMPARE(container->childItems().at(2), repeater);
testObject->setUseModel(false);
- QCOMPARE(container->childItems().count(), 1);
+ QCOMPARE(container->childItems().size(), 1);
delete testObject;
delete window;
@@ -486,7 +486,7 @@ void tst_QQuickRepeater::resetModel()
QQuickItem *container = findItem<QQuickItem>(window->rootObject(), "container");
QVERIFY(container != nullptr);
- QCOMPARE(repeater->count(), dataA.count());
+ QCOMPARE(repeater->count(), dataA.size());
for (int i=0; i<repeater->count(); i++)
QCOMPARE(repeater->itemAt(i), container->childItems().at(i+1)); // +1 to skip first Text object
@@ -501,13 +501,13 @@ void tst_QQuickRepeater::resetModel()
// reset context property
ctxt->setContextProperty("testData", dataB);
- QCOMPARE(repeater->count(), dataB.count());
+ QCOMPARE(repeater->count(), dataB.size());
- QCOMPARE(modelChangedSpy.count(), 1);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(removedSpy.count(), dataA.count());
- QCOMPARE(addedSpy.count(), dataB.count());
- for (int i=0; i<dataB.count(); i++) {
+ QCOMPARE(modelChangedSpy.size(), 1);
+ QCOMPARE(countSpy.size(), 1);
+ QCOMPARE(removedSpy.size(), dataA.size());
+ QCOMPARE(addedSpy.size(), dataB.size());
+ for (int i=0; i<dataB.size(); i++) {
QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
}
@@ -518,13 +518,13 @@ void tst_QQuickRepeater::resetModel()
// reset via setModel()
repeater->setModel(dataA);
- QCOMPARE(repeater->count(), dataA.count());
+ QCOMPARE(repeater->count(), dataA.size());
- QCOMPARE(modelChangedSpy.count(), 1);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(removedSpy.count(), dataB.count());
- QCOMPARE(addedSpy.count(), dataA.count());
- for (int i=0; i<dataA.count(); i++) {
+ QCOMPARE(modelChangedSpy.size(), 1);
+ QCOMPARE(countSpy.size(), 1);
+ QCOMPARE(removedSpy.size(), dataB.size());
+ QCOMPARE(addedSpy.size(), dataA.size());
+ for (int i=0; i<dataA.size(); i++) {
QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
}
@@ -551,12 +551,12 @@ void tst_QQuickRepeater::modelChanged()
repeater->setModel(4);
QCOMPARE(repeater->count(), 4);
QCOMPARE(repeater->property("itemsCount").toInt(), 4);
- QCOMPARE(repeater->property("itemsFound").toList().count(), 4);
+ QCOMPARE(repeater->property("itemsFound").toList().size(), 4);
repeater->setModel(10);
QCOMPARE(repeater->count(), 10);
QCOMPARE(repeater->property("itemsCount").toInt(), 10);
- QCOMPARE(repeater->property("itemsFound").toList().count(), 10);
+ QCOMPARE(repeater->property("itemsFound").toList().size(), 10);
delete rootObject;
}
@@ -593,10 +593,10 @@ void tst_QQuickRepeater::modelReset()
model.resetItems(items);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(removedSpy.count(), 0);
- QCOMPARE(addedSpy.count(), items.count());
- for (int i = 0; i< items.count(); i++) {
+ QCOMPARE(countSpy.size(), 1);
+ QCOMPARE(removedSpy.size(), 0);
+ QCOMPARE(addedSpy.size(), items.size());
+ for (int i = 0; i< items.size(); i++) {
QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
}
@@ -605,10 +605,10 @@ void tst_QQuickRepeater::modelReset()
addedSpy.clear();
model.reset();
- QCOMPARE(countSpy.count(), 0);
- QCOMPARE(removedSpy.count(), 3);
- QCOMPARE(addedSpy.count(), 3);
- for (int i = 0; i< items.count(); i++) {
+ QCOMPARE(countSpy.size(), 0);
+ QCOMPARE(removedSpy.size(), 3);
+ QCOMPARE(addedSpy.size(), 3);
+ for (int i = 0; i< items.size(); i++) {
QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
}
@@ -620,10 +620,10 @@ void tst_QQuickRepeater::modelReset()
items.append(qMakePair(QString::fromLatin1("five"), QString::fromLatin1("5")));
model.resetItems(items);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(removedSpy.count(), 3);
- QCOMPARE(addedSpy.count(), 5);
- for (int i = 0; i< items.count(); i++) {
+ QCOMPARE(countSpy.size(), 1);
+ QCOMPARE(removedSpy.size(), 3);
+ QCOMPARE(addedSpy.size(), 5);
+ for (int i = 0; i< items.size(); i++) {
QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
}
@@ -634,9 +634,9 @@ void tst_QQuickRepeater::modelReset()
items.clear();
model.resetItems(items);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(removedSpy.count(), 5);
- QCOMPARE(addedSpy.count(), 0);
+ QCOMPARE(countSpy.size(), 1);
+ QCOMPARE(removedSpy.size(), 5);
+ QCOMPARE(addedSpy.size(), 0);
}
// QTBUG-46828
@@ -672,9 +672,9 @@ void tst_QQuickRepeater::properties()
QSignalSpy modelSpy(repeater, SIGNAL(modelChanged()));
repeater->setModel(3);
- QCOMPARE(modelSpy.count(),1);
+ QCOMPARE(modelSpy.size(),1);
repeater->setModel(3);
- QCOMPARE(modelSpy.count(),1);
+ QCOMPARE(modelSpy.size(),1);
QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged()));
@@ -682,9 +682,9 @@ void tst_QQuickRepeater::properties()
rectComponent.setData("import QtQuick 2.0; Rectangle {}", QUrl::fromLocalFile(""));
repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
+ QCOMPARE(delegateSpy.size(),1);
repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
+ QCOMPARE(delegateSpy.size(),1);
delete rootObject;
}
@@ -805,7 +805,7 @@ void tst_QQuickRepeater::invalidContextCrash()
engine.rootContext()->setContextProperty("badModel", model);
QScopedPointer<QObject> root(component.create());
- QCOMPARE(root->children().count(), 1);
+ QCOMPARE(root->children().size(), 1);
QObject *repeater = root->children().first();
// Make sure the model comes first in the child list, so it will be
@@ -815,7 +815,7 @@ void tst_QQuickRepeater::invalidContextCrash()
repeater->setParent(nullptr);
repeater->setParent(root.data());
- QCOMPARE(root->children().count(), 2);
+ QCOMPARE(root->children().size(), 2);
QCOMPARE(root->children().at(0), model);
QCOMPARE(root->children().at(1), repeater);
@@ -844,11 +844,11 @@ void tst_QQuickRepeater::jsArrayChange()
}
repeater->setModel(QVariant::fromValue(array1));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// no change
repeater->setModel(QVariant::fromValue(array2));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QQuickRepeater::clearRemovalOrder()
@@ -876,7 +876,7 @@ void tst_QQuickRepeater::clearRemovalOrder()
// we should have 0 items, and 3 removal signals.
QCOMPARE(repeater->count(), 0);
- QCOMPARE(removedSpy.count(), 3);
+ QCOMPARE(removedSpy.size(), 3);
// column 1 is for the items, we won't bother verifying these. just look at
// the indices and make sure they're sane.
diff --git a/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp
index 64547108b8..ccdf69facf 100644
--- a/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp
+++ b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp
@@ -50,7 +50,7 @@ void tst_qquickscreen::basicProperties()
QCOMPARE(screen->geometry().x(), root->property("vx").toInt());
QCOMPARE(screen->geometry().y(), root->property("vy").toInt());
- QVERIFY(root->property("screenCount").toInt() == QGuiApplication::screens().count());
+ QVERIFY(root->property("screenCount").toInt() == QGuiApplication::screens().size());
}
void tst_qquickscreen::screenOnStartup()
@@ -89,7 +89,7 @@ void tst_qquickscreen::fullScreenList()
QVERIFY(screensArray.isArray());
int length = screensArray.property("length").toInt();
const QList<QScreen *> screenList = QGuiApplication::screens();
- QVERIFY(length == screenList.count());
+ QVERIFY(length == screenList.size());
for (int i = 0; i < length; ++i) {
QQuickScreenInfo *info = qobject_cast<QQuickScreenInfo *>(screensArray.property(i).toQObject());
diff --git a/tests/auto/quick/qquickshape/tst_qquickshape.cpp b/tests/auto/quick/qquickshape/tst_qquickshape.cpp
index 4da77cd35b..a9e15939d3 100644
--- a/tests/auto/quick/qquickshape/tst_qquickshape.cpp
+++ b/tests/auto/quick/qquickshape/tst_qquickshape.cpp
@@ -204,7 +204,7 @@ void tst_QQuickShape::changeSignals()
QSignalSpy asyncPropSpy(obj, SIGNAL(asynchronousChanged()));
obj->setAsynchronous(true);
obj->setAsynchronous(false);
- QCOMPARE(asyncPropSpy.count(), 2);
+ QCOMPARE(asyncPropSpy.size(), 2);
QQmlListReference list(obj, "data");
QQuickShapePath *vp = qobject_cast<QQuickShapePath *>(list.at(0));
@@ -224,29 +224,29 @@ void tst_QQuickShape::changeSignals()
vp->setCapStyle(QQuickShapePath::RoundCap);
vp->setDashOffset(10);
vp->setDashPattern(QVector<qreal>() << 1 << 2 << 3 << 4);
- QCOMPARE(strokeColorPropSpy.count(), 1);
- QCOMPARE(vpChangeSpy.count(), 10);
+ QCOMPARE(strokeColorPropSpy.size(), 1);
+ QCOMPARE(vpChangeSpy.size(), 10);
// Verify that property changes from Path and its elements bubble up and result in shapePathChanged().
QQuickPath *path = vp;
path->setStartX(30);
- QCOMPARE(vpChangeSpy.count(), 11);
+ QCOMPARE(vpChangeSpy.size(), 11);
QQmlListReference pathList(path, "pathElements");
qobject_cast<QQuickPathLine *>(pathList.at(1))->setY(200);
- QCOMPARE(vpChangeSpy.count(), 12);
+ QCOMPARE(vpChangeSpy.size(), 12);
// Verify that property changes from the gradient bubble up and result in shapePathChanged().
vp->setFillGradient(g);
- QCOMPARE(vpChangeSpy.count(), 13);
+ QCOMPARE(vpChangeSpy.size(), 13);
QQuickShapeLinearGradient *lgrad = qobject_cast<QQuickShapeLinearGradient *>(g);
lgrad->setX2(200);
- QCOMPARE(vpChangeSpy.count(), 14);
+ QCOMPARE(vpChangeSpy.size(), 14);
QQmlListReference stopList(lgrad, "stops");
QCOMPARE(stopList.count(), 5);
qobject_cast<QQuickGradientStop *>(stopList.at(1))->setPosition(0.3);
- QCOMPARE(vpChangeSpy.count(), 15);
+ QCOMPARE(vpChangeSpy.size(), 15);
qobject_cast<QQuickGradientStop *>(stopList.at(1))->setColor(Qt::black);
- QCOMPARE(vpChangeSpy.count(), 16);
+ QCOMPARE(vpChangeSpy.size(), 16);
}
void tst_QQuickShape::render()
diff --git a/tests/auto/quick/qquickstates/data/jsValueWhen2.qml b/tests/auto/quick/qquickstates/data/jsValueWhen2.qml
new file mode 100644
index 0000000000..e1f173138e
--- /dev/null
+++ b/tests/auto/quick/qquickstates/data/jsValueWhen2.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.15
+
+Item {
+ id: root
+ property var prop: null
+ property bool works: false
+ states: [
+ State {
+ name: "mystate"
+ when: root.prop
+ PropertyChanges {
+ target: root
+ works: "works"
+ }
+ }
+ ]
+ Component.onCompleted: root.prop = Qt.createQmlObject(
+ "import QtQml 2.15\nQtObject {}",
+ root, "dynamicSnippet")
+}
diff --git a/tests/auto/quick/qquickstates/data/removeBindingWithTransition.qml b/tests/auto/quick/qquickstates/data/removeBindingWithTransition.qml
new file mode 100644
index 0000000000..ed40e18374
--- /dev/null
+++ b/tests/auto/quick/qquickstates/data/removeBindingWithTransition.qml
@@ -0,0 +1,23 @@
+import QtQuick
+
+Item {
+ id: root
+ property bool toggle: true
+ property int state1Width: 500
+
+ states: [
+ State {
+ when: root.toggle
+ PropertyChanges { root.width: root.state1Width }
+ },
+ State {
+ when: !root.toggle
+ PropertyChanges { root.width: 300 }
+ }
+ ]
+
+ transitions: Transition {
+ id: transition
+ SmoothedAnimation { target: root; property: "width"; velocity: 200 }
+ }
+}
diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
index a57f186d80..44187d2b65 100644
--- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp
+++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
@@ -175,6 +175,7 @@ private slots:
void revertListMemoryLeak();
void duplicateStateName();
void trivialWhen();
+ void jsValueWhen_data();
void jsValueWhen();
void noStateOsciallation();
void parentChangeCorrectReversal();
@@ -183,6 +184,7 @@ private slots:
void parentChangeInvolvingBindings();
void deferredProperties();
void rewindAnchorChange();
+ void bindingProperlyRemovedWithTransition();
};
void tst_qquickstates::initTestCase()
@@ -1327,7 +1329,7 @@ void tst_qquickstates::illegalObjectCreation()
QQmlComponent component(&engine, testFileUrl("illegalObj.qml"));
QList<QQmlError> errors = component.errors();
- QCOMPARE(errors.count(), 1);
+ QCOMPARE(errors.size(), 1);
const QQmlError &error = errors.at(0);
QCOMPARE(error.line(), 9);
QCOMPARE(error.column(), 23);
@@ -1482,7 +1484,7 @@ void tst_qquickstates::editProperties()
rectPrivate->setState("");
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QCOMPARE(propertyChangesBlue->actions().size(), 2);
QVERIFY(propertyChangesBlue->containsValue("width"));
QVERIFY(!propertyChangesBlue->containsProperty("x"));
QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
@@ -1490,20 +1492,20 @@ void tst_qquickstates::editProperties()
propertyChangesBlue->changeValue("width", 60);
QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QCOMPARE(propertyChangesBlue->actions().size(), 2);
propertyChangesBlue->changeExpression("width", "myRectangle.width / 2");
QVERIFY(!propertyChangesBlue->containsValue("width"));
QVERIFY(propertyChangesBlue->containsExpression("width"));
QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QCOMPARE(propertyChangesBlue->actions().size(), 2);
propertyChangesBlue->changeValue("width", 50);
QVERIFY(propertyChangesBlue->containsValue("width"));
QVERIFY(!propertyChangesBlue->containsExpression("width"));
QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QCOMPARE(propertyChangesBlue->actions().size(), 2);
QVERIFY(QQmlAnyBinding::ofProperty(QQmlProperty(childRect, "width")));
rectPrivate->setState("blue");
@@ -1512,7 +1514,7 @@ void tst_qquickstates::editProperties()
propertyChangesBlue->changeValue("width", 60);
QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QCOMPARE(propertyChangesBlue->actions().size(), 2);
QCOMPARE(childRect->width(), qreal(60));
QVERIFY(!QQmlAnyBinding::ofProperty(QQmlProperty(childRect, "width")));
@@ -1520,7 +1522,7 @@ void tst_qquickstates::editProperties()
QVERIFY(!propertyChangesBlue->containsValue("width"));
QVERIFY(propertyChangesBlue->containsExpression("width"));
QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QCOMPARE(propertyChangesBlue->actions().size(), 2);
QVERIFY(QQmlAnyBinding::ofProperty(QQmlProperty(childRect, "width")));
QCOMPARE(childRect->width(), qreal(200));
@@ -1531,13 +1533,13 @@ void tst_qquickstates::editProperties()
QCOMPARE(childRect->width(), qreal(402));
QVERIFY(QQmlAnyBinding::ofProperty(QQmlProperty(childRect, "width")));
- QCOMPARE(propertyChangesGreen->actions().length(), 2);
+ QCOMPARE(propertyChangesGreen->actions().size(), 2);
rectPrivate->setState("green");
QCOMPARE(childRect->width(), qreal(200));
QCOMPARE(childRect->height(), qreal(100));
QVERIFY(QQmlAnyBinding::ofProperty(QQmlProperty(childRect, "width")));
QVERIFY(greenState->bindingInRevertList(childRect, "width"));
- QCOMPARE(propertyChangesGreen->actions().length(), 2);
+ QCOMPARE(propertyChangesGreen->actions().size(), 2);
propertyChangesGreen->removeProperty("height");
@@ -1694,11 +1696,20 @@ void tst_qquickstates::trivialWhen()
QVERIFY(root);
}
+
+void tst_qquickstates::jsValueWhen_data()
+{
+ QTest::addColumn<QByteArray>("fileName");
+ QTest::addRow("jsObject") << QByteArray("jsValueWhen.qml");
+ QTest::addRow("qmlObject") << QByteArray("jsValueWhen2.qml");
+}
+
void tst_qquickstates::jsValueWhen()
{
+ QFETCH(QByteArray, fileName);
QQmlEngine engine;
- QQmlComponent c(&engine, testFileUrl("jsValueWhen.qml"));
+ QQmlComponent c(&engine, testFileUrl(fileName.constData()));
QScopedPointer<QObject> root(c.create());
QVERIFY(root);
QVERIFY(root->property("works").toBool());
@@ -1883,10 +1894,10 @@ void tst_qquickstates::parentChangeInvolvingBindings()
QCOMPARE(root->property("childRotation").toInt(), 100);
// First change to 40 via reverse(), then to 20 via binding.
- QCOMPARE(xSpy.count(), 2);
+ QCOMPARE(xSpy.size(), 2);
// First change to 400 via reverse(), then to 200 via binding.
- QCOMPARE(widthSpy.count(), 2);
+ QCOMPARE(widthSpy.size(), 2);
QCOMPARE(root->property("childX").toInt(), 20);
QCOMPARE(root->property("childWidth").toInt(), 200);
@@ -1964,6 +1975,26 @@ void tst_qquickstates::rewindAnchorChange()
QTRY_COMPARE(innerRect->height(), 200);
}
+void tst_qquickstates::bindingProperlyRemovedWithTransition()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("removeBindingWithTransition.qml"));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> root(c.create());
+ QVERIFY(root);
+ QQuickItem *item = qobject_cast<QQuickItem *>(root.get());
+ QVERIFY(item);
+
+ item->setProperty("toggle", false);
+ QTRY_COMPARE(item->width(), 300);
+
+ item->setProperty("state1Width", 100);
+ QCOMPARE(item->width(), 300);
+
+ item->setProperty("toggle", true);
+ QTRY_COMPARE(item->width(), 100);
+}
+
QTEST_MAIN(tst_qquickstates)
#include "tst_qquickstates.moc"
diff --git a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
index 233c467201..aebd9990f7 100644
--- a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
+++ b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
@@ -130,6 +130,10 @@ void tst_qquickstyledtext::textOutput_data()
QTest::newRow("tag mix") << "<f6>ds<b></img><pro>gfh</b><w><w>ghj</stron><ql><sl><pl>dfg</j6><img><bol><r><prp>dfg<bkj></b><up><string>ewrq</al><bl>jklhj<zl>" << "dsgfhghjdfgdfgewrqjklhj" << (FormatList() << Format(Format::Bold, 2, 3)) << false;
QTest::newRow("named html entities") << "&gt; &lt; &amp; &quot; &nbsp;" << QLatin1String("> < & \" ") + QChar(QChar::Nbsp) << FormatList() << false;
QTest::newRow("invalid html entities") << "a &hello & a &goodbye;" << "a &hello & a " << FormatList() << false;
+ QTest::newRow("upper case tags 1") << "<B><I><S><U>text</U></S></I></B>" << "text" << (FormatList() << Format(Format::Bold|Format::Italic|Format::StrikeOut|Format::Underline, 0, 4)) << false;
+ QTest::newRow("upper case tags 2") << "<STRONG><DEL>text</DEL></STRONG>" << "text" << (FormatList() << Format(Format::Bold|Format::StrikeOut, 0, 4)) << false;
+ QTest::newRow("upper case font") << "<FONT COLOR=\"red\" SIZE=\"1\">text</FONT>" << "text" << (FormatList() << Format(0, 0, 4)) << true;
+ QTest::newRow("upper case entities") << "&LT;b&GT;&QUOT;this&QUOT; &AMP; that&LT;/b&GT;" << "<b>\"this\" & that</b>" << FormatList() << false;
}
void tst_qquickstyledtext::textOutput()
@@ -148,8 +152,8 @@ void tst_qquickstyledtext::textOutput()
const QVector<QTextLayout::FormatRange> layoutFormats = layout.formats();
- QCOMPARE(layoutFormats.count(), formats.count());
- for (int i = 0; i < formats.count(); ++i) {
+ QCOMPARE(layoutFormats.size(), formats.size());
+ for (int i = 0; i < formats.size(); ++i) {
QCOMPARE(layoutFormats.at(i).start, formats.at(i).start);
QCOMPARE(layoutFormats.at(i).length, formats.at(i).length);
if (formats.at(i).type & Format::Bold)
@@ -178,8 +182,8 @@ void tst_qquickstyledtext::anchors()
const QVector<QTextLayout::FormatRange> layoutFormats = layout.formats();
- QCOMPARE(layoutFormats.count(), formats.count());
- for (int i = 0; i < formats.count(); ++i) {
+ QCOMPARE(layoutFormats.size(), formats.size());
+ for (int i = 0; i < formats.size(); ++i) {
QCOMPARE(layoutFormats.at(i).start, formats.at(i).start);
QCOMPARE(layoutFormats.at(i).length, formats.at(i).length);
QVERIFY(layoutFormats.at(i).format.isAnchor() == bool(formats.at(i).type & Format::Anchor));
diff --git a/tests/auto/quick/qquicktableview/data/columnwidthboundtoviewwidth.qml b/tests/auto/quick/qquicktableview/data/columnwidthboundtoviewwidth.qml
new file mode 100644
index 0000000000..bbbdf74d4e
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/columnwidthboundtoviewwidth.qml
@@ -0,0 +1,40 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+ property Component delegate: tableViewDelegate
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ columnSpacing: 1
+ rowSpacing: 1
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ implicitWidth: tableView.width
+ implicitHeight: 50
+ objectName: "tableViewDelegate"
+ color: "lightgray"
+ border.width: 1
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/syncviewsimple.qml b/tests/auto/quick/qquicktableview/data/syncviewsimple.qml
index f0534e8440..880554b129 100644
--- a/tests/auto/quick/qquicktableview/data/syncviewsimple.qml
+++ b/tests/auto/quick/qquicktableview/data/syncviewsimple.qml
@@ -13,6 +13,9 @@ Item {
property alias tableViewV: tableViewV
property alias tableViewHV: tableViewHV
+ property real delegateWidth: 30
+ property real delegateHeight: 60
+
Column {
spacing: 10
TableView {
@@ -57,7 +60,7 @@ Item {
height: 100
anchors.margins: 1
clip: true
- delegate: tableViewDelegate
+ delegate: tableViewDelegateMainView
columnSpacing: 1
rowSpacing: 1
@@ -70,10 +73,27 @@ Item {
id: tableViewDelegate
Rectangle {
objectName: "tableViewDelegate"
+ color: "lightblue"
+ border.width: 1
+ implicitWidth: 100
+ implicitHeight: 100
+
+ Text {
+ anchors.centerIn: parent
+ font.pixelSize: 10
+ text: parent.TableView.view.objectName + "\n" + column + ", " + row
+ }
+ }
+ }
+
+ Component {
+ id: tableViewDelegateMainView
+ Rectangle {
+ objectName: "tableViewDelegate"
color: "lightgray"
border.width: 1
- implicitWidth: 30
- implicitHeight: 60
+ implicitWidth: delegateWidth
+ implicitHeight: delegateHeight
Text {
anchors.centerIn: parent
diff --git a/tests/auto/quick/qquicktableview/data/tableviewinteractive.qml b/tests/auto/quick/qquicktableview/data/tableviewinteractive.qml
new file mode 100644
index 0000000000..526313dc24
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/tableviewinteractive.qml
@@ -0,0 +1,32 @@
+import QtQuick
+import QtQuick.Controls
+
+Item {
+ id: rootItem
+
+ width: 200
+ height: 200
+ visible: true
+
+ property int eventCount: 0
+ property alias tableView: tableView
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: function(mouse) {
+ ++eventCount
+ }
+ }
+
+ TableView {
+ id: tableView
+ objectName: "tableView"
+ anchors.fill: parent
+ model: 1
+ delegate: Rectangle {
+ color: "red"
+ implicitWidth: 200
+ implicitHeight: 200
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
index eeaf95068f..176b9cb603 100644
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -90,6 +90,7 @@ private slots:
void checkColumnWidthProviderInvalidReturnValues();
void checkColumnWidthProviderNegativeReturnValue();
void checkColumnWidthProviderNotCallable();
+ void checkColumnWidthBoundToViewWidth();
void checkRowHeightWithoutProvider();
void checkRowHeightProvider();
void checkRowHeightProviderInvalidReturnValues();
@@ -155,10 +156,12 @@ private slots:
void checkSyncView_childViews_data();
void checkSyncView_childViews();
void checkSyncView_differentSizedModels();
+ void checkSyncView_differentGeometry();
void checkSyncView_connect_late_data();
void checkSyncView_connect_late();
void checkSyncView_pageFlicking();
void checkSyncView_emptyModel();
+ void checkSyncView_topLeftChanged();
void delegateWithRequiredProperties();
void checkThatFetchMoreIsCalledWhenScrolledToTheEndOfTable();
void replaceModel();
@@ -215,6 +218,7 @@ private slots:
void testDeprecatedApi();
void alternatingRows();
void boundDelegateComponent();
+ void tableViewInteractive();
};
tst_QQuickTableView::tst_QQuickTableView()
@@ -284,8 +288,9 @@ void tst_QQuickTableView::emptyModel()
LOAD_TABLEVIEW("plaintableview.qml");
tableView->setModel(model);
- WAIT_UNTIL_POLISHED;
- QCOMPARE(tableViewPrivate->loadedItems.count(), 0);
+ if (QQuickTest::qIsPolishScheduled(tableView))
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableViewPrivate->loadedItems.size(), 0);
}
void tst_QQuickTableView::checkPreload_data()
@@ -504,6 +509,27 @@ void tst_QQuickTableView::checkColumnWidthProviderNotCallable()
QCOMPARE(fxItem->item->width(), kDefaultColumnWidth);
}
+void tst_QQuickTableView::checkColumnWidthBoundToViewWidth()
+{
+ // Check that you can bind the width of a delegate to the
+ // width of TableView, and that it updates when TableView is resized.
+ LOAD_TABLEVIEW("columnwidthboundtoviewwidth.qml");
+
+ auto model = TestModelAsVariant(10, 1);
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems)
+ QCOMPARE(fxItem->item->width(), tableView->width());
+
+ tableView->setWidth(200);
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems)
+ QCOMPARE(fxItem->item->width(), 200);
+}
+
void tst_QQuickTableView::checkRowHeightWithoutProvider()
{
// Checks that a function isn't assigned to the rowHeightProvider property
@@ -2680,6 +2706,18 @@ void tst_QQuickTableView::checkSyncView_rootView()
QCOMPARE(tableViewVPrivate->loadedTableOuterRect.left(), 0);
QCOMPARE(tableViewHVPrivate->loadedTableOuterRect, tableViewPrivate->loadedTableOuterRect);
+
+ // Check that the column widths are in sync
+ for (int column = tableView->leftColumn(); column < tableView->rightColumn(); ++column) {
+ QCOMPARE(tableViewH->columnWidth(column), tableView->columnWidth(column));
+ QCOMPARE(tableViewHV->columnWidth(column), tableView->columnWidth(column));
+ }
+
+ // Check that the row heights are in sync
+ for (int row = tableView->topRow(); row < tableView->bottomRow(); ++row) {
+ QCOMPARE(tableViewV->rowHeight(row), tableView->rowHeight(row));
+ QCOMPARE(tableViewHV->rowHeight(row), tableView->rowHeight(row));
+ }
}
void tst_QQuickTableView::checkSyncView_childViews_data()
@@ -2785,6 +2823,18 @@ void tst_QQuickTableView::checkSyncView_childViews()
QCOMPARE(tableViewHVPrivate->bottomRow(), tableViewPrivate->bottomRow());
QCOMPARE(tableViewHVPrivate->loadedTableOuterRect, tableViewPrivate->loadedTableOuterRect);
}
+
+ // Check that the column widths are in sync
+ for (int column = tableView->leftColumn(); column < tableView->rightColumn(); ++column) {
+ QCOMPARE(tableViewH->columnWidth(column), tableView->columnWidth(column));
+ QCOMPARE(tableViewHV->columnWidth(column), tableView->columnWidth(column));
+ }
+
+ // Check that the row heights are in sync
+ for (int row = tableView->topRow(); row < tableView->bottomRow(); ++row) {
+ QCOMPARE(tableViewV->rowHeight(row), tableView->rowHeight(row));
+ QCOMPARE(tableViewHV->rowHeight(row), tableView->rowHeight(row));
+ }
}
void tst_QQuickTableView::checkSyncView_differentSizedModels()
@@ -2850,6 +2900,61 @@ void tst_QQuickTableView::checkSyncView_differentSizedModels()
QVERIFY(tableViewHVPrivate->loadedColumns.isEmpty());
}
+void tst_QQuickTableView::checkSyncView_differentGeometry()
+{
+ // Check that you can have two tables in a syncView relation, where
+ // the sync "child" is larger than the sync view. This means that the
+ // child will display more rows and columns than the parent.
+ // In that case, the sync view will anyway need to load the same rows
+ // and columns as the child, otherwise the column and row sizes
+ // cannot be determined for the child.
+ LOAD_TABLEVIEW("syncviewsimple.qml");
+ GET_QML_TABLEVIEW(tableViewH);
+ GET_QML_TABLEVIEW(tableViewV);
+ GET_QML_TABLEVIEW(tableViewHV);
+
+ tableView->setWidth(40);
+ tableView->setHeight(40);
+
+ auto tableViewModel = TestModelAsVariant(100, 100);
+
+ tableView->setModel(tableViewModel);
+ tableViewH->setModel(tableViewModel);
+ tableViewV->setModel(tableViewModel);
+ tableViewHV->setModel(tableViewModel);
+
+ WAIT_UNTIL_POLISHED;
+
+ // Check that the column widths are in sync
+ for (int column = tableViewH->leftColumn(); column < tableViewH->rightColumn(); ++column) {
+ QCOMPARE(tableViewH->columnWidth(column), tableView->columnWidth(column));
+ QCOMPARE(tableViewHV->columnWidth(column), tableView->columnWidth(column));
+ }
+
+ // Check that the row heights are in sync
+ for (int row = tableViewV->topRow(); row < tableViewV->bottomRow(); ++row) {
+ QCOMPARE(tableViewV->rowHeight(row), tableView->rowHeight(row));
+ QCOMPARE(tableViewHV->rowHeight(row), tableView->rowHeight(row));
+ }
+
+ // Flick a bit, and do the same test again
+ tableView->setContentX(200);
+ tableView->setContentY(200);
+ WAIT_UNTIL_POLISHED;
+
+ // Check that the column widths are in sync
+ for (int column = tableViewH->leftColumn(); column < tableViewH->rightColumn(); ++column) {
+ QCOMPARE(tableViewH->columnWidth(column), tableView->columnWidth(column));
+ QCOMPARE(tableViewHV->columnWidth(column), tableView->columnWidth(column));
+ }
+
+ // Check that the row heights are in sync
+ for (int row = tableViewV->topRow(); row < tableViewV->bottomRow(); ++row) {
+ QCOMPARE(tableViewV->rowHeight(row), tableView->rowHeight(row));
+ QCOMPARE(tableViewHV->rowHeight(row), tableView->rowHeight(row));
+ }
+}
+
void tst_QQuickTableView::checkSyncView_connect_late_data()
{
QTest::addColumn<qreal>("flickToPos");
@@ -3017,6 +3122,42 @@ void tst_QQuickTableView::checkSyncView_emptyModel()
QCOMPARE(tableViewVPrivate->loadedTableOuterRect.left(), 0);
}
+void tst_QQuickTableView::checkSyncView_topLeftChanged()
+{
+ LOAD_TABLEVIEW("syncviewsimple.qml");
+ GET_QML_TABLEVIEW(tableViewH);
+ GET_QML_TABLEVIEW(tableViewV);
+ GET_QML_TABLEVIEW(tableViewHV);
+ QQuickTableView *views[] = {tableViewH, tableViewV, tableViewHV};
+
+ auto model = TestModelAsVariant(100, 100);
+ tableView->setModel(model);
+
+ for (auto view : views)
+ view->setModel(model);
+
+ tableView->setColumnWidthProvider(QJSValue());
+ tableView->setRowHeightProvider(QJSValue());
+ view->rootObject()->setProperty("delegateWidth", 300);
+ view->rootObject()->setProperty("delegateHeight", 300);
+ tableView->forceLayout();
+
+ tableViewHV->setContentX(350);
+ tableViewHV->setContentY(350);
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableViewH->leftColumn(), tableView->leftColumn());
+ QCOMPARE(tableViewV->topRow(), tableView->topRow());
+
+ view->rootObject()->setProperty("delegateWidth", 50);
+ view->rootObject()->setProperty("delegateHeight", 50);
+ tableView->forceLayout();
+
+ QCOMPARE(tableViewH->leftColumn(), tableView->leftColumn());
+ QCOMPARE(tableViewV->topRow(), tableView->topRow());
+}
+
void tst_QQuickTableView::checkThatFetchMoreIsCalledWhenScrolledToTheEndOfTable()
{
LOAD_TABLEVIEW("plaintableview.qml");
@@ -4918,7 +5059,7 @@ void tst_QQuickTableView::disablePointerNavigation()
// Enable navigation, and try again
tableView->setPointerNavigationEnabled(true);
QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, pos);
- QCOMPARE(selectionModel.currentIndex(), tableView->modelIndex(0, 0));
+ QCOMPARE(selectionModel.currentIndex(), tableView->index(0, 0));
QVERIFY(item0_0->property("current").toBool());
QCOMPARE(tableView->currentColumn(), cell0_0.x());
QCOMPARE(tableView->currentRow(), cell0_0.y());
@@ -5347,6 +5488,42 @@ void tst_QQuickTableView::boundDelegateComponent()
QVERIFY(innerTableView->itemAtCell(0, i)->objectName().isEmpty());
}
+void tst_QQuickTableView::tableViewInteractive()
+{
+ LOAD_TABLEVIEW("tableviewinteractive.qml");
+ auto *root = view->rootObject();
+ QVERIFY(root);
+ auto *window = root->window();
+ QVERIFY(window);
+ int eventCount = root->property("eventCount").toInt();
+ QCOMPARE(eventCount, 0);
+ // Event though we make 'interactive' as false, the TableView has
+ // pointerNacigationEnabled set as true by default, which allows it to consume
+ // mouse events and thus, eventCount still be zero
+ tableView->setInteractive(false);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(100, 100));
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(100, 100));
+ eventCount = root->property("eventCount").toInt();
+ QCOMPARE(eventCount, 0);
+ // Making both 'interactive' and 'pointerNavigationEnabled' as false, doesn't
+ // allow TableView (and its parent Flickable) to consume mouse event and it
+ // passes to the below visual item
+ tableView->setInteractive(false);
+ tableView->setPointerNavigationEnabled(false);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(100, 100));
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(100, 100));
+ eventCount = root->property("eventCount").toInt();
+ QCOMPARE(eventCount, 1);
+ // Making 'interactive' as true and 'pointerNavigationEnabled' as false,
+ // allows parent of TableView (i.e. Flickable) to consume mouse events
+ tableView->setInteractive(true);
+ tableView->setPointerNavigationEnabled(false);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(100, 100));
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(100, 100));
+ eventCount = root->property("eventCount").toInt();
+ QCOMPARE(eventCount, 1);
+}
+
QTEST_MAIN(tst_QQuickTableView)
#include "tst_qquicktableview.moc"
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index a660814113..f448928875 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -88,6 +88,7 @@ private slots:
void implicitSize_data();
void implicitSize();
void implicitSizeChangeRewrap();
+ void implicitSizeMaxLineCount();
void dependentImplicitSizes();
void contentSize();
void implicitSizeBinding_data();
@@ -488,14 +489,14 @@ void tst_qquicktext::wrap()
textObject->setWrapMode(QQuickText::Wrap);
QCOMPARE(textObject->wrapMode(), QQuickText::Wrap);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
textObject->setWrapMode(QQuickText::Wrap);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
textObject->setWrapMode(QQuickText::NoWrap);
QCOMPARE(textObject->wrapMode(), QQuickText::NoWrap);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
}
@@ -760,14 +761,14 @@ void tst_qquicktext::textFormat()
text->setTextFormat(QQuickText::StyledText);
QCOMPARE(text->textFormat(), QQuickText::StyledText);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
text->setTextFormat(QQuickText::StyledText);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
text->setTextFormat(QQuickText::AutoText);
QCOMPARE(text->textFormat(), QQuickText::AutoText);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
{
@@ -1244,25 +1245,25 @@ void tst_qquicktext::color()
textObject->setColor(QColor("white"));
QCOMPARE(textObject->color(), QColor("white"));
- QCOMPARE(colorSpy.count(), 1);
+ QCOMPARE(colorSpy.size(), 1);
textObject->setLinkColor(QColor("black"));
QCOMPARE(textObject->linkColor(), QColor("black"));
- QCOMPARE(linkColorSpy.count(), 1);
+ QCOMPARE(linkColorSpy.size(), 1);
textObject->setColor(QColor("white"));
- QCOMPARE(colorSpy.count(), 1);
+ QCOMPARE(colorSpy.size(), 1);
textObject->setLinkColor(QColor("black"));
- QCOMPARE(linkColorSpy.count(), 1);
+ QCOMPARE(linkColorSpy.size(), 1);
textObject->setColor(QColor("black"));
QCOMPARE(textObject->color(), QColor("black"));
- QCOMPARE(colorSpy.count(), 2);
+ QCOMPARE(colorSpy.size(), 2);
textObject->setLinkColor(QColor("blue"));
QCOMPARE(textObject->linkColor(), QColor("blue"));
- QCOMPARE(linkColorSpy.count(), 2);
+ QCOMPARE(linkColorSpy.size(), 2);
delete textObject;
}
@@ -1329,12 +1330,12 @@ void tst_qquicktext::color()
QCOMPARE(textObject->color(), testColor);
textObject->setColor(testColor);
QCOMPARE(textObject->color(), testColor);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
testColor = QColor("black");
textObject->setColor(testColor);
QCOMPARE(textObject->color(), testColor);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
} {
QString colorStr = "#001234";
QColor testColor(colorStr);
@@ -1350,12 +1351,12 @@ void tst_qquicktext::color()
QCOMPARE(textObject->styleColor(), testColor);
textObject->setStyleColor(testColor);
QCOMPARE(textObject->styleColor(), testColor);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
testColor = QColor("black");
textObject->setStyleColor(testColor);
QCOMPARE(textObject->styleColor(), testColor);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
} {
QString colorStr = "#001234";
QColor testColor(colorStr);
@@ -1371,12 +1372,12 @@ void tst_qquicktext::color()
QCOMPARE(textObject->linkColor(), testColor);
textObject->setLinkColor(testColor);
QCOMPARE(textObject->linkColor(), testColor);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
testColor = QColor("black");
textObject->setLinkColor(testColor);
QCOMPARE(textObject->linkColor(), testColor);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
}
@@ -1440,14 +1441,14 @@ void tst_qquicktext::renderType()
text->setRenderType(QQuickText::NativeRendering);
QCOMPARE(text->renderType(), QQuickText::NativeRendering);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
text->setRenderType(QQuickText::NativeRendering);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
text->setRenderType(QQuickText::QtRendering);
QCOMPARE(text->renderType(), QQuickText::QtRendering);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_qquicktext::antialiasing()
@@ -1464,14 +1465,14 @@ void tst_qquicktext::antialiasing()
text->setAntialiasing(false);
QCOMPARE(text->antialiasing(), false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
text->setAntialiasing(false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
text->resetAntialiasing();
QCOMPARE(text->antialiasing(), true);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
// QTBUG-39047
component.setData("import QtQuick 2.0\n Text { antialiasing: true }", QUrl());
@@ -2075,7 +2076,7 @@ void tst_qquicktext::linkInteraction()
QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString)));
QObject::connect(textObject, SIGNAL(linkHovered(QString)), &test, SLOT(linkHovered(QString)));
- QVERIFY(mousePositions.count() > 0);
+ QVERIFY(mousePositions.size() > 0);
QPointF mousePosition = mousePositions.first();
auto globalPos = textObject->mapToGlobal(mousePosition);
@@ -2091,7 +2092,7 @@ void tst_qquicktext::linkInteraction()
QCOMPARE(textObject->hoveredLink(), hoverEnterLink);
QCOMPARE(textObject->linkAt(mousePosition.x(), mousePosition.y()), hoverEnterLink);
- for (int i = 1; i < mousePositions.count(); ++i) {
+ for (int i = 1; i < mousePositions.size(); ++i) {
mousePosition = mousePositions.at(i);
auto globalPos = textObject->mapToGlobal(mousePosition);
@@ -2137,15 +2138,15 @@ void tst_qquicktext::baseUrl()
textObject->setBaseUrl(localUrl);
QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
textObject->setBaseUrl(remoteUrl);
QCOMPARE(textObject->baseUrl(), remoteUrl);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
textObject->resetBaseUrl();
QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_qquicktext::embeddedImages_data()
@@ -2377,6 +2378,20 @@ void tst_qquicktext::implicitSize()
delete textObject;
}
+void tst_qquicktext::implicitSizeMaxLineCount()
+{
+ QScopedPointer<QQuickText> textObject(new QQuickText);
+
+ textObject->setText("1st line");
+ const auto referenceWidth = textObject->implicitWidth();
+
+ textObject->setText(textObject->text() + "\n2nd long long long long long line");
+ QCOMPARE_GT(textObject->implicitWidth(), referenceWidth);
+
+ textObject->setMaximumLineCount(1);
+ QCOMPARE_EQ(textObject->implicitWidth(), referenceWidth);
+}
+
void tst_qquicktext::dependentImplicitSizes()
{
QQmlComponent component(&engine, testFile("implicitSizes.qml"));
@@ -2449,23 +2464,23 @@ void tst_qquicktext::contentSize()
QVERIFY(textObject->contentWidth() > textObject->width());
QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spySize.count(), 1);
- QCOMPARE(spyWidth.count(), 1);
- QCOMPARE(spyHeight.count(), 0);
+ QCOMPARE(spySize.size(), 1);
+ QCOMPARE(spyWidth.size(), 1);
+ QCOMPARE(spyHeight.size(), 0);
textObject->setWrapMode(QQuickText::WordWrap);
QVERIFY(textObject->contentWidth() <= textObject->width());
QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spySize.count(), 2);
- QCOMPARE(spyWidth.count(), 2);
- QCOMPARE(spyHeight.count(), 1);
+ QCOMPARE(spySize.size(), 2);
+ QCOMPARE(spyWidth.size(), 2);
+ QCOMPARE(spyHeight.size(), 1);
textObject->setElideMode(QQuickText::ElideRight);
QVERIFY(textObject->contentWidth() <= textObject->width());
QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spySize.count(), 3);
- QCOMPARE(spyWidth.count(), 3);
- QCOMPARE(spyHeight.count(), 2);
+ QCOMPARE(spySize.size(), 3);
+ QCOMPARE(spyWidth.size(), 3);
+ QCOMPARE(spyHeight.size(), 2);
int spyCount = 3;
qreal elidedWidth = textObject->contentWidth();
@@ -2474,16 +2489,16 @@ void tst_qquicktext::contentSize()
QVERIFY(textObject->contentHeight() < textObject->height());
// this text probably won't have the same elided width, but it's not guaranteed.
if (textObject->contentWidth() != elidedWidth)
- QCOMPARE(spySize.count(), ++spyCount);
+ QCOMPARE(spySize.size(), ++spyCount);
else
- QCOMPARE(spySize.count(), spyCount);
+ QCOMPARE(spySize.size(), spyCount);
textObject->setElideMode(QQuickText::ElideNone);
QVERIFY(textObject->contentWidth() > textObject->width());
QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spySize.count(), ++spyCount);
- QCOMPARE(spyWidth.count(), spyCount);
- QCOMPARE(spyHeight.count(), 3);
+ QCOMPARE(spySize.size(), ++spyCount);
+ QCOMPARE(spyWidth.size(), spyCount);
+ QCOMPARE(spyHeight.size(), 3);
}
void tst_qquicktext::geometryChanged()
@@ -3297,7 +3312,7 @@ void tst_qquicktext::imgTagsMultipleImages()
QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
QVERIFY(textPrivate != nullptr);
- QCOMPARE(textPrivate->extra->visibleImgTags.count(), 2);
+ QCOMPARE(textPrivate->extra->visibleImgTags.size(), 2);
delete textObject;
}
@@ -3310,9 +3325,9 @@ void tst_qquicktext::imgTagsElide()
QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
QVERIFY(textPrivate != nullptr);
- QCOMPARE(textPrivate->extra->visibleImgTags.count(), 0);
+ QCOMPARE(textPrivate->extra->visibleImgTags.size(), 0);
myText->setMaximumLineCount(20);
- QTRY_COMPARE(textPrivate->extra->visibleImgTags.count(), 1);
+ QTRY_COMPARE(textPrivate->extra->visibleImgTags.size(), 1);
delete myText;
}
@@ -3329,16 +3344,16 @@ void tst_qquicktext::imgTagsUpdates()
QVERIFY(textPrivate != nullptr);
myText->setText("This is a heart<img src=\"images/heart200.png\">.");
- QCOMPARE(textPrivate->extra->visibleImgTags.count(), 1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(textPrivate->extra->visibleImgTags.size(), 1);
+ QCOMPARE(spy.size(), 1);
myText->setMaximumLineCount(2);
myText->setText("This is another heart<img src=\"images/heart200.png\">.");
- QTRY_COMPARE(textPrivate->extra->visibleImgTags.count(), 1);
+ QTRY_COMPARE(textPrivate->extra->visibleImgTags.size(), 1);
// if maximumLineCount is set and the img tag doesn't have an explicit size
// we relayout twice.
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
delete myText;
}
@@ -3601,6 +3616,46 @@ void tst_qquicktext::fontSizeMode()
myText->setElideMode(QQuickText::ElideNone);
QVERIFY(QQuickTest::qWaitForPolish(myText));
+
+ // Growing height needs to update the baselineOffset when AlignBottom is used
+ // and text is NOT wrapped
+ myText->setVAlign(QQuickText::AlignBottom);
+ myText->setFontSizeMode(QQuickText::Fit);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
+
+ int baselineOffset = myText->baselineOffset();
+ myText->setHeight(myText->height() * 2);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
+ QVERIFY(myText->baselineOffset() > baselineOffset);
+
+ // Growing height needs to update the baselineOffset when AlignBottom is used
+ // and the text is wrapped
+ myText->setVAlign(QQuickText::AlignBottom);
+ myText->setFontSizeMode(QQuickText::Fit);
+ myText->setWrapMode(QQuickText::NoWrap);
+ myText->resetMaximumLineCount();
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
+
+ baselineOffset = myText->baselineOffset();
+ myText->setHeight(myText->height() * 2);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
+ QVERIFY(myText->baselineOffset() > baselineOffset);
+
+ // Check baselineOffset for the HorizontalFit case
+ myText->setVAlign(QQuickText::AlignBottom);
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QVERIFY(QQuickTest::qWaitForPolish(myText));
+ QSignalSpy baselineOffsetSpy(myText, SIGNAL(baselineOffsetChanged(qreal)));
+ QVERIFY(QQuickTest::qWaitForPolish(myText));
+ const qreal oldBaselineOffset = myText->baselineOffset();
+ myText->setHeight(myText->height() + 42);
+ QVERIFY(QQuickTest::qWaitForPolish(myText));
+ QCOMPARE(baselineOffsetSpy.size(), 1);
+ QCOMPARE(myText->baselineOffset(), oldBaselineOffset + 42);
+ myText->setHeight(myText->height() - 42);
+ QVERIFY(QQuickTest::qWaitForPolish(myText));
+ QCOMPARE(baselineOffsetSpy.size(), 2);
+ QCOMPARE(myText->baselineOffset(), oldBaselineOffset);
}
void tst_qquicktext::fontSizeModeMultiline_data()
diff --git a/tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml b/tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml
index 24bd434830..b753d844be 100644
--- a/tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml
+++ b/tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml
@@ -14,7 +14,7 @@ Item {
id: txt
x: 100
text: "enter text"
- Keys.onShortcutOverride: {
+ Keys.onShortcutOverride: (event) => {
who = "TextEdit"
event.accepted = (event.key === Qt.Key_Escape)
}
@@ -26,7 +26,7 @@ Item {
height: width
focus: true
color: focus ? "red" : "gray"
- Keys.onShortcutOverride: {
+ Keys.onShortcutOverride: (event) => {
who = "Rectangle"
event.accepted = (event.key === Qt.Key_Escape)
}
diff --git a/tests/auto/quick/qquicktextedit/data/threeLines.qml b/tests/auto/quick/qquicktextedit/data/threeLines.qml
new file mode 100644
index 0000000000..cee03bfa15
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/data/threeLines.qml
@@ -0,0 +1,7 @@
+import QtQuick
+import Qt.test 1.0
+
+NodeCheckerTextEdit {
+ width: 200; height: 100
+ text: "Line 1\nLine 2\nLine 3\n"
+}
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index b8861f101d..36543357a2 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -57,6 +57,8 @@ public:
tst_qquicktextedit();
private slots:
+ void initTestCase() override;
+
void cleanup();
void text();
void width();
@@ -138,6 +140,7 @@ private slots:
void implicitSizeBinding();
void largeTextObservesViewport_data();
void largeTextObservesViewport();
+ void renderingAroundSelection();
void signal_editingfinished();
@@ -241,7 +244,7 @@ Q_DECLARE_METATYPE(QQuickTextEdit::TextFormat)
void tst_qquicktextedit::simulateKeys(QWindow *window, const QList<Key> &keys)
{
- for (int i = 0; i < keys.count(); ++i) {
+ for (int i = 0; i < keys.size(); ++i) {
const int key = keys.at(i).first;
const int modifiers = key & Qt::KeyboardModifierMask;
const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString();
@@ -336,6 +339,56 @@ tst_qquicktextedit::tst_qquicktextedit()
//
}
+class NodeCheckerTextEdit : public QQuickTextEdit
+{
+public:
+ NodeCheckerTextEdit(QQuickItem *parent = nullptr) : QQuickTextEdit(parent) {}
+
+ void populateLinePositions(QSGNode *node)
+ {
+ linePositions.clear();
+ lastLinePosition = 0;
+ QSGNode *ch = node->firstChild();
+ while (ch != node->lastChild()) {
+ QCOMPARE(ch->type(), QSGNode::TransformNodeType);
+ QSGTransformNode *tn = static_cast<QSGTransformNode *>(ch);
+ int y = 0;
+ if (!tn->matrix().isIdentity())
+ y = tn->matrix().column(3).y();
+ if (tn->childCount() == 0) {
+ // A TransformNode with no children is a waste of memory.
+ // So far, QQuickTextEdit still creates a couple of extras.
+ qCDebug(lcTests) << "ignoring leaf TransformNode" << tn << "@ y" << y;
+ } else {
+ qCDebug(lcTests) << "child" << tn << "@ y" << y << "has children" << tn->childCount();
+ if (!linePositions.contains(y)) {
+ linePositions.append(y);
+ lastLinePosition = qMax(lastLinePosition, y);
+ }
+ }
+ ch = ch->nextSibling();
+ }
+ std::sort(linePositions.begin(), linePositions.end());
+ }
+
+ QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *data) override
+ {
+ QSGNode *ret = QQuickTextEdit::updatePaintNode(node, data);
+ qCDebug(lcTests) << "updated root node" << ret;
+ populateLinePositions(ret);
+ return ret;
+ }
+
+ QList<int> linePositions;
+ int lastLinePosition;
+};
+
+void tst_qquicktextedit::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<NodeCheckerTextEdit>("Qt.test", 1, 0, "NodeCheckerTextEdit");
+}
+
void tst_qquicktextedit::cleanup()
{
// ensure not even skipped tests with custom input context leave it dangling
@@ -364,7 +417,7 @@ void tst_qquicktextedit::text()
QVERIFY(textEditObject != nullptr);
QCOMPARE(textEditObject->text(), standard.at(i));
- QCOMPARE(textEditObject->length(), standard.at(i).length());
+ QCOMPARE(textEditObject->length(), standard.at(i).size());
}
for (int i = 0; i < richText.size(); i++)
@@ -380,7 +433,7 @@ void tst_qquicktextedit::text()
QString expected = richText.at(i);
expected.replace(QRegularExpression("\\\\(.)"),"\\1");
QCOMPARE(textEditObject->text(), expected);
- QCOMPARE(textEditObject->length(), expected.length());
+ QCOMPARE(textEditObject->length(), expected.size());
}
for (int i = 0; i < standard.size(); i++)
@@ -399,7 +452,7 @@ void tst_qquicktextedit::text()
actual.remove(QRegularExpression("(<[^>]*>)+"));
expected.remove("\n");
QCOMPARE(actual.simplified(), expected);
- QCOMPARE(textEditObject->length(), expected.length());
+ QCOMPARE(textEditObject->length(), expected.size());
}
for (int i = 0; i < richText.size(); i++)
@@ -419,7 +472,7 @@ void tst_qquicktextedit::text()
QCOMPARE(actual.simplified(),expected.simplified());
expected.replace("<>", " ");
- QCOMPARE(textEditObject->length(), expected.simplified().length());
+ QCOMPARE(textEditObject->length(), expected.simplified().size());
}
for (int i = 0; i < standard.size(); i++)
@@ -431,7 +484,7 @@ void tst_qquicktextedit::text()
QVERIFY(textEditObject != nullptr);
QCOMPARE(textEditObject->text(), standard.at(i));
- QCOMPARE(textEditObject->length(), standard.at(i).length());
+ QCOMPARE(textEditObject->length(), standard.at(i).size());
}
for (int i = 0; i < richText.size(); i++)
@@ -451,7 +504,7 @@ void tst_qquicktextedit::text()
QCOMPARE(actual.simplified(),expected.simplified());
expected.replace("<>", " ");
- QCOMPARE(textEditObject->length(), expected.simplified().length());
+ QCOMPARE(textEditObject->length(), expected.simplified().size());
}
}
@@ -569,14 +622,14 @@ void tst_qquicktextedit::wrap()
edit->setWrapMode(QQuickTextEdit::Wrap);
QCOMPARE(edit->wrapMode(), QQuickTextEdit::Wrap);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
edit->setWrapMode(QQuickTextEdit::Wrap);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
edit->setWrapMode(QQuickTextEdit::NoWrap);
QCOMPARE(edit->wrapMode(), QQuickTextEdit::NoWrap);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
}
@@ -625,18 +678,18 @@ void tst_qquicktextedit::textFormat()
edit->setTextFormat(QQuickTextEdit::RichText);
QCOMPARE(edit->textFormat(), QQuickTextEdit::RichText);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
edit->setTextFormat(QQuickTextEdit::RichText);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
edit->setTextFormat(QQuickTextEdit::PlainText);
QCOMPARE(edit->textFormat(), QQuickTextEdit::PlainText);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
edit->setTextFormat(QQuickTextEdit::MarkdownText);
QCOMPARE(edit->textFormat(), QQuickTextEdit::MarkdownText);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
}
@@ -838,7 +891,7 @@ void tst_qquicktextedit::hAlign_RightToLeft()
QSignalSpy cursorRectangleSpy(textEdit, SIGNAL(cursorRectangleChanged()));
platformInputContext.setInputDirection(Qt::RightToLeft);
- QCOMPARE(cursorRectangleSpy.count(), 1);
+ QCOMPARE(cursorRectangleSpy.size(), 1);
QCOMPARE(qApp->inputMethod()->inputDirection(), Qt::RightToLeft);
QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
QVERIFY(textEdit->positionToRectangle(0).x() > window.width()/2);
@@ -1149,36 +1202,36 @@ void tst_qquicktextedit::color()
textEditObject->setColor(QColor("white"));
QCOMPARE(textEditObject->color(), QColor("white"));
- QCOMPARE(colorSpy.count(), 1);
+ QCOMPARE(colorSpy.size(), 1);
textEditObject->setSelectionColor(QColor("black"));
QCOMPARE(textEditObject->selectionColor(), QColor("black"));
- QCOMPARE(selectionColorSpy.count(), 1);
+ QCOMPARE(selectionColorSpy.size(), 1);
textEditObject->setSelectedTextColor(QColor("blue"));
QCOMPARE(textEditObject->selectedTextColor(), QColor("blue"));
- QCOMPARE(selectedTextColorSpy.count(), 1);
+ QCOMPARE(selectedTextColorSpy.size(), 1);
textEditObject->setColor(QColor("white"));
- QCOMPARE(colorSpy.count(), 1);
+ QCOMPARE(colorSpy.size(), 1);
textEditObject->setSelectionColor(QColor("black"));
- QCOMPARE(selectionColorSpy.count(), 1);
+ QCOMPARE(selectionColorSpy.size(), 1);
textEditObject->setSelectedTextColor(QColor("blue"));
- QCOMPARE(selectedTextColorSpy.count(), 1);
+ QCOMPARE(selectedTextColorSpy.size(), 1);
textEditObject->setColor(QColor("black"));
QCOMPARE(textEditObject->color(), QColor("black"));
- QCOMPARE(colorSpy.count(), 2);
+ QCOMPARE(colorSpy.size(), 2);
textEditObject->setSelectionColor(QColor("blue"));
QCOMPARE(textEditObject->selectionColor(), QColor("blue"));
- QCOMPARE(selectionColorSpy.count(), 2);
+ QCOMPARE(selectionColorSpy.size(), 2);
textEditObject->setSelectedTextColor(QColor("white"));
QCOMPARE(textEditObject->selectedTextColor(), QColor("white"));
- QCOMPARE(selectedTextColorSpy.count(), 2);
+ QCOMPARE(selectedTextColorSpy.size(), 2);
}
//test normal
@@ -1259,7 +1312,7 @@ void tst_qquicktextedit::persistentSelection()
edit->setPersistentSelection(false);
QCOMPARE(edit->persistentSelection(), false);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
edit->select(1, 4);
QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
@@ -1272,7 +1325,7 @@ void tst_qquicktextedit::persistentSelection()
edit->setPersistentSelection(true);
QCOMPARE(edit->persistentSelection(), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
edit->select(1, 4);
QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
@@ -1288,7 +1341,7 @@ void tst_qquicktextedit::persistentSelection()
edit->setPersistentSelection(false);
QCOMPARE(edit->persistentSelection(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
edit->select(1, 4);
QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
@@ -1301,7 +1354,7 @@ void tst_qquicktextedit::persistentSelection()
edit->setPersistentSelection(true);
QCOMPARE(edit->persistentSelection(), true);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
edit->select(1, 4);
QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
@@ -1379,7 +1432,7 @@ void tst_qquicktextedit::focusOnPress()
textEditObject->setFocusOnPress(true);
QCOMPARE(textEditObject->focusOnPress(), true);
- QCOMPARE(activeFocusOnPressSpy.count(), 0);
+ QCOMPARE(activeFocusOnPressSpy.size(), 0);
QQuickWindow window;
window.resize(100, 50);
@@ -1397,20 +1450,20 @@ void tst_qquicktextedit::focusOnPress()
QGuiApplication::processEvents();
QCOMPARE(textEditObject->hasFocus(), true);
QCOMPARE(textEditObject->hasActiveFocus(), true);
- QCOMPARE(focusSpy.count(), 1);
- QCOMPARE(activeFocusSpy.count(), 1);
+ QCOMPARE(focusSpy.size(), 1);
+ QCOMPARE(activeFocusSpy.size(), 1);
QCOMPARE(textEditObject->selectedText(), QString());
QTest::mouseRelease(&window, Qt::LeftButton, noModifiers, centerPoint);
textEditObject->setFocusOnPress(false);
QCOMPARE(textEditObject->focusOnPress(), false);
- QCOMPARE(activeFocusOnPressSpy.count(), 1);
+ QCOMPARE(activeFocusOnPressSpy.size(), 1);
textEditObject->setFocus(false);
QCOMPARE(textEditObject->hasFocus(), false);
QCOMPARE(textEditObject->hasActiveFocus(), false);
- QCOMPARE(focusSpy.count(), 2);
- QCOMPARE(activeFocusSpy.count(), 2);
+ QCOMPARE(focusSpy.size(), 2);
+ QCOMPARE(activeFocusSpy.size(), 2);
// Wait for double click timeout to expire before clicking again.
QTest::qWait(400);
@@ -1418,13 +1471,13 @@ void tst_qquicktextedit::focusOnPress()
QGuiApplication::processEvents();
QCOMPARE(textEditObject->hasFocus(), false);
QCOMPARE(textEditObject->hasActiveFocus(), false);
- QCOMPARE(focusSpy.count(), 2);
- QCOMPARE(activeFocusSpy.count(), 2);
+ QCOMPARE(focusSpy.size(), 2);
+ QCOMPARE(activeFocusSpy.size(), 2);
QTest::mouseRelease(&window, Qt::LeftButton, noModifiers, centerPoint);
textEditObject->setFocusOnPress(true);
QCOMPARE(textEditObject->focusOnPress(), true);
- QCOMPARE(activeFocusOnPressSpy.count(), 2);
+ QCOMPARE(activeFocusOnPressSpy.size(), 2);
// Test a selection made in the on(Active)FocusChanged handler isn't overwritten.
textEditObject->setProperty("selectOnFocus", true);
@@ -1434,8 +1487,8 @@ void tst_qquicktextedit::focusOnPress()
QGuiApplication::processEvents();
QCOMPARE(textEditObject->hasFocus(), true);
QCOMPARE(textEditObject->hasActiveFocus(), true);
- QCOMPARE(focusSpy.count(), 3);
- QCOMPARE(activeFocusSpy.count(), 3);
+ QCOMPARE(focusSpy.size(), 3);
+ QCOMPARE(activeFocusSpy.size(), 3);
QCOMPARE(textEditObject->selectedText(), textEditObject->text());
QTest::mouseRelease(&window, Qt::LeftButton, noModifiers, centerPoint);
}
@@ -1472,7 +1525,7 @@ void tst_qquicktextedit::selection()
QCOMPARE(textEditObject->selectionEnd(), 0);
QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->setCursorPosition(textEditObject->text().length()+1);
+ textEditObject->setCursorPosition(textEditObject->text().size()+1);
QCOMPARE(textEditObject->cursorPosition(), 0);
QCOMPARE(textEditObject->selectionStart(), 0);
QCOMPARE(textEditObject->selectionEnd(), 0);
@@ -1543,37 +1596,37 @@ void tst_qquicktextedit::overwriteMode()
QVERIFY(textEdit->hasActiveFocus());
textEdit->setOverwriteMode(true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(true, textEdit->overwriteMode());
textEdit->setOverwriteMode(false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(false, textEdit->overwriteMode());
QVERIFY(!textEdit->overwriteMode());
QString insertString = "Some first text";
- for (int j = 0; j < insertString.length(); j++)
+ for (int j = 0; j < insertString.size(); j++)
QTest::keyClick(&window, insertString.at(j).toLatin1());
QCOMPARE(textEdit->text(), QString("Some first text"));
textEdit->setOverwriteMode(true);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
textEdit->setCursorPosition(5);
insertString = "shiny";
- for (int j = 0; j < insertString.length(); j++)
+ for (int j = 0; j < insertString.size(); j++)
QTest::keyClick(&window, insertString.at(j).toLatin1());
QCOMPARE(textEdit->text(), QString("Some shiny text"));
- textEdit->setCursorPosition(textEdit->text().length());
+ textEdit->setCursorPosition(textEdit->text().size());
QTest::keyClick(&window, Qt::Key_Enter);
textEdit->setOverwriteMode(false);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
insertString = "Second paragraph";
- for (int j = 0; j < insertString.length(); j++)
+ for (int j = 0; j < insertString.size(); j++)
QTest::keyClick(&window, insertString.at(j).toLatin1());
QCOMPARE(textEdit->lineCount(), 2);
@@ -1582,10 +1635,10 @@ void tst_qquicktextedit::overwriteMode()
QCOMPARE(textEdit->cursorPosition(), 15);
textEdit->setOverwriteMode(true);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
insertString = " blah";
- for (int j = 0; j < insertString.length(); j++)
+ for (int j = 0; j < insertString.size(); j++)
QTest::keyClick(&window, insertString.at(j).toLatin1());
QCOMPARE(textEdit->lineCount(), 2);
@@ -1629,24 +1682,24 @@ void tst_qquicktextedit::isRightToLeft()
// first test that the right string is delivered to the QString::isRightToLeft()
QCOMPARE(textEdit.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
QCOMPARE(textEdit.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.length()-2, text.length()-1), text.mid(text.length()-2, text.length()-1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.length()/2, text.length()/2 + 1), text.mid(text.length()/2, text.length()/2 + 1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(0,text.length()/4), text.mid(0,text.length()/4).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.length()/4,3*text.length()/4), text.mid(text.length()/4,3*text.length()/4).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(text.size()-2, text.size()-1), text.mid(text.size()-2, text.size()-1).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(text.size()/2, text.size()/2 + 1), text.mid(text.size()/2, text.size()/2 + 1).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(0,text.size()/4), text.mid(0,text.size()/4).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(text.size()/4,3*text.size()/4), text.mid(text.size()/4,3*text.size()/4).isRightToLeft());
if (text.isEmpty())
QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textEdit.isRightToLeft(3*text.length()/4,text.length()-1), text.mid(3*text.length()/4,text.length()-1).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(3*text.size()/4,text.size()-1), text.mid(3*text.size()/4,text.size()-1).isRightToLeft());
// then test that the feature actually works
QCOMPARE(textEdit.isRightToLeft(0,0), emptyString);
QCOMPARE(textEdit.isRightToLeft(0,1), firstCharacter);
- QCOMPARE(textEdit.isRightToLeft(text.length()-2, text.length()-1), lastCharacter);
- QCOMPARE(textEdit.isRightToLeft(text.length()/2, text.length()/2 + 1), middleCharacter);
- QCOMPARE(textEdit.isRightToLeft(0,text.length()/4), startString);
- QCOMPARE(textEdit.isRightToLeft(text.length()/4,3*text.length()/4), midString);
+ QCOMPARE(textEdit.isRightToLeft(text.size()-2, text.size()-1), lastCharacter);
+ QCOMPARE(textEdit.isRightToLeft(text.size()/2, text.size()/2 + 1), middleCharacter);
+ QCOMPARE(textEdit.isRightToLeft(0,text.size()/4), startString);
+ QCOMPARE(textEdit.isRightToLeft(text.size()/4,3*text.size()/4), midString);
if (text.isEmpty())
QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textEdit.isRightToLeft(3*text.length()/4,text.length()-1), endString);
+ QCOMPARE(textEdit.isRightToLeft(3*text.size()/4,text.size()-1), endString);
}
void tst_qquicktextedit::keySelection()
@@ -1668,31 +1721,31 @@ void tst_qquicktextedit::keySelection()
simulateKey(&window, Qt::Key_Right, Qt::ShiftModifier);
QVERIFY(input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString("a"));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
simulateKey(&window, Qt::Key_Right);
QVERIFY(input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
simulateKey(&window, Qt::Key_Right);
QVERIFY(!input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
simulateKey(&window, Qt::Key_Left);
QVERIFY(input->hasActiveFocus());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
simulateKey(&window, Qt::Key_Left, Qt::ShiftModifier);
QVERIFY(input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString("a"));
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
simulateKey(&window, Qt::Key_Left);
QVERIFY(input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
simulateKey(&window, Qt::Key_Left);
QVERIFY(!input->hasActiveFocus());
QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
}
void tst_qquicktextedit::moveCursorSelection_data()
@@ -2174,7 +2227,7 @@ void tst_qquicktextedit::dragMouseSelection()
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(x2,y));
QTest::qWait(300);
QString str1;
- QTRY_VERIFY((str1 = textEditObject->selectedText()).length() > 3);
+ QTRY_VERIFY((str1 = textEditObject->selectedText()).size() > 3);
// press and drag the current selection.
x1 = 40;
@@ -2184,7 +2237,7 @@ void tst_qquicktextedit::dragMouseSelection()
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(x2,y));
QTest::qWait(300);
QString str2;
- QTRY_VERIFY((str2 = textEditObject->selectedText()).length() > 3);
+ QTRY_VERIFY((str2 = textEditObject->selectedText()).size() > 3);
QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and not the first moved.
@@ -2230,7 +2283,7 @@ void tst_qquicktextedit::mouseSelectionMode()
if (selectWords) {
QTRY_COMPARE(textEditObject->selectedText(), text);
} else {
- QTRY_VERIFY(textEditObject->selectedText().length() > 3);
+ QTRY_VERIFY(textEditObject->selectedText().size() > 3);
QVERIFY(str != text);
}
}
@@ -2249,14 +2302,14 @@ void tst_qquicktextedit::mouseSelectionMode_accessors()
edit->setMouseSelectionMode(QQuickTextEdit::SelectWords);
QCOMPARE(edit->mouseSelectionMode(), QQuickTextEdit::SelectWords);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
edit->setMouseSelectionMode(QQuickTextEdit::SelectWords);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
edit->setMouseSelectionMode(QQuickTextEdit::SelectCharacters);
QCOMPARE(edit->mouseSelectionMode(), QQuickTextEdit::SelectCharacters);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_qquicktextedit::selectByMouse()
@@ -2273,15 +2326,15 @@ void tst_qquicktextedit::selectByMouse()
edit->setSelectByMouse(true);
QCOMPARE(edit->selectByMouse(), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), true);
edit->setSelectByMouse(true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
edit->setSelectByMouse(false);
QCOMPARE(edit->selectByMouse(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(spy.at(1).at(0).toBool(), false);
}
@@ -2304,21 +2357,21 @@ void tst_qquicktextedit::selectByKeyboard()
edit->setReadOnly(true);
QCOMPARE(edit->selectByKeyboard(), false);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), false);
edit->setSelectByKeyboard(true);
QCOMPARE(edit->selectByKeyboard(), true);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(spy.at(1).at(0).toBool(), true);
edit->setReadOnly(false);
QCOMPARE(edit->selectByKeyboard(), true);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
edit->setSelectByKeyboard(false);
QCOMPARE(edit->selectByKeyboard(), false);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
QCOMPARE(spy.at(2).at(0).toBool(), false);
}
@@ -2424,14 +2477,14 @@ void tst_qquicktextedit::renderType()
edit->setRenderType(QQuickTextEdit::NativeRendering);
QCOMPARE(edit->renderType(), QQuickTextEdit::NativeRendering);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
edit->setRenderType(QQuickTextEdit::NativeRendering);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
edit->setRenderType(QQuickTextEdit::QtRendering);
QCOMPARE(edit->renderType(), QQuickTextEdit::QtRendering);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_qquicktextedit::inputMethodHints()
@@ -2447,9 +2500,9 @@ void tst_qquicktextedit::inputMethodHints()
QSignalSpy inputMethodHintSpy(textEditObject, SIGNAL(inputMethodHintsChanged()));
textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
+ QCOMPARE(inputMethodHintSpy.size(), 1);
textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
+ QCOMPARE(inputMethodHintSpy.size(), 1);
QQuickTextEdit plainTextEdit;
QCOMPARE(plainTextEdit.inputMethodHints(), Qt::ImhNone);
@@ -2587,22 +2640,22 @@ void tst_qquicktextedit::linkHover()
const QPoint textPos = window.mapToGlobal(texteditObject->positionToRectangle(2).center().toPoint());
QCursor::setPos(linkPos);
- QTRY_COMPARE(hover.count(), 1);
+ QTRY_COMPARE(hover.size(), 1);
QCOMPARE(window.cursor().shape(), Qt::PointingHandCursor);
QCOMPARE(hover.last()[0].toString(), link);
QCursor::setPos(textPos);
- QTRY_COMPARE(hover.count(), 2);
+ QTRY_COMPARE(hover.size(), 2);
QCOMPARE(window.cursor().shape(), Qt::IBeamCursor);
QCOMPARE(hover.last()[0].toString(), QString());
QCursor::setPos(linkPos);
- QTRY_COMPARE(hover.count(), 3);
+ QTRY_COMPARE(hover.size(), 3);
QCOMPARE(window.cursor().shape(), Qt::PointingHandCursor);
QCOMPARE(hover.last()[0].toString(), link);
QCursor::setPos(textPos);
- QTRY_COMPARE(hover.count(), 4);
+ QTRY_COMPARE(hover.size(), 4);
QCOMPARE(window.cursor().shape(), Qt::IBeamCursor);
QCOMPARE(hover.last()[0].toString(), QString());
}
@@ -2630,16 +2683,16 @@ void tst_qquicktextedit::linkInteraction()
const QPointF textPos = texteditObject->positionToRectangle(2).center();
QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, linkPos.toPoint());
- QTRY_COMPARE(spy.count(), 1);
- QTRY_COMPARE(hover.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
+ QTRY_COMPARE(hover.size(), 1);
QCOMPARE(spy.last()[0].toString(), link);
QCOMPARE(hover.last()[0].toString(), link);
QCOMPARE(texteditObject->hoveredLink(), link);
QCOMPARE(texteditObject->linkAt(linkPos.x(), linkPos.y()), link);
QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, textPos.toPoint());
- QTRY_COMPARE(spy.count(), 1);
- QTRY_COMPARE(hover.count(), 2);
+ QTRY_COMPARE(spy.size(), 1);
+ QTRY_COMPARE(hover.size(), 2);
QCOMPARE(hover.last()[0].toString(), QString());
QCOMPARE(texteditObject->hoveredLink(), QString());
QCOMPARE(texteditObject->linkAt(textPos.x(), textPos.y()), QString());
@@ -2647,16 +2700,16 @@ void tst_qquicktextedit::linkInteraction()
texteditObject->setReadOnly(true);
QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, linkPos.toPoint());
- QTRY_COMPARE(spy.count(), 2);
- QTRY_COMPARE(hover.count(), 3);
+ QTRY_COMPARE(spy.size(), 2);
+ QTRY_COMPARE(hover.size(), 3);
QCOMPARE(spy.last()[0].toString(), link);
QCOMPARE(hover.last()[0].toString(), link);
QCOMPARE(texteditObject->hoveredLink(), link);
QCOMPARE(texteditObject->linkAt(linkPos.x(), linkPos.y()), link);
QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, textPos.toPoint());
- QTRY_COMPARE(spy.count(), 2);
- QTRY_COMPARE(hover.count(), 4);
+ QTRY_COMPARE(spy.size(), 2);
+ QTRY_COMPARE(hover.size(), 4);
QCOMPARE(hover.last()[0].toString(), QString());
QCOMPARE(texteditObject->hoveredLink(), QString());
QCOMPARE(texteditObject->linkAt(textPos.x(), textPos.y()), QString());
@@ -2689,7 +2742,7 @@ void tst_qquicktextedit::cursorDelegate()
QVERIFY(delegateObject);
QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
//Test Delegate gets moved
- for (int i=0; i<= textEditObject->text().length(); i++) {
+ for (int i=0; i<= textEditObject->text().size(); i++) {
textEditObject->setCursorPosition(i);
QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
@@ -2825,27 +2878,27 @@ void tst_qquicktextedit::cursorVisible()
edit.setCursorVisible(true);
QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
edit.setCursorVisible(false);
QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
edit.setFocus(true);
QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
edit.setParentItem(view.rootObject());
QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
edit.setFocus(false);
QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
edit.setFocus(true);
QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
QWindow alternateView;
alternateView.show();
@@ -2853,12 +2906,12 @@ void tst_qquicktextedit::cursorVisible()
QVERIFY(QTest::qWaitForWindowActive(&alternateView));
QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
view.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 7);
+ QCOMPARE(spy.size(), 7);
{ // Cursor attribute with 0 length hides cursor.
QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>()
@@ -2866,7 +2919,7 @@ void tst_qquicktextedit::cursorVisible()
QCoreApplication::sendEvent(&edit, &ev);
}
QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 8);
+ QCOMPARE(spy.size(), 8);
{ // Cursor attribute with non zero length shows cursor.
QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>()
@@ -2874,7 +2927,7 @@ void tst_qquicktextedit::cursorVisible()
QCoreApplication::sendEvent(&edit, &ev);
}
QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 9);
+ QCOMPARE(spy.size(), 9);
{ // If the cursor is hidden by the input method and the text is changed it should be visible again.
@@ -2883,11 +2936,11 @@ void tst_qquicktextedit::cursorVisible()
QCoreApplication::sendEvent(&edit, &ev);
}
QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 10);
+ QCOMPARE(spy.size(), 10);
edit.setText("something");
QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 11);
+ QCOMPARE(spy.size(), 11);
{ // If the cursor is hidden by the input method and the cursor position is changed it should be visible again.
QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>()
@@ -2895,11 +2948,11 @@ void tst_qquicktextedit::cursorVisible()
QCoreApplication::sendEvent(&edit, &ev);
}
QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 12);
+ QCOMPARE(spy.size(), 12);
edit.setCursorPosition(5);
QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 13);
+ QCOMPARE(spy.size(), 13);
}
void tst_qquicktextedit::delegateLoading_data()
@@ -3046,16 +3099,16 @@ void tst_qquicktextedit::copyAndPaste()
QVERIFY(textEdit != nullptr);
// copy and paste
- QCOMPARE(textEdit->text().length(), 12);
- textEdit->select(0, textEdit->text().length());;
+ QCOMPARE(textEdit->text().size(), 12);
+ textEdit->select(0, textEdit->text().size());;
textEdit->copy();
QCOMPARE(textEdit->selectedText(), QString("Hello world!"));
- QCOMPARE(textEdit->selectedText().length(), 12);
+ QCOMPARE(textEdit->selectedText().size(), 12);
textEdit->setCursorPosition(0);
QVERIFY(textEdit->canPaste());
textEdit->paste();
QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textEdit->text().length(), 24);
+ QCOMPARE(textEdit->text().size(), 24);
// canPaste
QVERIFY(textEdit->canPaste());
@@ -3063,7 +3116,7 @@ void tst_qquicktextedit::copyAndPaste()
QVERIFY(!textEdit->canPaste());
textEdit->paste();
QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textEdit->text().length(), 24);
+ QCOMPARE(textEdit->text().size(), 24);
textEdit->setReadOnly(false);
QVERIFY(textEdit->canPaste());
@@ -3091,10 +3144,10 @@ void tst_qquicktextedit::copyAndPaste()
// select all and cut
textEdit->selectAll();
textEdit->cut();
- QCOMPARE(textEdit->text().length(), 0);
+ QCOMPARE(textEdit->text().size(), 0);
textEdit->paste();
QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textEdit->text().length(), 24);
+ QCOMPARE(textEdit->text().size(), 24);
// Copy first word.
textEdit->setCursorPosition(0);
@@ -3180,7 +3233,7 @@ void tst_qquicktextedit::middleClickPaste()
QTest::mouseClick(&window, Qt::MiddleButton, Qt::NoModifier, p3);
if (QGuiApplication::clipboard()->supportsSelection())
- QCOMPARE(textEditObject->text().mid(1, selectedText.length()), selectedText);
+ QCOMPARE(textEditObject->text().mid(1, selectedText.size()), selectedText);
else
QCOMPARE(textEditObject->text(), originalText);
}
@@ -3210,7 +3263,7 @@ void tst_qquicktextedit::readOnly()
edit->setCursorPosition(3);
edit->setReadOnly(false);
QCOMPARE(edit->isReadOnly(), false);
- QCOMPARE(edit->cursorPosition(), edit->text().length());
+ QCOMPARE(edit->cursorPosition(), edit->text().size());
}
void tst_qquicktextedit::inFlickableMouse_data()
@@ -3357,7 +3410,7 @@ void tst_qquicktextedit::textInput()
event.setCommitString( "Hello world!", 0, 0);
QGuiApplication::sendEvent(edit, &event);
QCOMPARE(edit->text(), QString("Hello world!"));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// QTBUG-12339
// test that document and internal text attribute are in sync
@@ -3527,7 +3580,7 @@ void tst_qquicktextedit::openInputPanel()
anotherEdit.setFocus(true);
QCOMPARE(qApp->inputMethod()->isVisible(), true);
QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherEdit));
- QCOMPARE(inputPanelVisibilitySpy.count(), 0);
+ QCOMPARE(inputPanelVisibilitySpy.size(), 0);
anotherEdit.setFocus(false);
QVERIFY(qApp->focusObject() != &anotherEdit);
@@ -3643,18 +3696,18 @@ void tst_qquicktextedit::contentSize()
QVERIFY(textObject->contentWidth() > textObject->width());
QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
textObject->setWrapMode(QQuickTextEdit::WordWrap);
QVERIFY(textObject->contentWidth() <= textObject->width());
QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
QVERIFY(textObject->contentWidth() > textObject->width());
QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
void tst_qquicktextedit::implicitSizeBinding_data()
@@ -3823,6 +3876,40 @@ void tst_qquicktextedit::largeTextObservesViewport()
QCOMPARE(textPriv->cursorItem->isVisible(), textPriv->renderedRegion.intersects(textItem->cursorRectangle()));
}
+void tst_qquicktextedit::renderingAroundSelection()
+{
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("threeLines.qml")));
+ NodeCheckerTextEdit *textItem = qmlobject_cast<NodeCheckerTextEdit*>(window.rootObject());
+ QVERIFY(textItem);
+ QTRY_VERIFY(textItem->linePositions.size() > 0);
+ const auto linePositions = textItem->linePositions;
+ const int lastLinePosition = textItem->lastLinePosition;
+ QQuickTextEditPrivate *textPriv = QQuickTextEditPrivate::get(textItem);
+ QSignalSpy renderSpy(&window, &QQuickWindow::afterRendering);
+
+ if (lcTests().isDebugEnabled())
+ QTest::qWait(500); // for visual check; not needed in CI
+
+ const int renderCount = renderSpy.size();
+ QPoint p1 = textItem->mapToScene(textItem->positionToRectangle(8).center()).toPoint();
+ QPoint p2 = textItem->mapToScene(textItem->positionToRectangle(10).center()).toPoint();
+ qCDebug(lcTests) << "drag from" << p1 << "to" << p2;
+ QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTest::mouseMove(&window, p2);
+ QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p2);
+ // ensure that QQuickTextEdit::updatePaintNode() has a chance to run
+ QTRY_COMPARE_GT(renderSpy.size(), renderCount);
+
+ if (lcTests().isDebugEnabled())
+ QTest::qWait(500); // for visual check; not needed in CI
+
+ qCDebug(lcTests) << "TextEdit's nodes" << textPriv->textNodeMap;
+ qCDebug(lcTests) << "font" << textItem->font() << "line positions" << textItem->linePositions << "should be" << linePositions;
+ QCOMPARE(textItem->lastLinePosition, lastLinePosition);
+ QTRY_COMPARE(textItem->linePositions, linePositions);
+}
+
void tst_qquicktextedit::signal_editingfinished()
{
QQuickView *window = new QQuickView(nullptr);
@@ -3851,7 +3938,7 @@ void tst_qquicktextedit::signal_editingfinished()
QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
QGuiApplication::sendEvent(window, &key);
QVERIFY(key.isAccepted());
- QTRY_COMPARE(editingFinished1Spy.count(), 1);
+ QTRY_COMPARE(editingFinished1Spy.size(), 1);
QTRY_VERIFY(!input1->hasActiveFocus());
QTRY_VERIFY(input2->hasActiveFocus());
@@ -3867,7 +3954,7 @@ void tst_qquicktextedit::signal_editingfinished()
QKeyEvent key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
QGuiApplication::sendEvent(window, &key);
QVERIFY(key.isAccepted());
- QTRY_COMPARE(editingFinished2Spy.count(), 1);
+ QTRY_COMPARE(editingFinished2Spy.size(), 1);
QTRY_VERIFY(input1->hasActiveFocus());
QTRY_VERIFY(!input2->hasActiveFocus());
@@ -4071,7 +4158,7 @@ void tst_qquicktextedit::preeditCursorRectangle()
// Verify that the micro focus rect is positioned the same for position 0 as
// it would be if there was no preedit text.
QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
- << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, preeditText.length(), QVariant()));
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, preeditText.size(), QVariant()));
QCoreApplication::sendEvent(edit, &imEvent);
QCoreApplication::sendEvent(edit, &query);
currentRect = query.value(Qt::ImCursorRectangle).toRectF();
@@ -4085,15 +4172,15 @@ void tst_qquicktextedit::preeditCursorRectangle()
panelSpy.clear();
for (int i = 1; i <= 5; ++i) {
QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
- << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, preeditText.length(), QVariant()));
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, preeditText.size(), QVariant()));
QCoreApplication::sendEvent(edit, &imEvent);
QCoreApplication::sendEvent(edit, &query);
currentRect = query.value(Qt::ImCursorRectangle).toRectF();
QCOMPARE(edit->cursorRectangle(), currentRect);
QCOMPARE(cursor->position(), currentRect.topLeft());
QVERIFY(previousRect.left() < currentRect.left());
- QCOMPARE(editSpy.count(), 1); editSpy.clear();
- QCOMPARE(panelSpy.count(), 1); panelSpy.clear();
+ QCOMPARE(editSpy.size(), 1); editSpy.clear();
+ QCOMPARE(panelSpy.size(), 1); panelSpy.clear();
previousRect = currentRect;
}
@@ -4108,8 +4195,8 @@ void tst_qquicktextedit::preeditCursorRectangle()
currentRect = query.value(Qt::ImCursorRectangle).toRectF();
QCOMPARE(edit->cursorRectangle(), currentRect);
QCOMPARE(cursor->position(), currentRect.topLeft());
- QCOMPARE(editSpy.count(), 1);
- QCOMPARE(panelSpy.count(), 1);
+ QCOMPARE(editSpy.size(), 1);
+ QCOMPARE(panelSpy.size(), 1);
// Verify that if there is no preedit cursor then the micro focus rect is the
// same as it would be if it were positioned at the end of the preedit text.
@@ -4122,8 +4209,8 @@ void tst_qquicktextedit::preeditCursorRectangle()
QCOMPARE(edit->cursorRectangle(), currentRect);
QCOMPARE(cursor->position(), currentRect.topLeft());
QCOMPARE(currentRect, previousRect);
- QCOMPARE(editSpy.count(), 1);
- QCOMPARE(panelSpy.count(), 1);
+ QCOMPARE(editSpy.size(), 1);
+ QCOMPARE(panelSpy.size(), 1);
}
void tst_qquicktextedit::inputMethodComposing()
@@ -4150,37 +4237,37 @@ void tst_qquicktextedit::inputMethodComposing()
}
QCOMPARE(edit->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
{
QInputMethodEvent event(text.mid(12), QList<QInputMethodEvent::Attribute>());
QGuiApplication::sendEvent(edit, &event);
}
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
{
QInputMethodEvent event;
QGuiApplication::sendEvent(edit, &event);
}
QCOMPARE(edit->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
// Changing the text while not composing doesn't alter the composing state.
edit->setText(text.mid(0, 16));
QCOMPARE(edit->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
{
QInputMethodEvent event(text.mid(16), QList<QInputMethodEvent::Attribute>());
QGuiApplication::sendEvent(edit, &event);
}
QCOMPARE(edit->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
// Changing the text while composing cancels composition.
edit->setText(text.mid(0, 12));
QCOMPARE(edit->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
{ // Preedit cursor positioned outside (empty) preedit; composing.
QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>()
@@ -4188,7 +4275,7 @@ void tst_qquicktextedit::inputMethodComposing()
QGuiApplication::sendEvent(edit, &event);
}
QCOMPARE(edit->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
{ // Cursor hidden; composing
QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>()
@@ -4196,7 +4283,7 @@ void tst_qquicktextedit::inputMethodComposing()
QGuiApplication::sendEvent(edit, &event);
}
QCOMPARE(edit->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
{ // Default cursor attributes; composing.
QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>()
@@ -4204,7 +4291,7 @@ void tst_qquicktextedit::inputMethodComposing()
QGuiApplication::sendEvent(edit, &event);
}
QCOMPARE(edit->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
{ // Selections are persisted: not composing
QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>()
@@ -4212,7 +4299,7 @@ void tst_qquicktextedit::inputMethodComposing()
QGuiApplication::sendEvent(edit, &event);
}
QCOMPARE(edit->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
edit->setCursorPosition(0);
@@ -4224,14 +4311,14 @@ void tst_qquicktextedit::inputMethodComposing()
QGuiApplication::sendEvent(edit, &event);
}
QCOMPARE(edit->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 7);
+ QCOMPARE(spy.size(), 7);
{
QInputMethodEvent event;
QGuiApplication::sendEvent(edit, &event);
}
QCOMPARE(edit->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 8);
+ QCOMPARE(spy.size(), 8);
}
void tst_qquicktextedit::cursorRectangleSize_data()
@@ -4307,7 +4394,7 @@ void tst_qquicktextedit::getText_data()
QTest::newRow("all plain text")
<< standard.at(0)
- << 0 << standard.at(0).length()
+ << 0 << standard.at(0).size()
<< standard.at(0);
QTest::newRow("plain text sub string")
@@ -4327,17 +4414,17 @@ void tst_qquicktextedit::getText_data()
QTest::newRow("plain text cropped end")
<< standard.at(0)
- << 23 << standard.at(0).length() + 8
+ << 23 << standard.at(0).size() + 8
<< standard.at(0).mid(23);
QTest::newRow("plain text cropped beginning and end")
<< standard.at(0)
- << -9 << standard.at(0).length() + 4
+ << -9 << standard.at(0).size() + 4
<< standard.at(0);
QTest::newRow("all rich text")
<< richBoldText
- << 0 << plainBoldText.length()
+ << 0 << plainBoldText.size()
<< plainBoldText;
QTest::newRow("rich text sub string")
@@ -4348,7 +4435,7 @@ void tst_qquicktextedit::getText_data()
// Line break.
QTest::newRow("all plain text (line break)")
<< standard.at(1)
- << 0 << standard.at(1).length()
+ << 0 << standard.at(1).size()
<< standard.at(1);
QTest::newRow("plain text sub string (line break)")
@@ -4368,17 +4455,17 @@ void tst_qquicktextedit::getText_data()
QTest::newRow("plain text cropped end (line break)")
<< standard.at(1)
- << 23 << standard.at(1).length() + 8
+ << 23 << standard.at(1).size() + 8
<< standard.at(1).mid(23);
QTest::newRow("plain text cropped beginning and end (line break)")
<< standard.at(1)
- << -9 << standard.at(1).length() + 4
+ << -9 << standard.at(1).size() + 4
<< standard.at(1);
QTest::newRow("all rich text (line break)")
<< richBoldTextLB
- << 0 << plainBoldTextLB.length()
+ << 0 << plainBoldTextLB.size()
<< plainBoldTextLB;
QTest::newRow("rich text sub string (line break)")
@@ -4417,7 +4504,7 @@ void tst_qquicktextedit::getFormattedText_data()
QTest::newRow("all plain text")
<< standard.at(0)
<< QQuickTextEdit::PlainText
- << 0 << standard.at(0).length()
+ << 0 << standard.at(0).size()
<< standard.at(0);
QTest::newRow("plain text sub string")
@@ -4441,31 +4528,31 @@ void tst_qquicktextedit::getFormattedText_data()
QTest::newRow("plain text cropped end")
<< standard.at(0)
<< QQuickTextEdit::PlainText
- << 23 << standard.at(0).length() + 8
+ << 23 << standard.at(0).size() + 8
<< standard.at(0).mid(23);
QTest::newRow("plain text cropped beginning and end")
<< standard.at(0)
<< QQuickTextEdit::PlainText
- << -9 << standard.at(0).length() + 4
+ << -9 << standard.at(0).size() + 4
<< standard.at(0);
QTest::newRow("all rich (Auto) text")
<< richBoldText
<< QQuickTextEdit::AutoText
- << 0 << plainBoldText.length()
+ << 0 << plainBoldText.size()
<< QString("This is some \\<.*\\>bold\\</.*\\> text");
QTest::newRow("all rich (Rich) text")
<< richBoldText
<< QQuickTextEdit::RichText
- << 0 << plainBoldText.length()
+ << 0 << plainBoldText.size()
<< QString("This is some \\<.*\\>bold\\</.*\\> text");
QTest::newRow("all rich (Plain) text")
<< richBoldText
<< QQuickTextEdit::PlainText
- << 0 << richBoldText.length()
+ << 0 << richBoldText.size()
<< richBoldText;
QTest::newRow("rich (Auto) text sub string")
@@ -4544,10 +4631,10 @@ void tst_qquicktextedit::append_data()
QTest::newRow("cursor follows (end)")
<< standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).size() << standard.at(0).size()
<< QString("Hello")
<< standard.at(0) + QString("\nHello")
- << standard.at(0).length() + 6 << standard.at(0).length() + 6 << standard.at(0).length() + 6
+ << standard.at(0).size() + 6 << standard.at(0).size() + 6 << standard.at(0).size() + 6
<< false << true;
QTest::newRow("selection kept intact (beginning)")
@@ -4568,10 +4655,10 @@ void tst_qquicktextedit::append_data()
QTest::newRow("selection kept intact, cursor follows (end)")
<< standard.at(0) << QQuickTextEdit::PlainText
- << 18 << standard.at(0).length()
+ << 18 << standard.at(0).size()
<< QString("Hello")
<< standard.at(0) + QString("\nHello")
- << 18 << standard.at(0).length() + 6 << standard.at(0).length() + 6
+ << 18 << standard.at(0).size() + 6 << standard.at(0).size() + 6
<< true << true;
QTest::newRow("reversed selection kept intact")
@@ -4657,12 +4744,12 @@ void tst_qquicktextedit::append()
if (textFormat == QQuickTextEdit::RichText || textFormat == QQuickTextEdit::MarkdownText ||
(textFormat == QQuickTextEdit::AutoText &&
(Qt::mightBeRichText(text) || Qt::mightBeRichText(appendText)))) {
- QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
+ QCOMPARE(textEdit->getText(0, expectedText.size()), expectedText);
} else {
QCOMPARE(textEdit->text(), expectedText);
}
- QCOMPARE(textEdit->length(), expectedText.length());
+ QCOMPARE(textEdit->length(), expectedText.size());
QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
@@ -4671,11 +4758,11 @@ void tst_qquicktextedit::append()
if (selectionStart > selectionEnd)
qSwap(selectionStart, selectionEnd);
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
- QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
+ QCOMPARE(selectionSpy.size() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.size() > 0, selectionStart != expectedSelectionStart);
+ QCOMPARE(selectionEndSpy.size() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.size() > 0, text != expectedText);
+ QCOMPARE(cursorPositionSpy.size() > 0, cursorPositionChanged);
}
void tst_qquicktextedit::insert_data()
@@ -4703,10 +4790,10 @@ void tst_qquicktextedit::insert_data()
QTest::newRow("at cursor position (end)")
<< standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).size() << standard.at(0).size() << standard.at(0).size()
<< QString("Hello")
<< standard.at(0) + QString("Hello")
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << standard.at(0).size() + 5 << standard.at(0).size() + 5 << standard.at(0).size() + 5
<< false << true;
QTest::newRow("at cursor position (middle)")
@@ -4727,10 +4814,10 @@ void tst_qquicktextedit::insert_data()
QTest::newRow("before cursor position (end)")
<< standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length() << 18
+ << standard.at(0).size() << standard.at(0).size() << 18
<< QString("Hello")
<< standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << standard.at(0).size() + 5 << standard.at(0).size() + 5 << standard.at(0).size() + 5
<< false << true;
QTest::newRow("before cursor position (middle)")
@@ -4743,7 +4830,7 @@ void tst_qquicktextedit::insert_data()
QTest::newRow("after cursor position (middle)")
<< standard.at(0) << QQuickTextEdit::PlainText
- << 18 << 18 << standard.at(0).length()
+ << 18 << 18 << standard.at(0).size()
<< QString("Hello")
<< standard.at(0) + QString("Hello")
<< 18 << 18 << 18
@@ -4767,7 +4854,7 @@ void tst_qquicktextedit::insert_data()
QTest::newRow("after selection")
<< standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 19 << standard.at(0).length()
+ << 14 << 19 << standard.at(0).size()
<< QString("Hello")
<< standard.at(0) + QString("Hello")
<< 14 << 19 << 19
@@ -4775,7 +4862,7 @@ void tst_qquicktextedit::insert_data()
QTest::newRow("after reversed selection")
<< standard.at(0) << QQuickTextEdit::PlainText
- << 19 << 14 << standard.at(0).length()
+ << 19 << 14 << standard.at(0).size()
<< QString("Hello")
<< standard.at(0) + QString("Hello")
<< 14 << 19 << 14
@@ -4831,7 +4918,7 @@ void tst_qquicktextedit::insert_data()
QTest::newRow("past end")
<< standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0 << standard.at(0).length() + 3
+ << 0 << 0 << standard.at(0).size() + 3
<< QString("Hello")
<< standard.at(0)
<< 0 << 0 << 0
@@ -4906,12 +4993,12 @@ void tst_qquicktextedit::insert()
if (textFormat == QQuickTextEdit::RichText || textFormat == QQuickTextEdit::MarkdownText ||
(textFormat == QQuickTextEdit::AutoText &&
(Qt::mightBeRichText(text) || Qt::mightBeRichText(insertText)))) {
- QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
+ QCOMPARE(textEdit->getText(0, expectedText.size()), expectedText);
qCDebug(lcTests) << "with formatting:" << textEdit->getFormattedText(0, 100);
} else {
QCOMPARE(textEdit->text(), expectedText);
}
- QCOMPARE(textEdit->length(), expectedText.length());
+ QCOMPARE(textEdit->length(), expectedText.size());
QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
@@ -4920,11 +5007,11 @@ void tst_qquicktextedit::insert()
if (selectionStart > selectionEnd)
qSwap(selectionStart, selectionEnd);
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
- QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
+ QCOMPARE(selectionSpy.size() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.size() > 0, selectionStart != expectedSelectionStart);
+ QCOMPARE(selectionEndSpy.size() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.size() > 0, text != expectedText);
+ QCOMPARE(cursorPositionSpy.size() > 0, cursorPositionChanged);
}
void tst_qquicktextedit::remove_data()
@@ -4963,18 +5050,18 @@ void tst_qquicktextedit::remove_data()
QTest::newRow("to cursor position (end)")
<< standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() << standard.at(0).length() - 5
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << standard.at(0).size() << standard.at(0).size()
+ << standard.at(0).size() << standard.at(0).size() - 5
+ << standard.at(0).mid(0, standard.at(0).size() - 5)
+ << standard.at(0).size() - 5 << standard.at(0).size() - 5 << standard.at(0).size() - 5
<< false << true;
QTest::newRow("to cursor position (end)")
<< standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << standard.at(0).size() << standard.at(0).size()
+ << standard.at(0).size() - 5 << standard.at(0).size()
+ << standard.at(0).mid(0, standard.at(0).size() - 5)
+ << standard.at(0).size() - 5 << standard.at(0).size() - 5 << standard.at(0).size() - 5
<< false << true;
QTest::newRow("from cursor position (middle)")
@@ -5003,10 +5090,10 @@ void tst_qquicktextedit::remove_data()
QTest::newRow("before cursor position (end)")
<< standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).size() << standard.at(0).size()
<< 18 << 23
<< standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << standard.at(0).size() - 5 << standard.at(0).size() - 5 << standard.at(0).size() - 5
<< false << true;
QTest::newRow("before cursor position (middle)")
@@ -5044,16 +5131,16 @@ void tst_qquicktextedit::remove_data()
QTest::newRow("after selection")
<< standard.at(0) << QQuickTextEdit::PlainText
<< 14 << 19
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).size() - 5 << standard.at(0).size()
+ << standard.at(0).mid(0, standard.at(0).size() - 5)
<< 14 << 19 << 19
<< false << false;
QTest::newRow("after reversed selection")
<< standard.at(0) << QQuickTextEdit::PlainText
<< 19 << 14
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).size() - 5 << standard.at(0).size()
+ << standard.at(0).mid(0, standard.at(0).size() - 5)
<< 14 << 19 << 14
<< false << false;
@@ -5084,7 +5171,7 @@ void tst_qquicktextedit::remove_data()
QTest::newRow("plain text cropped end")
<< standard.at(0) << QQuickTextEdit::PlainText
<< 0 << 0
- << 23 << standard.at(0).length() + 8
+ << 23 << standard.at(0).size() + 8
<< standard.at(0).mid(0, 23)
<< 0 << 0 << 0
<< false << false;
@@ -5092,7 +5179,7 @@ void tst_qquicktextedit::remove_data()
QTest::newRow("plain text cropped beginning and end")
<< standard.at(0) << QQuickTextEdit::PlainText
<< 0 << 0
- << -9 << standard.at(0).length() + 4
+ << -9 << standard.at(0).size() + 4
<< QString()
<< 0 << 0 << 0
<< false << false;
@@ -5100,7 +5187,7 @@ void tst_qquicktextedit::remove_data()
QTest::newRow("all rich text")
<< richBoldText << QQuickTextEdit::RichText
<< 0 << 0
- << 0 << plainBoldText.length()
+ << 0 << plainBoldText.size()
<< QString()
<< 0 << 0 << 0
<< false << false;
@@ -5148,11 +5235,11 @@ void tst_qquicktextedit::remove()
if (textFormat == QQuickTextEdit::RichText
|| (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) {
- QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
+ QCOMPARE(textEdit->getText(0, expectedText.size()), expectedText);
} else {
QCOMPARE(textEdit->text(), expectedText);
}
- QCOMPARE(textEdit->length(), expectedText.length());
+ QCOMPARE(textEdit->length(), expectedText.size());
if (selectionStart > selectionEnd) //
qSwap(selectionStart, selectionEnd);
@@ -5161,14 +5248,14 @@ void tst_qquicktextedit::remove()
QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition);
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
+ QCOMPARE(selectionSpy.size() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.size() > 0, selectionStart != expectedSelectionStart);
+ QCOMPARE(selectionEndSpy.size() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.size() > 0, text != expectedText);
if (cursorPositionChanged) //
- QVERIFY(cursorPositionSpy.count() > 0);
+ QVERIFY(cursorPositionSpy.size() > 0);
}
#if QT_CONFIG(shortcut)
@@ -5507,11 +5594,11 @@ void tst_qquicktextedit::undo()
// QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier);
}
- for (int j = 0; j < insertString.at(i).length(); j++)
+ for (int j = 0; j < insertString.at(i).size(); j++)
QTest::keyClick(&window, insertString.at(i).at(j).toLatin1());
}
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// STEP 2: Next call undo several times and see if we can restore to the previous state
for (i = 0; i < expectedString.size() - 1; ++i) {
@@ -5523,7 +5610,7 @@ void tst_qquicktextedit::undo()
// STEP 3: Verify that we have undone everything
QVERIFY(textEdit->text().isEmpty());
QVERIFY(!textEdit->canUndo());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_qquicktextedit::redo_data()
@@ -5584,13 +5671,13 @@ void tst_qquicktextedit::redo()
for (i = 0; i < insertString.size(); ++i) {
if (insertIndex[i] > -1)
textEdit->setCursorPosition(insertIndex[i]);
- for (int j = 0; j < insertString.at(i).length(); j++)
+ for (int j = 0; j < insertString.at(i).size(); j++)
QTest::keyClick(&window, insertString.at(i).at(j).toLatin1());
QVERIFY(textEdit->canUndo());
QVERIFY(!textEdit->canRedo());
}
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// undo everything
while (!textEdit->text().isEmpty()) {
@@ -5599,7 +5686,7 @@ void tst_qquicktextedit::redo()
QVERIFY(textEdit->canRedo());
}
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
for (i = 0; i < expectedString.size(); ++i) {
QVERIFY(textEdit->canRedo());
@@ -5608,7 +5695,7 @@ void tst_qquicktextedit::redo()
QVERIFY(textEdit->canUndo());
}
QVERIFY(!textEdit->canRedo());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
#if QT_CONFIG(shortcut)
@@ -5830,12 +5917,12 @@ void tst_qquicktextedit::clear()
textEdit->clear();
QVERIFY(textEdit->text().isEmpty());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// checks that clears can be undone
textEdit->undo();
QVERIFY(!textEdit->canUndo());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(textEdit->text(), QString("I am Legend"));
textEdit->setCursorPosition(4);
@@ -5847,12 +5934,12 @@ void tst_qquicktextedit::clear()
textEdit->clear();
QVERIFY(textEdit->text().isEmpty());
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
// checks that clears can be undone
textEdit->undo();
QVERIFY(!textEdit->canUndo());
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
QCOMPARE(textEdit->text(), QString("I am Legend"));
textEdit->setText(QString("<i>I am Legend</i>"));
@@ -5860,11 +5947,11 @@ void tst_qquicktextedit::clear()
textEdit->clear();
QVERIFY(textEdit->text().isEmpty());
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
// checks that clears can be undone
textEdit->undo();
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
QCOMPARE(textEdit->text(), QString("<i>I am Legend</i>"));
}
@@ -5883,15 +5970,15 @@ void tst_qquicktextedit::baseUrl()
textObject->setBaseUrl(localUrl);
QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
textObject->setBaseUrl(remoteUrl);
QCOMPARE(textObject->baseUrl(), remoteUrl);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
textObject->resetBaseUrl();
QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_qquicktextedit::embeddedImages_data()
@@ -5989,7 +6076,7 @@ void tst_qquicktextedit::cursorRectangle_QTBUG_38947()
QRectF rect = edit->positionToRectangle(i);
QTest::mouseMove(&window, rect.center().toPoint());
QCOMPARE(edit->cursorRectangle(), rect);
- QCOMPARE(spy.count(), i);
+ QCOMPARE(spy.size(), i);
}
QPoint to = edit->positionToRectangle(edit->length() - 1).center().toPoint();
@@ -6018,13 +6105,13 @@ void tst_qquicktextedit::doubleSelect_QTBUG_38704()
QSignalSpy selectionSpy(textEdit, SIGNAL(selectedTextChanged()));
textEdit->select(0,1); //Select some text initially
- QCOMPARE(selectionSpy.count(), 1);
+ QCOMPARE(selectionSpy.size(), 1);
textEdit->select(0,1); //No change to selection start/end
- QCOMPARE(selectionSpy.count(), 1);
+ QCOMPARE(selectionSpy.size(), 1);
textEdit->select(0,2); //Change selection end
- QCOMPARE(selectionSpy.count(), 2);
+ QCOMPARE(selectionSpy.size(), 2);
textEdit->select(1,2); //Change selection start
- QCOMPARE(selectionSpy.count(), 3);
+ QCOMPARE(selectionSpy.size(), 3);
}
void tst_qquicktextedit::padding()
@@ -6210,28 +6297,28 @@ void tst_qquicktextedit::keyEventPropagation()
QQuickTextEdit *textEdit = root->findChild<QQuickTextEdit *>();
QVERIFY(textEdit->hasActiveFocus());
simulateKey(&view, Qt::Key_Back);
- QCOMPARE(downSpy.count(), 1);
- QCOMPARE(upSpy.count(), 1);
+ QCOMPARE(downSpy.size(), 1);
+ QCOMPARE(upSpy.size(), 1);
auto downKey = downSpy.takeFirst();
auto upKey = upSpy.takeFirst();
QCOMPARE(downKey.at(0).toInt(), Qt::Key_Back);
QCOMPARE(upKey.at(0).toInt(), Qt::Key_Back);
simulateKey(&view, Qt::Key_Shift);
- QCOMPARE(downSpy.count(), 1);
- QCOMPARE(upSpy.count(), 1);
+ QCOMPARE(downSpy.size(), 1);
+ QCOMPARE(upSpy.size(), 1);
downKey = downSpy.takeFirst();
upKey = upSpy.takeFirst();
QCOMPARE(downKey.at(0).toInt(), Qt::Key_Shift);
QCOMPARE(upKey.at(0).toInt(), Qt::Key_Shift);
simulateKey(&view, Qt::Key_A);
- QCOMPARE(downSpy.count(), 0);
- QCOMPARE(upSpy.count(), 0);
+ QCOMPARE(downSpy.size(), 0);
+ QCOMPARE(upSpy.size(), 0);
simulateKey(&view, Qt::Key_Right);
- QCOMPARE(downSpy.count(), 0);
- QCOMPARE(upSpy.count(), 1);
+ QCOMPARE(downSpy.size(), 0);
+ QCOMPARE(upSpy.size(), 1);
upKey = upSpy.takeFirst();
QCOMPARE(upKey.at(0).toInt(), Qt::Key_Right);
}
@@ -6366,7 +6453,7 @@ void tst_qquicktextedit::touchscreenSetsFocusAndMovesCursor()
QVERIFY(top);
QQuickTextEdit *bottom = window.rootObject()->findChild<QQuickTextEdit*>("bottom");
QVERIFY(bottom);
- const auto len = bottom->text().length();
+ const auto len = bottom->text().size();
// tap the bottom field
QPoint p1 = bottom->mapToScene({6, 6}).toPoint();
@@ -6379,7 +6466,7 @@ void tst_qquicktextedit::touchscreenSetsFocusAndMovesCursor()
QVERIFY(!bottom->text().startsWith('q'));
QTest::keyClick(&window, Qt::Key_Q);
QVERIFY(bottom->text().startsWith('q'));
- QCOMPARE(bottom->text().length(), len + 1);
+ QCOMPARE(bottom->text().size(), len + 1);
QTest::touchEvent(&window, touchDevice).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
// the cursor gets moved on release, as long as TextInput's grab wasn't stolen (e.g. by Flickable)
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 54f650f86e..9475d63930 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -226,7 +226,7 @@ Q_DECLARE_METATYPE(KeyList)
void tst_qquicktextinput::simulateKeys(QWindow *window, const QList<Key> &keys)
{
- for (int i = 0; i < keys.count(); ++i) {
+ for (int i = 0; i < keys.size(); ++i) {
const Qt::KeyboardModifiers modifiers = keys.at(i).keyCombination.keyboardModifiers();
const QChar character = keys.at(i).character;
if (!character.isNull())
@@ -318,7 +318,7 @@ void tst_qquicktextinput::text()
QVERIFY(textinputObject != nullptr);
QCOMPARE(textinputObject->text(), standard.at(i));
- QCOMPARE(textinputObject->length(), standard.at(i).length());
+ QCOMPARE(textinputObject->length(), standard.at(i).size());
delete textinputObject;
}
@@ -470,36 +470,36 @@ void tst_qquicktextinput::color()
textInputObject->setColor(QColor("white"));
QCOMPARE(textInputObject->color(), QColor("white"));
- QCOMPARE(colorSpy.count(), 1);
+ QCOMPARE(colorSpy.size(), 1);
textInputObject->setSelectionColor(QColor("black"));
QCOMPARE(textInputObject->selectionColor(), QColor("black"));
- QCOMPARE(selectionColorSpy.count(), 1);
+ QCOMPARE(selectionColorSpy.size(), 1);
textInputObject->setSelectedTextColor(QColor("blue"));
QCOMPARE(textInputObject->selectedTextColor(), QColor("blue"));
- QCOMPARE(selectedTextColorSpy.count(), 1);
+ QCOMPARE(selectedTextColorSpy.size(), 1);
textInputObject->setColor(QColor("white"));
- QCOMPARE(colorSpy.count(), 1);
+ QCOMPARE(colorSpy.size(), 1);
textInputObject->setSelectionColor(QColor("black"));
- QCOMPARE(selectionColorSpy.count(), 1);
+ QCOMPARE(selectionColorSpy.size(), 1);
textInputObject->setSelectedTextColor(QColor("blue"));
- QCOMPARE(selectedTextColorSpy.count(), 1);
+ QCOMPARE(selectedTextColorSpy.size(), 1);
textInputObject->setColor(QColor("black"));
QCOMPARE(textInputObject->color(), QColor("black"));
- QCOMPARE(colorSpy.count(), 2);
+ QCOMPARE(colorSpy.size(), 2);
textInputObject->setSelectionColor(QColor("blue"));
QCOMPARE(textInputObject->selectionColor(), QColor("blue"));
- QCOMPARE(selectionColorSpy.count(), 2);
+ QCOMPARE(selectionColorSpy.size(), 2);
textInputObject->setSelectedTextColor(QColor("white"));
QCOMPARE(textInputObject->selectedTextColor(), QColor("white"));
- QCOMPARE(selectedTextColorSpy.count(), 2);
+ QCOMPARE(selectedTextColorSpy.size(), 2);
}
//test color
@@ -575,7 +575,7 @@ void tst_qquicktextinput::wrap()
delete textObject;
}
- for (int i = 0; i < standard.count(); i++) {
+ for (int i = 0; i < standard.size(); i++) {
QString componentStr = "import QtQuick 2.0\nTextInput { wrapMode: Text.WrapAnywhere; width: 30; text: \"" + standard.at(i) + "\" }";
QQmlComponent textComponent(&engine);
textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
@@ -605,14 +605,14 @@ void tst_qquicktextinput::wrap()
input->setWrapMode(QQuickTextInput::Wrap);
QCOMPARE(input->wrapMode(), QQuickTextInput::Wrap);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
input->setWrapMode(QQuickTextInput::Wrap);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
input->setWrapMode(QQuickTextInput::NoWrap);
QCOMPARE(input->wrapMode(), QQuickTextInput::NoWrap);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
}
@@ -648,7 +648,7 @@ void tst_qquicktextinput::selection()
QCOMPARE(textinputObject->selectionEnd(), 0);
QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->setCursorPosition(textinputObject->text().length() + 1);
+ textinputObject->setCursorPosition(textinputObject->text().size() + 1);
QCOMPARE(textinputObject->cursorPosition(), 0);
QCOMPARE(textinputObject->selectionStart(), 0);
QCOMPARE(textinputObject->selectionEnd(), 0);
@@ -708,7 +708,7 @@ void tst_qquicktextinput::selection()
QInputMethodEvent event("", attributes);
QGuiApplication::sendEvent(textinputObject, &event);
}
- QCOMPARE(selectionSpy.count(), 1);
+ QCOMPARE(selectionSpy.size(), 1);
QCOMPARE(textinputObject->selectionStart(), 12);
QCOMPARE(textinputObject->selectionEnd(), 17);
@@ -732,7 +732,7 @@ void tst_qquicktextinput::persistentSelection()
input->setPersistentSelection(false);
QCOMPARE(input->persistentSelection(), false);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
input->select(1, 4);
QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
@@ -745,7 +745,7 @@ void tst_qquicktextinput::persistentSelection()
input->setPersistentSelection(true);
QCOMPARE(input->persistentSelection(), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
input->select(1, 4);
QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
@@ -776,25 +776,25 @@ void tst_qquicktextinput::overwriteMode()
QVERIFY(textInput->hasActiveFocus());
textInput->setOverwriteMode(true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(true, textInput->overwriteMode());
textInput->setOverwriteMode(false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(false, textInput->overwriteMode());
QVERIFY(!textInput->overwriteMode());
QString insertString = "Some first text";
- for (int j = 0; j < insertString.length(); j++)
+ for (int j = 0; j < insertString.size(); j++)
QTest::keyClick(&window, insertString.at(j).toLatin1());
QCOMPARE(textInput->text(), QString("Some first text"));
textInput->setOverwriteMode(true);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
textInput->setCursorPosition(5);
insertString = "shiny";
- for (int j = 0; j < insertString.length(); j++)
+ for (int j = 0; j < insertString.size(); j++)
QTest::keyClick(&window, insertString.at(j).toLatin1());
QCOMPARE(textInput->text(), QString("Some shiny text"));
}
@@ -836,24 +836,24 @@ void tst_qquicktextinput::isRightToLeft()
// first test that the right string is delivered to the QString::isRightToLeft()
QCOMPARE(textInput.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
QCOMPARE(textInput.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.length()-2, text.length()-1), text.mid(text.length()-2, text.length()-1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.length()/2, text.length()/2 + 1), text.mid(text.length()/2, text.length()/2 + 1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(0,text.length()/4), text.mid(0,text.length()/4).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.length()/4,3*text.length()/4), text.mid(text.length()/4,3*text.length()/4).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(text.size()-2, text.size()-1), text.mid(text.size()-2, text.size()-1).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(text.size()/2, text.size()/2 + 1), text.mid(text.size()/2, text.size()/2 + 1).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(0,text.size()/4), text.mid(0,text.size()/4).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(text.size()/4,3*text.size()/4), text.mid(text.size()/4,3*text.size()/4).isRightToLeft());
if (text.isEmpty())
QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textInput.isRightToLeft(3*text.length()/4,text.length()-1), text.mid(3*text.length()/4,text.length()-1).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(3*text.size()/4,text.size()-1), text.mid(3*text.size()/4,text.size()-1).isRightToLeft());
// then test that the feature actually works
QCOMPARE(textInput.isRightToLeft(0,0), emptyString);
QCOMPARE(textInput.isRightToLeft(0,1), firstCharacter);
- QCOMPARE(textInput.isRightToLeft(text.length()-2, text.length()-1), lastCharacter);
- QCOMPARE(textInput.isRightToLeft(text.length()/2, text.length()/2 + 1), middleCharacter);
- QCOMPARE(textInput.isRightToLeft(0,text.length()/4), startString);
- QCOMPARE(textInput.isRightToLeft(text.length()/4,3*text.length()/4), midString);
+ QCOMPARE(textInput.isRightToLeft(text.size()-2, text.size()-1), lastCharacter);
+ QCOMPARE(textInput.isRightToLeft(text.size()/2, text.size()/2 + 1), middleCharacter);
+ QCOMPARE(textInput.isRightToLeft(0,text.size()/4), startString);
+ QCOMPARE(textInput.isRightToLeft(text.size()/4,3*text.size()/4), midString);
if (text.isEmpty())
QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textInput.isRightToLeft(3*text.length()/4,text.length()-1), endString);
+ QCOMPARE(textInput.isRightToLeft(3*text.size()/4,text.size()-1), endString);
}
void tst_qquicktextinput::moveCursorSelection_data()
@@ -1289,8 +1289,8 @@ void tst_qquicktextinput::dragMouseSelection()
QTest::mouseMove(&window, QPoint(x2, y));
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(x2,y));
QString str1;
- QTRY_VERIFY((str1 = textInputObject->selectedText()).length() > 3);
- QTRY_VERIFY(str1.length() > 3);
+ QTRY_VERIFY((str1 = textInputObject->selectedText()).size() > 3);
+ QTRY_VERIFY(str1.size() > 3);
// press and drag the current selection.
x1 = 40;
@@ -1299,7 +1299,7 @@ void tst_qquicktextinput::dragMouseSelection()
QTest::mouseMove(&window, QPoint(x2, y));
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(x2,y));
QString str2 = textInputObject->selectedText();
- QTRY_VERIFY(str2.length() > 3);
+ QTRY_VERIFY(str2.size() > 3);
QTRY_VERIFY(str1 != str2);
}
@@ -1355,7 +1355,7 @@ void tst_qquicktextinput::mouseSelectionMode()
if (selectWords) {
QTRY_COMPARE(textInputObject->selectedText(), text);
} else {
- QTRY_VERIFY(textInputObject->selectedText().length() > 3);
+ QTRY_VERIFY(textInputObject->selectedText().size() > 3);
QVERIFY(textInputObject->selectedText() != text);
}
}
@@ -1374,14 +1374,14 @@ void tst_qquicktextinput::mouseSelectionMode_accessors()
input->setMouseSelectionMode(QQuickTextInput::SelectWords);
QCOMPARE(input->mouseSelectionMode(), QQuickTextInput::SelectWords);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
input->setMouseSelectionMode(QQuickTextInput::SelectWords);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
input->setMouseSelectionMode(QQuickTextInput::SelectCharacters);
QCOMPARE(input->mouseSelectionMode(), QQuickTextInput::SelectCharacters);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_qquicktextinput::selectByMouse()
@@ -1398,15 +1398,15 @@ void tst_qquicktextinput::selectByMouse()
input->setSelectByMouse(true);
QCOMPARE(input->selectByMouse(), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), true);
input->setSelectByMouse(true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
input->setSelectByMouse(false);
QCOMPARE(input->selectByMouse(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(spy.at(1).at(0).toBool(), false);
}
@@ -1424,14 +1424,14 @@ void tst_qquicktextinput::renderType()
input->setRenderType(QQuickTextInput::NativeRendering);
QCOMPARE(input->renderType(), QQuickTextInput::NativeRendering);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
input->setRenderType(QQuickTextInput::NativeRendering);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
input->setRenderType(QQuickTextInput::QtRendering);
QCOMPARE(input->renderType(), QQuickTextInput::QtRendering);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_qquicktextinput::horizontalAlignment_RightToLeft()
@@ -1541,7 +1541,7 @@ void tst_qquicktextinput::horizontalAlignment_RightToLeft()
QSignalSpy cursorRectangleSpy(textInput, SIGNAL(cursorRectangleChanged()));
platformInputContext.setInputDirection(Qt::RightToLeft);
QCOMPARE(qApp->inputMethod()->inputDirection(), Qt::RightToLeft);
- QCOMPARE(cursorRectangleSpy.count(), 1);
+ QCOMPARE(cursorRectangleSpy.size(), 1);
QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
QVERIFY(textInput->boundingRect().right() >= textInput->width() - 1);
QVERIFY(textInput->boundingRect().right() <= textInput->width() + 1);
@@ -1876,15 +1876,15 @@ void tst_qquicktextinput::maxLength()
QVERIFY(textinputObject->text().isEmpty());
QCOMPARE(textinputObject->maxLength(), 10);
foreach (const QString &str, standard) {
- QVERIFY(textinputObject->text().length() <= 10);
+ QVERIFY(textinputObject->text().size() <= 10);
textinputObject->setText(str);
- QVERIFY(textinputObject->text().length() <= 10);
+ QVERIFY(textinputObject->text().size() <= 10);
}
textinputObject->setText("");
QTRY_VERIFY(textinputObject->hasActiveFocus());
for (int i=0; i<20; i++) {
- QTRY_COMPARE(textinputObject->text().length(), qMin(i,10));
+ QTRY_COMPARE(textinputObject->text().size(), qMin(i,10));
QTest::keyClick(&window, Qt::Key_A);
}
}
@@ -1900,11 +1900,11 @@ void tst_qquicktextinput::masks()
QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(window.rootObject());
QVERIFY(textinputObject != nullptr);
QTRY_VERIFY(textinputObject->hasActiveFocus());
- QCOMPARE(textinputObject->text().length(), 0);
+ QCOMPARE(textinputObject->text().size(), 0);
QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
QCOMPARE(textinputObject->length(), 8);
for (int i=0; i<10; i++) {
- QTRY_COMPARE(qMin(i,8), textinputObject->text().length());
+ QTRY_COMPARE(qMin(i,8), textinputObject->text().size());
QCOMPARE(textinputObject->length(), 8);
QCOMPARE(textinputObject->getText(0, qMin(i, 8)), QString(qMin(i, 8), 'a'));
QCOMPARE(textinputObject->getText(qMin(i, 8), 8), QString(8 - qMin(i, 8), ' '));
@@ -1956,10 +1956,10 @@ void tst_qquicktextinput::validators()
QTRY_COMPARE(intInput->text(), QLatin1String("1"));
QCOMPARE(intInput->hasAcceptableInput(), false);
QCOMPARE(intInput->property("acceptable").toBool(), false);
- QCOMPARE(intSpy.count(), 0);
+ QCOMPARE(intSpy.size(), 0);
QCOMPARE(intInput->hasAcceptableInput(), false);
QCOMPARE(intInput->property("acceptable").toBool(), false);
- QCOMPARE(intSpy.count(), 0);
+ QCOMPARE(intSpy.size(), 0);
QTest::keyPress(&window, Qt::Key_Period);
QTest::keyRelease(&window, Qt::Key_Period, Qt::NoModifier);
QTRY_COMPARE(intInput->text(), QLatin1String("1"));
@@ -1987,13 +1987,13 @@ void tst_qquicktextinput::validators()
QCOMPARE(intInput->text(), QLatin1String("11"));
QCOMPARE(intInput->hasAcceptableInput(), true);
QCOMPARE(intInput->property("acceptable").toBool(), true);
- QCOMPARE(intSpy.count(), 1);
+ QCOMPARE(intSpy.size(), 1);
QTest::keyPress(&window, Qt::Key_0);
QTest::keyRelease(&window, Qt::Key_0, Qt::NoModifier);
QCOMPARE(intInput->text(), QLatin1String("11"));
QCOMPARE(intInput->hasAcceptableInput(), true);
QCOMPARE(intInput->property("acceptable").toBool(), true);
- QCOMPARE(intSpy.count(), 1);
+ QCOMPARE(intSpy.size(), 1);
QQuickTextInput *dblInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(window.rootObject()->property("dblInput")));
QVERIFY(dblInput);
@@ -2019,13 +2019,13 @@ void tst_qquicktextinput::validators()
QTRY_COMPARE(dblInput->text(), QLatin1String("1"));
QCOMPARE(dblInput->hasAcceptableInput(), false);
QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 0);
+ QCOMPARE(dblSpy.size(), 0);
QTest::keyPress(&window, Qt::Key_2);
QTest::keyRelease(&window, Qt::Key_2, Qt::NoModifier);
QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
QCOMPARE(dblInput->hasAcceptableInput(), true);
QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1);
+ QCOMPARE(dblSpy.size(), 1);
QTest::keyPress(&window, Qt::Key_Comma);
QTest::keyRelease(&window, Qt::Key_Comma, Qt::NoModifier);
QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
@@ -2066,84 +2066,84 @@ void tst_qquicktextinput::validators()
QTRY_COMPARE(dblInput->text(), QLatin1String("12."));
QCOMPARE(dblInput->hasAcceptableInput(), true);
QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1 + extraSignals);
+ QCOMPARE(dblSpy.size(), 1 + extraSignals);
QTest::keyPress(&window, Qt::Key_1);
QTest::keyRelease(&window, Qt::Key_1, Qt::NoModifier);
QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
QCOMPARE(dblInput->hasAcceptableInput(), true);
QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1 + extraSignals);
+ QCOMPARE(dblSpy.size(), 1 + extraSignals);
QTest::keyPress(&window, Qt::Key_1);
QTest::keyRelease(&window, Qt::Key_1, Qt::NoModifier);
QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
QCOMPARE(dblInput->hasAcceptableInput(), true);
QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1 + extraSignals);
+ QCOMPARE(dblSpy.size(), 1 + extraSignals);
QTest::keyPress(&window, Qt::Key_1);
QTest::keyRelease(&window, Qt::Key_1, Qt::NoModifier);
QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
QCOMPARE(dblInput->hasAcceptableInput(), true);
QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1 + extraSignals);
+ QCOMPARE(dblSpy.size(), 1 + extraSignals);
// Ensure the validator doesn't prevent characters being removed.
dblInput->setValidator(intInput->validator());
QCOMPARE(dblInput->text(), QLatin1String("12.11"));
QCOMPARE(dblInput->hasAcceptableInput(), false);
QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2 + extraSignals);
+ QCOMPARE(dblSpy.size(), 2 + extraSignals);
QTest::keyPress(&window, Qt::Key_Backspace);
QTest::keyRelease(&window, Qt::Key_Backspace, Qt::NoModifier);
QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
QCOMPARE(dblInput->hasAcceptableInput(), false);
QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2 + extraSignals);
+ QCOMPARE(dblSpy.size(), 2 + extraSignals);
// Once unacceptable input is in anything goes until it reaches an acceptable state again.
QTest::keyPress(&window, Qt::Key_1);
QTest::keyRelease(&window, Qt::Key_1, Qt::NoModifier);
QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblSpy.count(), 2 + extraSignals);
+ QCOMPARE(dblSpy.size(), 2 + extraSignals);
QTest::keyPress(&window, Qt::Key_Backspace);
QTest::keyRelease(&window, Qt::Key_Backspace, Qt::NoModifier);
QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
QCOMPARE(dblInput->hasAcceptableInput(), false);
QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2 + extraSignals);
+ QCOMPARE(dblSpy.size(), 2 + extraSignals);
QTest::keyPress(&window, Qt::Key_Backspace);
QTest::keyRelease(&window, Qt::Key_Backspace, Qt::NoModifier);
QTRY_COMPARE(dblInput->text(), QLatin1String("12."));
QCOMPARE(dblInput->hasAcceptableInput(), false);
QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2 + extraSignals);
+ QCOMPARE(dblSpy.size(), 2 + extraSignals);
QTest::keyPress(&window, Qt::Key_Backspace);
QTest::keyRelease(&window, Qt::Key_Backspace, Qt::NoModifier);
QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
QCOMPARE(dblInput->hasAcceptableInput(), false);
QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2 + extraSignals);
+ QCOMPARE(dblSpy.size(), 2 + extraSignals);
QTest::keyPress(&window, Qt::Key_Backspace);
QTest::keyRelease(&window, Qt::Key_Backspace, Qt::NoModifier);
QTRY_COMPARE(dblInput->text(), QLatin1String("1"));
QCOMPARE(dblInput->hasAcceptableInput(), false);
QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2 + extraSignals);
+ QCOMPARE(dblSpy.size(), 2 + extraSignals);
QTest::keyPress(&window, Qt::Key_1);
QTest::keyRelease(&window, Qt::Key_1, Qt::NoModifier);
QCOMPARE(dblInput->text(), QLatin1String("11"));
QCOMPARE(dblInput->property("acceptable").toBool(), true);
QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblSpy.count(), 3 + extraSignals);
+ QCOMPARE(dblSpy.size(), 3 + extraSignals);
// Changing the validator properties will re-evaluate whether the input is acceptable.
intValidator->setTop(10);
QCOMPARE(dblInput->property("acceptable").toBool(), false);
QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblSpy.count(), 4 + extraSignals);
+ QCOMPARE(dblSpy.size(), 4 + extraSignals);
intValidator->setTop(12);
QCOMPARE(dblInput->property("acceptable").toBool(), true);
QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblSpy.count(), 5 + extraSignals);
+ QCOMPARE(dblSpy.size(), 5 + extraSignals);
QQuickTextInput *strInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(window.rootObject()->property("strInput")));
QVERIFY(strInput);
@@ -2157,37 +2157,37 @@ void tst_qquicktextinput::validators()
QTRY_COMPARE(strInput->text(), QLatin1String(""));
QCOMPARE(strInput->hasAcceptableInput(), false);
QCOMPARE(strInput->property("acceptable").toBool(), false);
- QCOMPARE(strSpy.count(), 0);
+ QCOMPARE(strSpy.size(), 0);
QTest::keyPress(&window, Qt::Key_A);
QTest::keyRelease(&window, Qt::Key_A, Qt::NoModifier);
QTRY_COMPARE(strInput->text(), QLatin1String("a"));
QCOMPARE(strInput->hasAcceptableInput(), false);
QCOMPARE(strInput->property("acceptable").toBool(), false);
- QCOMPARE(strSpy.count(), 0);
+ QCOMPARE(strSpy.size(), 0);
QTest::keyPress(&window, Qt::Key_A);
QTest::keyRelease(&window, Qt::Key_A, Qt::NoModifier);
QTRY_COMPARE(strInput->text(), QLatin1String("aa"));
QCOMPARE(strInput->hasAcceptableInput(), true);
QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
+ QCOMPARE(strSpy.size(), 1);
QTest::keyPress(&window, Qt::Key_A);
QTest::keyRelease(&window, Qt::Key_A, Qt::NoModifier);
QTRY_COMPARE(strInput->text(), QLatin1String("aaa"));
QCOMPARE(strInput->hasAcceptableInput(), true);
QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
+ QCOMPARE(strSpy.size(), 1);
QTest::keyPress(&window, Qt::Key_A);
QTest::keyRelease(&window, Qt::Key_A, Qt::NoModifier);
QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
QCOMPARE(strInput->hasAcceptableInput(), true);
QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
+ QCOMPARE(strSpy.size(), 1);
QTest::keyPress(&window, Qt::Key_A);
QTest::keyRelease(&window, Qt::Key_A, Qt::NoModifier);
QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
QCOMPARE(strInput->hasAcceptableInput(), true);
QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
+ QCOMPARE(strSpy.size(), 1);
QQuickTextInput *unvalidatedInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(window.rootObject()->property("unvalidatedInput")));
QVERIFY(unvalidatedInput);
@@ -2201,13 +2201,13 @@ void tst_qquicktextinput::validators()
QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1"));
QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
- QCOMPARE(unvalidatedSpy.count(), 0);
+ QCOMPARE(unvalidatedSpy.size(), 0);
QTest::keyPress(&window, Qt::Key_A);
QTest::keyRelease(&window, Qt::Key_A, Qt::NoModifier);
QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1a"));
QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
- QCOMPARE(unvalidatedSpy.count(), 0);
+ QCOMPARE(unvalidatedSpy.size(), 0);
}
void tst_qquicktextinput::inputMethods()
@@ -2225,9 +2225,9 @@ void tst_qquicktextinput::inputMethods()
QSignalSpy inputMethodHintSpy(input, SIGNAL(inputMethodHintsChanged()));
input->setInputMethodHints(Qt::ImhUppercaseOnly);
QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
+ QCOMPARE(inputMethodHintSpy.size(), 1);
input->setInputMethodHints(Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
+ QCOMPARE(inputMethodHintSpy.size(), 1);
// default value
QQuickTextInput plainInput;
@@ -2286,8 +2286,8 @@ void tst_qquicktextinput::inputMethods()
// input should reset selection even if replacement parameters are out of bounds
input->setText("text");
input->setCursorPosition(0);
- input->moveCursorSelection(input->text().length());
- event.setCommitString("replacement", -input->text().length(), input->text().length());
+ input->moveCursorSelection(input->text().size());
+ event.setCommitString("replacement", -input->text().size(), input->text().size());
QGuiApplication::sendEvent(input, &event);
QCOMPARE(input->selectionStart(), input->selectionEnd());
QCOMPARE(input->text(), QString("replacement"));
@@ -2326,22 +2326,22 @@ void tst_qquicktextinput::signal_accepted()
QTRY_COMPARE(input->text(), QLatin1String("a"));
QCOMPARE(input->hasAcceptableInput(), false);
QCOMPARE(input->property("acceptable").toBool(), false);
- QTRY_COMPARE(inputSpy.count(), 0);
+ QTRY_COMPARE(inputSpy.size(), 0);
QTest::keyPress(&window, Qt::Key_Enter);
QTest::keyRelease(&window, Qt::Key_Enter, Qt::NoModifier);
- QTRY_COMPARE(acceptedSpy.count(), 0);
+ QTRY_COMPARE(acceptedSpy.size(), 0);
QTest::keyPress(&window, Qt::Key_A);
QTest::keyRelease(&window, Qt::Key_A, Qt::NoModifier);
QTRY_COMPARE(input->text(), QLatin1String("aa"));
QCOMPARE(input->hasAcceptableInput(), true);
QCOMPARE(input->property("acceptable").toBool(), true);
- QTRY_COMPARE(inputSpy.count(), 1);
+ QTRY_COMPARE(inputSpy.size(), 1);
QTest::keyPress(&window, Qt::Key_Enter);
QTest::keyRelease(&window, Qt::Key_Enter, Qt::NoModifier);
- QTRY_COMPARE(acceptedSpy.count(), 1);
+ QTRY_COMPARE(acceptedSpy.size(), 1);
}
void tst_qquicktextinput::signal_editingfinished()
@@ -2369,23 +2369,23 @@ void tst_qquicktextinput::signal_editingfinished()
QTRY_COMPARE(input1->text(), QLatin1String("a"));
QCOMPARE(input1->hasAcceptableInput(), false);
QCOMPARE(input1->property("acceptable").toBool(), false);
- QTRY_COMPARE(input1Spy.count(), 0);
+ QTRY_COMPARE(input1Spy.size(), 0);
QTest::keyPress(&window, Qt::Key_Enter);
QTest::keyRelease(&window, Qt::Key_Enter, Qt::NoModifier);
- QTRY_COMPARE(editingFinished1Spy.count(), 0);
+ QTRY_COMPARE(editingFinished1Spy.size(), 0);
QTest::keyPress(&window, Qt::Key_A);
QTest::keyRelease(&window, Qt::Key_A, Qt::NoModifier);
QTRY_COMPARE(input1->text(), QLatin1String("aa"));
QCOMPARE(input1->hasAcceptableInput(), true);
QCOMPARE(input1->property("acceptable").toBool(), true);
- QTRY_COMPARE(input1Spy.count(), 1);
+ QTRY_COMPARE(input1Spy.size(), 1);
QTest::keyPress(&window, Qt::Key_Enter);
QTest::keyRelease(&window, Qt::Key_Enter, Qt::NoModifier);
- QTRY_COMPARE(editingFinished1Spy.count(), 1);
- QTRY_COMPARE(input1Spy.count(), 1);
+ QTRY_COMPARE(editingFinished1Spy.size(), 1);
+ QTRY_COMPARE(input1Spy.size(), 1);
QSignalSpy editingFinished2Spy(input2, SIGNAL(editingFinished()));
QSignalSpy input2Spy(input2, SIGNAL(acceptableInputChanged()));
@@ -2399,19 +2399,19 @@ void tst_qquicktextinput::signal_editingfinished()
QTRY_COMPARE(input2->text(), QLatin1String("a"));
QCOMPARE(input2->hasAcceptableInput(), false);
QCOMPARE(input2->property("acceptable").toBool(), false);
- QTRY_COMPARE(input2Spy.count(), 0);
+ QTRY_COMPARE(input2Spy.size(), 0);
QTest::keyPress(&window, Qt::Key_A);
QTest::keyRelease(&window, Qt::Key_A, Qt::NoModifier);
QTRY_COMPARE(input2->text(), QLatin1String("aa"));
QCOMPARE(input2->hasAcceptableInput(), true);
QCOMPARE(input2->property("acceptable").toBool(), true);
- QTRY_COMPARE(input2Spy.count(), 1);
+ QTRY_COMPARE(input2Spy.size(), 1);
input1->setFocus(true);
QTRY_VERIFY(input1->hasActiveFocus());
QTRY_VERIFY(!input2->hasActiveFocus());
- QTRY_COMPARE(editingFinished2Spy.count(), 1);
+ QTRY_COMPARE(editingFinished2Spy.size(), 1);
}
void tst_qquicktextinput::signal_textEdited()
@@ -2437,32 +2437,32 @@ void tst_qquicktextinput::signal_textEdited()
int textEdits = 0;
QTest::keyClick(&window, Qt::Key_A);
- QCOMPARE(textChangedSpy.count(), ++textChanges);
- QCOMPARE(textEditedSpy.count(), ++textEdits);
+ QCOMPARE(textChangedSpy.size(), ++textChanges);
+ QCOMPARE(textEditedSpy.size(), ++textEdits);
QTest::keyClick(&window, Qt::Key_B);
- QCOMPARE(textChangedSpy.count(), ++textChanges);
- QCOMPARE(textEditedSpy.count(), ++textEdits);
+ QCOMPARE(textChangedSpy.size(), ++textChanges);
+ QCOMPARE(textEditedSpy.size(), ++textEdits);
QTest::keyClick(&window, Qt::Key_C);
- QCOMPARE(textChangedSpy.count(), ++textChanges);
- QCOMPARE(textEditedSpy.count(), ++textEdits);
+ QCOMPARE(textChangedSpy.size(), ++textChanges);
+ QCOMPARE(textEditedSpy.size(), ++textEdits);
QTest::keyClick(&window, Qt::Key_Space);
- QCOMPARE(textChangedSpy.count(), ++textChanges);
- QCOMPARE(textEditedSpy.count(), ++textEdits);
+ QCOMPARE(textChangedSpy.size(), ++textChanges);
+ QCOMPARE(textEditedSpy.size(), ++textEdits);
QTest::keyClick(&window, Qt::Key_Backspace);
- QCOMPARE(textChangedSpy.count(), ++textChanges);
- QCOMPARE(textEditedSpy.count(), ++textEdits);
+ QCOMPARE(textChangedSpy.size(), ++textChanges);
+ QCOMPARE(textEditedSpy.size(), ++textEdits);
input->clear();
- QCOMPARE(textChangedSpy.count(), ++textChanges);
- QCOMPARE(textEditedSpy.count(), textEdits);
+ QCOMPARE(textChangedSpy.size(), ++textChanges);
+ QCOMPARE(textEditedSpy.size(), textEdits);
input->setText("TextInput");
- QCOMPARE(textChangedSpy.count(), ++textChanges);
- QCOMPARE(textEditedSpy.count(), textEdits);
+ QCOMPARE(textChangedSpy.size(), ++textChanges);
+ QCOMPARE(textEditedSpy.size(), textEdits);
}
/*
@@ -2488,12 +2488,12 @@ void tst_qquicktextinput::navigation()
QTest::keyClick(&window, Qt::Key_Right);
QVERIFY(input->hasActiveFocus());
//QT-2944: If text is selected, ensure we deselect upon cursor motion
- input->setCursorPosition(input->text().length());
- input->select(0,input->text().length());
+ input->setCursorPosition(input->text().size());
+ input->select(0,input->text().size());
QVERIFY(input->selectionStart() != input->selectionEnd());
QTest::keyClick(&window, Qt::Key_Right);
QCOMPARE(input->selectionStart(), input->selectionEnd());
- QCOMPARE(input->selectionStart(), input->text().length());
+ QCOMPARE(input->selectionStart(), input->text().size());
QVERIFY(input->hasActiveFocus());
QTest::keyClick(&window, Qt::Key_Right);
QVERIFY(!input->hasActiveFocus());
@@ -2544,7 +2544,7 @@ void tst_qquicktextinput::navigation_RTL()
QTest::keyClick(&window, Qt::Key_Left);
QVERIFY(input->hasActiveFocus());
- input->setCursorPosition(input->text().length());
+ input->setCursorPosition(input->text().size());
QVERIFY(input->hasActiveFocus());
// move off
@@ -2569,16 +2569,16 @@ void tst_qquicktextinput::copyAndPaste()
QVERIFY(textInput != nullptr);
// copy and paste
- QCOMPARE(textInput->text().length(), 12);
- textInput->select(0, textInput->text().length());
+ QCOMPARE(textInput->text().size(), 12);
+ textInput->select(0, textInput->text().size());
textInput->copy();
QCOMPARE(textInput->selectedText(), QString("Hello world!"));
- QCOMPARE(textInput->selectedText().length(), 12);
+ QCOMPARE(textInput->selectedText().size(), 12);
textInput->setCursorPosition(0);
QTRY_VERIFY(textInput->canPaste());
textInput->paste();
QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
+ QCOMPARE(textInput->text().size(), 24);
// can paste
QVERIFY(textInput->canPaste());
@@ -2586,7 +2586,7 @@ void tst_qquicktextinput::copyAndPaste()
QVERIFY(!textInput->canPaste());
textInput->paste();
QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
+ QCOMPARE(textInput->text().size(), 24);
textInput->setReadOnly(false);
QVERIFY(textInput->canPaste());
@@ -2608,10 +2608,10 @@ void tst_qquicktextinput::copyAndPaste()
// select all and cut
textInput->selectAll();
textInput->cut();
- QCOMPARE(textInput->text().length(), 0);
+ QCOMPARE(textInput->text().size(), 0);
textInput->paste();
QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
+ QCOMPARE(textInput->text().size(), 24);
// Copy first word.
textInput->setCursorPosition(0);
@@ -2638,7 +2638,7 @@ void tst_qquicktextinput::copyAndPaste()
QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
textInput->setEchoMode(echoMode);
textInput->setText("My password");
- textInput->select(0, textInput->text().length());
+ textInput->select(0, textInput->text().size());
textInput->copy();
if (echoMode == QQuickTextInput::Normal) {
QVERIFY(!clipboard->text().isEmpty());
@@ -2674,24 +2674,24 @@ void tst_qquicktextinput::copyAndPasteKeySequence()
// copy and paste
QVERIFY(textInput->hasActiveFocus());
- QCOMPARE(textInput->text().length(), 12);
- textInput->select(0, textInput->text().length());
+ QCOMPARE(textInput->text().size(), 12);
+ textInput->select(0, textInput->text().size());
simulateKeys(&window, QKeySequence::Copy);
QCOMPARE(textInput->selectedText(), QString("Hello world!"));
- QCOMPARE(textInput->selectedText().length(), 12);
+ QCOMPARE(textInput->selectedText().size(), 12);
textInput->setCursorPosition(0);
QVERIFY(textInput->canPaste());
simulateKeys(&window, QKeySequence::Paste);
QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
+ QCOMPARE(textInput->text().size(), 24);
// select all and cut
simulateKeys(&window, QKeySequence::SelectAll);
simulateKeys(&window, QKeySequence::Cut);
- QCOMPARE(textInput->text().length(), 0);
+ QCOMPARE(textInput->text().size(), 0);
simulateKeys(&window, QKeySequence::Paste);
QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
+ QCOMPARE(textInput->text().size(), 24);
// clear copy buffer
QClipboard *clipboard = QGuiApplication::clipboard();
@@ -2706,7 +2706,7 @@ void tst_qquicktextinput::copyAndPasteKeySequence()
QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
textInput->setEchoMode(echoMode);
textInput->setText("My password");
- textInput->select(0, textInput->text().length());
+ textInput->select(0, textInput->text().size());
simulateKeys(&window, QKeySequence::Copy);
if (echoMode == QQuickTextInput::Normal) {
QVERIFY(!clipboard->text().isEmpty());
@@ -2733,7 +2733,7 @@ void tst_qquicktextinput::canPasteEmpty()
QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
QVERIFY(textInput != nullptr);
- bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0;
+ bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().size() != 0;
QCOMPARE(textInput->canPaste(), cp);
}
#endif
@@ -2749,7 +2749,7 @@ void tst_qquicktextinput::canPaste()
QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
QVERIFY(textInput != nullptr);
- bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0;
+ bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().size() != 0;
QCOMPARE(textInput->canPaste(), cp);
}
#endif
@@ -2792,7 +2792,7 @@ void tst_qquicktextinput::middleClickPaste()
QTest::qWait(QGuiApplication::styleHints()->mouseDoubleClickInterval() + 10);
if (QGuiApplication::clipboard()->supportsSelection())
- QCOMPARE(textInputObject->text().mid(1, selectedText.length()), selectedText);
+ QCOMPARE(textInputObject->text().mid(1, selectedText.size()), selectedText);
else
QCOMPARE(textInputObject->text(), originalText);
}
@@ -2844,7 +2844,7 @@ void tst_qquicktextinput::cursorDelegate()
QVERIFY(delegateObject);
QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
//Test Delegate gets moved
- for (int i=0; i<= textInputObject->text().length(); i++) {
+ for (int i=0; i<= textInputObject->text().size(); i++) {
textInputObject->setCursorPosition(i);
QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x());
QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y());
@@ -2982,27 +2982,27 @@ void tst_qquicktextinput::cursorVisible()
input.setCursorVisible(true);
QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
input.setCursorVisible(false);
QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
input.setFocus(true);
QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
input.setParentItem(view.rootObject());
QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
input.setFocus(false);
QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
input.setFocus(true);
QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
QQuickView alternateView;
alternateView.show();
@@ -3010,12 +3010,12 @@ void tst_qquicktextinput::cursorVisible()
QVERIFY(QTest::qWaitForWindowActive(&alternateView));
QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
view.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 7);
+ QCOMPARE(spy.size(), 7);
{ // Cursor attribute with 0 length hides cursor.
QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>()
@@ -3023,7 +3023,7 @@ void tst_qquicktextinput::cursorVisible()
QCoreApplication::sendEvent(&input, &ev);
}
QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 8);
+ QCOMPARE(spy.size(), 8);
{ // Cursor attribute with non zero length shows cursor.
QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>()
@@ -3031,7 +3031,7 @@ void tst_qquicktextinput::cursorVisible()
QCoreApplication::sendEvent(&input, &ev);
}
QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 9);
+ QCOMPARE(spy.size(), 9);
{ // If the cursor is hidden by the input method and the text is changed it should be visible again.
QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>()
@@ -3039,11 +3039,11 @@ void tst_qquicktextinput::cursorVisible()
QCoreApplication::sendEvent(&input, &ev);
}
QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 10);
+ QCOMPARE(spy.size(), 10);
input.setText("something");
QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 11);
+ QCOMPARE(spy.size(), 11);
{ // If the cursor is hidden by the input method and the cursor position is changed it should be visible again.
QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>()
@@ -3051,11 +3051,11 @@ void tst_qquicktextinput::cursorVisible()
QCoreApplication::sendEvent(&input, &ev);
}
QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 12);
+ QCOMPARE(spy.size(), 12);
input.setCursorPosition(5);
QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 13);
+ QCOMPARE(spy.size(), 13);
}
void tst_qquicktextinput::cursorRectangle_data()
@@ -3132,14 +3132,14 @@ void tst_qquicktextinput::cursorRectangle()
// Check the cursor rectangle remains within the input bounding rect when auto scrolling.
QCOMPARE(r.left(), leftToRight ? input.width() : 0);
- for (int i = positionAtWidth + 1; i < text.length(); ++i) {
+ for (int i = positionAtWidth + 1; i < text.size(); ++i) {
input.setCursorPosition(i);
QCOMPARE(r, input.cursorRectangle());
COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}
- for (int i = text.length() - 2; i >= 0; --i) {
+ for (int i = text.size() - 2; i >= 0; --i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
QCOMPARE(r.top(), 0.);
@@ -3178,7 +3178,7 @@ void tst_qquicktextinput::cursorRectangle()
COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(11), r);
- for (int i = wrapPosition + 1; i < text.length(); ++i) {
+ for (int i = wrapPosition + 1; i < text.size(); ++i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
QVERIFY(r.top() >= line.height() - 5);
@@ -3219,7 +3219,7 @@ void tst_qquicktextinput::cursorRectangle()
COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(11), r);
- for (int i = wrapPosition + 1; i < text.length(); ++i) {
+ for (int i = wrapPosition + 1; i < text.size(); ++i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
QVERIFY(r.bottom() >= input.height());
@@ -3227,7 +3227,7 @@ void tst_qquicktextinput::cursorRectangle()
QCOMPARE(input.positionToRectangle(i), r);
}
- for (int i = text.length() - 2; i >= wrapPosition; --i) {
+ for (int i = text.size() - 2; i >= wrapPosition; --i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
QVERIFY(r.bottom() >= input.height());
@@ -3268,7 +3268,7 @@ void tst_qquicktextinput::cursorRectangle()
widerText[1] = 'W'; // Assumes shortText is at least two characters long.
input.setText(widerText);
- QCOMPARE(cursorRectangleSpy.count(), 1);
+ QCOMPARE(cursorRectangleSpy.size(), 1);
}
void tst_qquicktextinput::readOnly()
@@ -3296,7 +3296,7 @@ void tst_qquicktextinput::readOnly()
input->setCursorPosition(3);
input->setReadOnly(false);
QCOMPARE(input->isReadOnly(), false);
- QCOMPARE(input->cursorPosition(), input->text().length());
+ QCOMPARE(input->cursorPosition(), input->text().size());
QVERIFY(input->isCursorVisible());
}
@@ -3418,7 +3418,7 @@ void tst_qquicktextinput::passwordEchoDelay()
QSignalSpy cursorSpy(input, SIGNAL(cursorRectangleChanged()));
QTest::qWait(maskDelay);
QTRY_COMPARE(input->displayText(), QString(5, fillChar));
- QCOMPARE(cursorSpy.count(), 1);
+ QCOMPARE(cursorSpy.size(), 1);
QCOMPARE(input->cursorRectangle().topLeft(), cursor->position());
QTest::keyPress(&window, '5');
@@ -3469,7 +3469,7 @@ void tst_qquicktextinput::focusOnPress()
textInputObject->setFocusOnPress(true);
QCOMPARE(textInputObject->focusOnPress(), true);
- QCOMPARE(activeFocusOnPressSpy.count(), 0);
+ QCOMPARE(activeFocusOnPressSpy.size(), 0);
QQuickWindow window;
window.resize(100, 50);
@@ -3486,20 +3486,20 @@ void tst_qquicktextinput::focusOnPress()
QGuiApplication::processEvents();
QCOMPARE(textInputObject->hasFocus(), true);
QCOMPARE(textInputObject->hasActiveFocus(), true);
- QCOMPARE(focusSpy.count(), 1);
- QCOMPARE(activeFocusSpy.count(), 1);
+ QCOMPARE(focusSpy.size(), 1);
+ QCOMPARE(activeFocusSpy.size(), 1);
QCOMPARE(textInputObject->selectedText(), QString());
QTest::mouseRelease(&window, Qt::LeftButton, noModifiers);
textInputObject->setFocusOnPress(false);
QCOMPARE(textInputObject->focusOnPress(), false);
- QCOMPARE(activeFocusOnPressSpy.count(), 1);
+ QCOMPARE(activeFocusOnPressSpy.size(), 1);
textInputObject->setFocus(false);
QCOMPARE(textInputObject->hasFocus(), false);
QCOMPARE(textInputObject->hasActiveFocus(), false);
- QCOMPARE(focusSpy.count(), 2);
- QCOMPARE(activeFocusSpy.count(), 2);
+ QCOMPARE(focusSpy.size(), 2);
+ QCOMPARE(activeFocusSpy.size(), 2);
// Wait for double click timeout to expire before clicking again.
QTest::qWait(400);
@@ -3507,13 +3507,13 @@ void tst_qquicktextinput::focusOnPress()
QGuiApplication::processEvents();
QCOMPARE(textInputObject->hasFocus(), false);
QCOMPARE(textInputObject->hasActiveFocus(), false);
- QCOMPARE(focusSpy.count(), 2);
- QCOMPARE(activeFocusSpy.count(), 2);
+ QCOMPARE(focusSpy.size(), 2);
+ QCOMPARE(activeFocusSpy.size(), 2);
QTest::mouseRelease(&window, Qt::LeftButton, noModifiers);
textInputObject->setFocusOnPress(true);
QCOMPARE(textInputObject->focusOnPress(), true);
- QCOMPARE(activeFocusOnPressSpy.count(), 2);
+ QCOMPARE(activeFocusOnPressSpy.size(), 2);
// Test a selection made in the on(Active)FocusChanged handler isn't overwritten.
textInputObject->setProperty("selectOnFocus", true);
@@ -3523,8 +3523,8 @@ void tst_qquicktextinput::focusOnPress()
QGuiApplication::processEvents();
QCOMPARE(textInputObject->hasFocus(), true);
QCOMPARE(textInputObject->hasActiveFocus(), true);
- QCOMPARE(focusSpy.count(), 3);
- QCOMPARE(activeFocusSpy.count(), 3);
+ QCOMPARE(focusSpy.size(), 3);
+ QCOMPARE(activeFocusSpy.size(), 3);
QCOMPARE(textInputObject->selectedText(), textInputObject->text());
QTest::mouseRelease(&window, Qt::LeftButton, noModifiers);
}
@@ -3615,7 +3615,7 @@ void tst_qquicktextinput::openInputPanel()
anotherInput.setFocus(true);
QCOMPARE(qApp->inputMethod()->isVisible(), true);
QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherInput));
- QCOMPARE(inputPanelVisibilitySpy.count(), 0);
+ QCOMPARE(inputPanelVisibilitySpy.size(), 0);
anotherInput.setFocus(false);
QVERIFY(qApp->focusObject() != &anotherInput);
@@ -3764,18 +3764,18 @@ void tst_qquicktextinput::contentSize()
QVERIFY(textObject->contentWidth() > textObject->width());
QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
textObject->setWrapMode(QQuickTextInput::WordWrap);
QVERIFY(textObject->contentWidth() <= textObject->width());
QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
QVERIFY(textObject->contentWidth() > textObject->width());
QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
textObject->setText("The quick red fox jumped over the lazy brown dog");
for (int w = 60; w < 120; ++w) {
@@ -3788,7 +3788,7 @@ void tst_qquicktextinput::contentSize()
static void sendPreeditText(QQuickItem *item, const QString &text, int cursor)
{
QInputMethodEvent event(text, QList<QInputMethodEvent::Attribute>()
- << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, text.length(), QVariant()));
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, text.size(), QVariant()));
QCoreApplication::sendEvent(item, &event);
}
@@ -3813,14 +3813,14 @@ void tst_qquicktextinput::preeditAutoScroll()
sendPreeditText(input, preeditText.mid(0, 3), 1);
QVERIFY(evaluate<int>(input, QString("positionAt(0)")) != 0);
QVERIFY(input->cursorRectangle().left() < input->boundingRect().width());
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QCOMPARE(cursorRectangleSpy.size(), ++cursorRectangleChanges);
// test the text is scrolled back when the preedit is removed.
QInputMethodEvent imEvent;
QCoreApplication::sendEvent(input, &imEvent);
QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(0)), 0);
QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(input->width())), 5);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QCOMPARE(cursorRectangleSpy.size(), ++cursorRectangleChanges);
QTextLayout layout(preeditText);
layout.setFont(input->font());
@@ -3841,7 +3841,7 @@ void tst_qquicktextinput::preeditAutoScroll()
int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i));
QVERIFY(input->cursorRectangle().right() >= width - 3);
QVERIFY(input->positionToRectangle(0).x() < x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QCOMPARE(cursorRectangleSpy.size(), ++cursorRectangleChanges);
x = input->positionToRectangle(0).x();
}
for (int i = 1; i >= 0; --i) {
@@ -3849,24 +3849,24 @@ void tst_qquicktextinput::preeditAutoScroll()
int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i));
QVERIFY(input->cursorRectangle().right() >= width - 3);
QVERIFY(input->positionToRectangle(0).x() > x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QCOMPARE(cursorRectangleSpy.size(), ++cursorRectangleChanges);
x = input->positionToRectangle(0).x();
}
// Test incrementing the preedit cursor doesn't cause further
// scrolling when right most text is visible.
- sendPreeditText(input, preeditText, preeditText.length() - 3);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ sendPreeditText(input, preeditText, preeditText.size() - 3);
+ QCOMPARE(cursorRectangleSpy.size(), ++cursorRectangleChanges);
x = input->positionToRectangle(0).x();
for (int i = 2; i >= 0; --i) {
- sendPreeditText(input, preeditText, preeditText.length() - i);
+ sendPreeditText(input, preeditText, preeditText.size() - i);
QCOMPARE(input->positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QCOMPARE(cursorRectangleSpy.size(), ++cursorRectangleChanges);
}
for (int i = 1; i < 3; ++i) {
- sendPreeditText(input, preeditText, preeditText.length() - i);
+ sendPreeditText(input, preeditText, preeditText.size() - i);
QCOMPARE(input->positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ QCOMPARE(cursorRectangleSpy.size(), ++cursorRectangleChanges);
}
// Test disabling auto scroll.
@@ -3920,8 +3920,8 @@ void tst_qquicktextinput::preeditCursorRectangle()
QVERIFY(previousRect.left() < currentRect.left());
QCOMPARE(input->cursorRectangle(), currentRect);
QCOMPARE(cursor->position(), currentRect.topLeft());
- QVERIFY(inputSpy.count() > 0); inputSpy.clear();
- QVERIFY(panelSpy.count() > 0); panelSpy.clear();
+ QVERIFY(inputSpy.size() > 0); inputSpy.clear();
+ QVERIFY(panelSpy.size() > 0); panelSpy.clear();
previousRect = currentRect;
}
@@ -3934,8 +3934,8 @@ void tst_qquicktextinput::preeditCursorRectangle()
currentRect = query.value(Qt::ImCursorRectangle).toRectF();
QCOMPARE(input->cursorRectangle(), currentRect);
QCOMPARE(cursor->position(), currentRect.topLeft());
- QCOMPARE(inputSpy.count(), 1);
- QCOMPARE(panelSpy.count(), 1);
+ QCOMPARE(inputSpy.size(), 1);
+ QCOMPARE(panelSpy.size(), 1);
// Verify that if there is no preedit cursor then the micro focus rect is the
// same as it would be if it were positioned at the end of the preedit text.
@@ -3948,8 +3948,8 @@ void tst_qquicktextinput::preeditCursorRectangle()
QCOMPARE(currentRect, previousRect);
QCOMPARE(input->cursorRectangle(), currentRect);
QCOMPARE(cursor->position(), currentRect.topLeft());
- QCOMPARE(inputSpy.count(), 1);
- QCOMPARE(panelSpy.count(), 1);
+ QCOMPARE(inputSpy.size(), 1);
+ QCOMPARE(panelSpy.size(), 1);
}
void tst_qquicktextinput::inputContextMouseHandler()
@@ -4016,37 +4016,37 @@ void tst_qquicktextinput::inputMethodComposing()
QGuiApplication::sendEvent(input, &event);
}
QCOMPARE(input->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
{
QInputMethodEvent event(text.mid(12), QList<QInputMethodEvent::Attribute>());
QGuiApplication::sendEvent(input, &event);
}
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
{
QInputMethodEvent event;
QGuiApplication::sendEvent(input, &event);
}
QCOMPARE(input->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
// Changing the text while not composing doesn't alter the composing state.
input->setText(text.mid(0, 16));
QCOMPARE(input->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
{
QInputMethodEvent event(text.mid(16), QList<QInputMethodEvent::Attribute>());
QGuiApplication::sendEvent(input, &event);
}
QCOMPARE(input->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
// Changing the text while composing cancels composition.
input->setText(text.mid(0, 12));
QCOMPARE(input->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
{ // Preedit cursor positioned outside (empty) preedit; composing.
QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>()
@@ -4054,7 +4054,7 @@ void tst_qquicktextinput::inputMethodComposing()
QGuiApplication::sendEvent(input, &event);
}
QCOMPARE(input->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
{ // Cursor hidden; composing
@@ -4063,7 +4063,7 @@ void tst_qquicktextinput::inputMethodComposing()
QGuiApplication::sendEvent(input, &event);
}
QCOMPARE(input->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
{ // Default cursor attributes; composing.
QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>()
@@ -4071,7 +4071,7 @@ void tst_qquicktextinput::inputMethodComposing()
QGuiApplication::sendEvent(input, &event);
}
QCOMPARE(input->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
{ // Selections are persisted: not composing
QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>()
@@ -4079,7 +4079,7 @@ void tst_qquicktextinput::inputMethodComposing()
QGuiApplication::sendEvent(input, &event);
}
QCOMPARE(input->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
input->setCursorPosition(12);
@@ -4091,14 +4091,14 @@ void tst_qquicktextinput::inputMethodComposing()
QGuiApplication::sendEvent(input, &event);
}
QCOMPARE(input->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 7);
+ QCOMPARE(spy.size(), 7);
{
QInputMethodEvent event;
QGuiApplication::sendEvent(input, &event);
}
QCOMPARE(input->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 8);
+ QCOMPARE(spy.size(), 8);
}
void tst_qquicktextinput::inputMethodUpdate()
@@ -4285,7 +4285,7 @@ void tst_qquicktextinput::getText_data()
QTest::newRow("all plain text")
<< standard.at(0)
<< QString()
- << 0 << standard.at(0).length()
+ << 0 << standard.at(0).size()
<< standard.at(0);
QTest::newRow("plain text sub string")
@@ -4309,13 +4309,13 @@ void tst_qquicktextinput::getText_data()
QTest::newRow("plain text cropped end")
<< standard.at(0)
<< QString()
- << 23 << standard.at(0).length() + 8
+ << 23 << standard.at(0).size() + 8
<< standard.at(0).mid(23);
QTest::newRow("plain text cropped beginning and end")
<< standard.at(0)
<< QString()
- << -9 << standard.at(0).length() + 4
+ << -9 << standard.at(0).size() + 4
<< standard.at(0);
}
@@ -4363,10 +4363,10 @@ void tst_qquicktextinput::insert_data()
QTest::newRow("at cursor position (end)")
<< standard.at(0)
<< QString()
- << standard.at(0).length() << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).size() << standard.at(0).size() << standard.at(0).size()
<< QString("Hello")
<< standard.at(0) + QString("Hello")
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << standard.at(0).size() + 5 << standard.at(0).size() + 5 << standard.at(0).size() + 5
<< false << true;
QTest::newRow("at cursor position (middle)")
@@ -4390,10 +4390,10 @@ void tst_qquicktextinput::insert_data()
QTest::newRow("before cursor position (end)")
<< standard.at(0)
<< QString()
- << standard.at(0).length() << standard.at(0).length() << 18
+ << standard.at(0).size() << standard.at(0).size() << 18
<< QString("Hello")
<< standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << standard.at(0).size() + 5 << standard.at(0).size() + 5 << standard.at(0).size() + 5
<< false << true;
QTest::newRow("before cursor position (middle)")
@@ -4408,7 +4408,7 @@ void tst_qquicktextinput::insert_data()
QTest::newRow("after cursor position (middle)")
<< standard.at(0)
<< QString()
- << 18 << 18 << standard.at(0).length()
+ << 18 << 18 << standard.at(0).size()
<< QString("Hello")
<< standard.at(0) + QString("Hello")
<< 18 << 18 << 18
@@ -4435,7 +4435,7 @@ void tst_qquicktextinput::insert_data()
QTest::newRow("after selection")
<< standard.at(0)
<< QString()
- << 14 << 19 << standard.at(0).length()
+ << 14 << 19 << standard.at(0).size()
<< QString("Hello")
<< standard.at(0) + QString("Hello")
<< 14 << 19 << 19
@@ -4444,7 +4444,7 @@ void tst_qquicktextinput::insert_data()
QTest::newRow("after reversed selection")
<< standard.at(0)
<< QString()
- << 19 << 14 << standard.at(0).length()
+ << 19 << 14 << standard.at(0).size()
<< QString("Hello")
<< standard.at(0) + QString("Hello")
<< 14 << 19 << 14
@@ -4489,7 +4489,7 @@ void tst_qquicktextinput::insert_data()
QTest::newRow("past end")
<< standard.at(0)
<< QString()
- << 0 << 0 << standard.at(0).length() + 3
+ << 0 << 0 << standard.at(0).size() + 3
<< QString("Hello")
<< standard.at(0)
<< 0 << 0 << 0
@@ -4510,10 +4510,10 @@ void tst_qquicktextinput::insert_data()
QTest::newRow("mask: at cursor position (end)")
<< ip
<< inputMask
- << inputMask.length() << inputMask.length() << inputMask.length()
+ << inputMask.size() << inputMask.size() << inputMask.size()
<< QString("8")
<< ip
- << inputMask.length() << inputMask.length() << inputMask.length()
+ << inputMask.size() << inputMask.size() << inputMask.size()
<< false << false;
QTest::newRow("mask: at cursor position (middle)")
@@ -4537,10 +4537,10 @@ void tst_qquicktextinput::insert_data()
QTest::newRow("mask: before cursor position (end)")
<< ip
<< inputMask
- << inputMask.length() << inputMask.length() << 6
+ << inputMask.size() << inputMask.size() << 6
<< QString("75.2")
<< QString("192.167.5.24")
- << inputMask.length() << inputMask.length() << inputMask.length()
+ << inputMask.size() << inputMask.size() << inputMask.size()
<< false << false;
QTest::newRow("mask: before cursor position (middle)")
@@ -4627,7 +4627,7 @@ void tst_qquicktextinput::insert_data()
QTest::newRow("mask: past end")
<< ip
<< inputMask
- << 0 << 0 << ip.length() + 3
+ << 0 << 0 << ip.size() + 3
<< QString("4")
<< ip
<< 0 << 0 << 0
@@ -4684,7 +4684,7 @@ void tst_qquicktextinput::insert()
textInput->insert(insertPosition, insertText);
QCOMPARE(textInput->text(), expectedText);
- QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length());
+ QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.size() : inputMask.size());
QCOMPARE(textInput->selectionStart(), expectedSelectionStart);
QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd);
@@ -4693,11 +4693,11 @@ void tst_qquicktextinput::insert()
if (selectionStart > selectionEnd)
qSwap(selectionStart, selectionEnd);
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
- QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
+ QCOMPARE(selectionSpy.size() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.size() > 0, selectionStart != expectedSelectionStart);
+ QCOMPARE(selectionEndSpy.size() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.size() > 0, text != expectedText);
+ QCOMPARE(cursorPositionSpy.size() > 0, cursorPositionChanged);
}
void tst_qquicktextinput::remove_data()
@@ -4736,19 +4736,19 @@ void tst_qquicktextinput::remove_data()
QTest::newRow("to cursor position (end)")
<< standard.at(0)
<< QString()
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() << standard.at(0).length() - 5
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << standard.at(0).size() << standard.at(0).size()
+ << standard.at(0).size() << standard.at(0).size() - 5
+ << standard.at(0).mid(0, standard.at(0).size() - 5)
+ << standard.at(0).size() - 5 << standard.at(0).size() - 5 << standard.at(0).size() - 5
<< false << true;
QTest::newRow("to cursor position (end)")
<< standard.at(0)
<< QString()
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << standard.at(0).size() << standard.at(0).size()
+ << standard.at(0).size() - 5 << standard.at(0).size()
+ << standard.at(0).mid(0, standard.at(0).size() - 5)
+ << standard.at(0).size() - 5 << standard.at(0).size() - 5 << standard.at(0).size() - 5
<< false << true;
QTest::newRow("from cursor position (middle)")
@@ -4781,10 +4781,10 @@ void tst_qquicktextinput::remove_data()
QTest::newRow("before cursor position (end)")
<< standard.at(0)
<< QString()
- << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).size() << standard.at(0).size()
<< 18 << 23
<< standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << standard.at(0).size() - 5 << standard.at(0).size() - 5 << standard.at(0).size() - 5
<< false << true;
QTest::newRow("before cursor position (middle)")
@@ -4827,8 +4827,8 @@ void tst_qquicktextinput::remove_data()
<< standard.at(0)
<< QString()
<< 14 << 19
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).size() - 5 << standard.at(0).size()
+ << standard.at(0).mid(0, standard.at(0).size() - 5)
<< 14 << 19 << 19
<< false << false;
@@ -4836,8 +4836,8 @@ void tst_qquicktextinput::remove_data()
<< standard.at(0)
<< QString()
<< 19 << 14
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).size() - 5 << standard.at(0).size()
+ << standard.at(0).mid(0, standard.at(0).size() - 5)
<< 14 << 19 << 14
<< false << false;
@@ -4872,7 +4872,7 @@ void tst_qquicktextinput::remove_data()
<< standard.at(0)
<< QString()
<< 0 << 0
- << 23 << standard.at(0).length() + 8
+ << 23 << standard.at(0).size() + 8
<< standard.at(0).mid(0, 23)
<< 0 << 0 << 0
<< false << false;
@@ -4881,7 +4881,7 @@ void tst_qquicktextinput::remove_data()
<< standard.at(0)
<< QString()
<< 0 << 0
- << -9 << standard.at(0).length() + 4
+ << -9 << standard.at(0).size() + 4
<< QString()
<< 0 << 0 << 0
<< false << false;
@@ -5039,7 +5039,7 @@ void tst_qquicktextinput::remove()
textInput->remove(removeStart, removeEnd);
QCOMPARE(textInput->text(), expectedText);
- QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length());
+ QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.size() : inputMask.size());
if (selectionStart > selectionEnd) //
qSwap(selectionStart, selectionEnd);
@@ -5048,13 +5048,13 @@ void tst_qquicktextinput::remove()
QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd);
QCOMPARE(textInput->cursorPosition(), expectedCursorPosition);
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
+ QCOMPARE(selectionSpy.size() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.size() > 0, selectionStart != expectedSelectionStart);
+ QCOMPARE(selectionEndSpy.size() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.size() > 0, text != expectedText);
if (cursorPositionChanged) //
- QVERIFY(cursorPositionSpy.count() > 0);
+ QVERIFY(cursorPositionSpy.size() > 0);
}
#if QT_CONFIG(shortcut)
@@ -5414,11 +5414,11 @@ void tst_qquicktextinput::undo()
// QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier);
}
- for (int j = 0; j < insertString.at(i).length(); j++)
+ for (int j = 0; j < insertString.at(i).size(); j++)
QTest::keyClick(&window, insertString.at(i).at(j).toLatin1());
}
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// STEP 2: Next call undo several times and see if we can restore to the previous state
for (i = 0; i < expectedString.size() - 1; ++i) {
@@ -5430,7 +5430,7 @@ void tst_qquicktextinput::undo()
// STEP 3: Verify that we have undone everything
QVERIFY(textInput->text().isEmpty());
QVERIFY(!textInput->canUndo());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_qquicktextinput::redo_data()
@@ -5491,13 +5491,13 @@ void tst_qquicktextinput::redo()
for (i = 0; i < insertString.size(); ++i) {
if (insertIndex[i] > -1)
textInput->setCursorPosition(insertIndex[i]);
- for (int j = 0; j < insertString.at(i).length(); j++)
+ for (int j = 0; j < insertString.at(i).size(); j++)
QTest::keyClick(&window, insertString.at(i).at(j).toLatin1());
QVERIFY(textInput->canUndo());
QVERIFY(!textInput->canRedo());
}
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// undo everything
while (!textInput->text().isEmpty()) {
@@ -5506,7 +5506,7 @@ void tst_qquicktextinput::redo()
QVERIFY(textInput->canRedo());
}
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
for (i = 0; i < expectedString.size(); ++i) {
QVERIFY(textInput->canRedo());
@@ -5515,7 +5515,7 @@ void tst_qquicktextinput::redo()
QVERIFY(textInput->canUndo());
}
QVERIFY(!textInput->canRedo());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
#if QT_CONFIG(shortcut)
@@ -5849,12 +5849,12 @@ void tst_qquicktextinput::clear()
textInput->clear();
QVERIFY(textInput->text().isEmpty());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// checks that clears can be undone
textInput->undo();
QVERIFY(!textInput->canUndo());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QCOMPARE(textInput->text(), QString("I am Legend"));
textInput->setCursorPosition(4);
@@ -5868,12 +5868,12 @@ void tst_qquicktextinput::clear()
QVERIFY(textInput->text().isEmpty());
QVERIFY2(textInput->preeditText().isEmpty(), "Pre-edit text must be empty after clear");
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
// checks that clears can be undone
textInput->undo();
QVERIFY(!textInput->canUndo());
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
QCOMPARE(textInput->text(), QString("I am Legend"));
QVERIFY2(textInput->preeditText().isEmpty(), "Pre-edit text must be empty after undo");
}
@@ -5890,7 +5890,7 @@ void tst_qquicktextinput::backspaceSurrogatePairs()
QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
QVERIFY(textInput != nullptr);
textInput->setText(text);
- textInput->setCursorPosition(text.length());
+ textInput->setCursorPosition(text.size());
QQuickWindow window;
textInput->setParentItem(window.contentItem());
@@ -5899,7 +5899,7 @@ void tst_qquicktextinput::backspaceSurrogatePairs()
QVERIFY(QTest::qWaitForWindowActive(&window));
QCOMPARE(QGuiApplication::focusWindow(), &window);
- for (int i = text.length(); i >= 0; i -= 2) {
+ for (int i = text.size(); i >= 0; i -= 2) {
QCOMPARE(textInput->text(), text.mid(0, i));
QTest::keyClick(&window, Qt::Key_Backspace, Qt::NoModifier);
}
@@ -5908,7 +5908,7 @@ void tst_qquicktextinput::backspaceSurrogatePairs()
textInput->setText(text);
textInput->setCursorPosition(0);
- for (int i = 0; i < text.length(); i += 2) {
+ for (int i = 0; i < text.size(); i += 2) {
QCOMPARE(textInput->text(), text.mid(i));
QTest::keyClick(&window, Qt::Key_Delete, Qt::NoModifier);
}
@@ -6397,7 +6397,7 @@ void tst_qquicktextinput::setInputMask()
unescapedMask.replace(QLatin1String("\\\\"), QLatin1String("\\")); // simple unescape
QSignalSpy spy(textInput, SIGNAL(inputMaskChanged(const QString &)));
textInput->setInputMask(unescapedMask);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// then either insert using insert() or keyboard
if (insert_text) {
@@ -6411,7 +6411,7 @@ void tst_qquicktextinput::setInputMask()
QVERIFY(textInput->hasActiveFocus());
QTest::keyClick(&window, Qt::Key_Home);
- for (int i = 0; i < input.length(); i++)
+ for (int i = 0; i < input.size(); i++)
QTest::keyClick(&window, input.at(i).toLatin1());
}
@@ -6891,7 +6891,7 @@ void tst_qquicktextinput::ensureVisible()
input->ensureVisible(input->length());
- QCOMPARE(cursorSpy.count(), 1);
+ QCOMPARE(cursorSpy.size(), 1);
QCOMPARE(input->boundingRect().x(), input->width() - line.naturalTextWidth());
QCOMPARE(input->boundingRect().y(), qreal(0));
@@ -7167,13 +7167,13 @@ void tst_qquicktextinput::touchscreenSetsFocusAndMovesCursor()
QQuickTouchUtils::flush(&window);
QCOMPARE(qApp->focusObject(), bottom);
// text cursor is at the end by default, on press
- const auto len = bottom->text().length();
+ const auto len = bottom->text().size();
QCOMPARE(bottom->cursorPosition(), len);
// so typing a character appends it
QVERIFY(!bottom->text().endsWith('q'));
QTest::keyClick(&window, Qt::Key_Q);
QVERIFY(bottom->text().endsWith('q'));
- QCOMPARE(bottom->text().length(), len + 1);
+ QCOMPARE(bottom->text().size(), len + 1);
QTest::touchEvent(&window, touchscreen.data()).release(0, QPoint(x1,y), &window);
QQuickTouchUtils::flush(&window);
// the cursor gets moved on release, as long as TextInput's grab wasn't stolen (e.g. by Flickable)
diff --git a/tests/auto/quick/qquicktreeview/testmodel.cpp b/tests/auto/quick/qquicktreeview/testmodel.cpp
index 50e326e108..9962234a06 100644
--- a/tests/auto/quick/qquicktreeview/testmodel.cpp
+++ b/tests/auto/quick/qquicktreeview/testmodel.cpp
@@ -38,8 +38,14 @@ void TestModel::createTreeRecursive(TreeItem *item, int childCount, int currentD
for (int col = 0; col < m_columnCount; ++col)
childItem->m_entries << QVariant(QString("%1, %2").arg(row).arg(col));
item->m_childItems.append(childItem);
- if (row == childCount - 1)
+ if (row == childCount - 2 && currentDepth != maxDepth()) {
+ // Add a branch that doesn't recurse
+ createTreeRecursive(childItem, childCount, maxDepth());
+ }
+ if (row == childCount - 1) {
+ // Add a branch that recurses
createTreeRecursive(childItem, childCount, currentDepth + 1);
+ }
}
}
@@ -54,7 +60,7 @@ int TestModel::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid())
return 1; // root of the tree
- return treeItem(parent)->m_childItems.count();
+ return treeItem(parent)->m_childItems.size();
}
int TestModel::columnCount(const QModelIndex &) const
diff --git a/tests/auto/quick/qquicktreeview/testmodel.h b/tests/auto/quick/qquicktreeview/testmodel.h
index e35a6e4f6a..4cb80d0eab 100644
--- a/tests/auto/quick/qquicktreeview/testmodel.h
+++ b/tests/auto/quick/qquicktreeview/testmodel.h
@@ -45,4 +45,6 @@ private:
int m_columnCount = 5;
};
+#define TestModelAsVariant(...) QVariant::fromValue(QSharedPointer<TestModel>(new TestModel(__VA_ARGS__)))
+
#endif // TESTMODEL_H
diff --git a/tests/auto/quick/qquicktreeview/tst_qquicktreeview.cpp b/tests/auto/quick/qquicktreeview/tst_qquicktreeview.cpp
index 1a775ed3c7..71aa10a518 100644
--- a/tests/auto/quick/qquicktreeview/tst_qquicktreeview.cpp
+++ b/tests/auto/quick/qquicktreeview/tst_qquicktreeview.cpp
@@ -79,6 +79,10 @@ private slots:
void selectionBehaviorRows();
void selectionBehaviorColumns();
void selectionBehaviorDisabled();
+ void sortTreeModel_data();
+ void sortTreeModel();
+ void sortTreeModelDynamic_data();
+ void sortTreeModelDynamic();
};
tst_qquicktreeview::tst_qquicktreeview()
@@ -136,7 +140,7 @@ void tst_qquicktreeview::expandAndCollapseRoot()
// Expand the root
treeView->expand(0);
- QCOMPARE(expandedSpy.count(), 1);
+ QCOMPARE(expandedSpy.size(), 1);
auto signalArgs = expandedSpy.takeFirst();
QVERIFY(signalArgs.at(0).toInt() == 0);
QVERIFY(signalArgs.at(1).toInt() == 1);
@@ -186,7 +190,7 @@ void tst_qquicktreeview::expandAndCollapseChildren()
treeView->expand(nodeToExpand);
- QCOMPARE(expandedSpy.count(), 1);
+ QCOMPARE(expandedSpy.size(), 1);
auto signalArgs = expandedSpy.takeFirst();
QVERIFY(signalArgs.at(0).toInt() == nodeToExpand);
QVERIFY(signalArgs.at(1).toInt() == 1);
@@ -297,7 +301,7 @@ void tst_qquicktreeview::requiredPropertiesChildren()
QCOMPARE(viewProp, treeView);
QCOMPARE(isTreeNode, true);
QCOMPARE(expanded, row == 4);
- QCOMPARE(hasChildren, row == 4 || row == 8);
+ QCOMPARE(hasChildren, model->hasChildren(treeView->index(row, 0)));
QCOMPARE(depth, row <= 4 ? 1 : 2);
}
}
@@ -310,7 +314,7 @@ void tst_qquicktreeview::emptyModel()
treeView->setModel(QVariant());
WAIT_UNTIL_POLISHED;
- QCOMPARE(treeViewPrivate->loadedItems.count(), 0);
+ QCOMPARE(treeViewPrivate->loadedItems.size(), 0);
QCOMPARE(treeView->rows(), 0);
QCOMPARE(treeView->columns(), 0);
@@ -320,7 +324,7 @@ void tst_qquicktreeview::emptyModel()
QCOMPARE(treeView->depth(0), -1);
QCOMPARE(treeView->isExpanded(0), false);
- QVERIFY(!treeView->modelIndex(10, 10).isValid());
+ QVERIFY(!treeView->index(10, 10).isValid());
QCOMPARE(treeView->rowAtIndex(QModelIndex()), -1);
QCOMPARE(treeView->columnAtIndex(QModelIndex()), -1);
}
@@ -431,10 +435,10 @@ void tst_qquicktreeview::expandRecursivelyRoot()
treeView->expandRecursively(rowToExpand, depth);
if (depth == 0) {
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
} else {
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
const auto signalArgs = spy.takeFirst();
QVERIFY(signalArgs.at(0).toInt() == rowToExpand);
QVERIFY(signalArgs.at(1).toInt() == depth);
@@ -453,7 +457,7 @@ void tst_qquicktreeview::expandRecursivelyRoot()
// Check that all rows after rowToExpand, that are also
// children of that row, is expanded (down to depth)
for (int currentRow = rowToExpand + 1; currentRow < treeView->rows(); ++currentRow) {
- const auto modelIndex = treeView->modelIndex(0, currentRow);
+ const auto modelIndex = treeView->index(currentRow, 0);
const int currentDepth = treeView->depth(currentRow);
const bool isChild = currentDepth > rowToExpandDepth;
const bool isExpandable = model->rowCount(modelIndex) > 0;
@@ -487,7 +491,7 @@ void tst_qquicktreeview::expandRecursivelyChild()
treeView->expand(0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
auto signalArgs = spy.takeFirst();
QVERIFY(signalArgs.at(0).toInt() == 0);
QVERIFY(signalArgs.at(1).toInt() == 1);
@@ -495,9 +499,9 @@ void tst_qquicktreeview::expandRecursivelyChild()
treeView->expandRecursively(rowToExpand, depth);
if (depth == 0) {
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
} else {
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
signalArgs = spy.takeFirst();
QVERIFY(signalArgs.at(0).toInt() == rowToExpand);
QVERIFY(signalArgs.at(1).toInt() == depth);
@@ -508,7 +512,7 @@ void tst_qquicktreeview::expandRecursivelyChild()
const bool rowToExpandDepth = treeView->depth(rowToExpand);
const int effectiveMaxDepth = depth != -1 ? rowToExpandDepth + depth : model->maxDepth();
- // Check that all rows before rowToExpand is not expanded
+ // Check that none of the rows before rowToExpand are expanded
// (except the root node)
for (int currentRow = 1; currentRow < rowToExpand; ++currentRow)
QVERIFY(!treeView->isExpanded(currentRow));
@@ -519,12 +523,12 @@ void tst_qquicktreeview::expandRecursivelyChild()
else
QVERIFY(!treeView->isExpanded(rowToExpand));
- // Check that all rows after rowToExpand that is also
- // children of that row is expanded (down to depth)
+ // Check that any row after rowToExpand, that is also
+ // a child of that row, is expanded (down to depth)
for (int currentRow = rowToExpand + 1; currentRow < treeView->rows(); ++currentRow) {
const int currentDepth = treeView->depth(currentRow);
const bool isChild = currentDepth > rowToExpandDepth;
- const auto modelIndex = treeView->modelIndex(0, currentRow);
+ const auto modelIndex = treeView->index(currentRow, 0);
const bool isExpandable = model->rowCount(modelIndex) > 0;
const bool shouldBeExpanded = isChild && isExpandable && currentDepth < effectiveMaxDepth;
QCOMPARE(treeView->isExpanded(currentRow), shouldBeExpanded);
@@ -538,7 +542,7 @@ void tst_qquicktreeview::expandRecursivelyWholeTree()
QSignalSpy spy(treeView, SIGNAL(expanded(int, int)));
treeView->expandRecursively(-1, -1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
auto signalArgs = spy.takeFirst();
QVERIFY(signalArgs.at(0).toInt() == -1);
QVERIFY(signalArgs.at(1).toInt() == -1);
@@ -547,7 +551,7 @@ void tst_qquicktreeview::expandRecursivelyWholeTree()
// Check that all rows that have children are expanded
for (int currentRow = 0; currentRow < treeView->rows(); ++currentRow) {
- const auto modelIndex = treeView->modelIndex(0, currentRow);
+ const auto modelIndex = treeView->index(currentRow, 0);
const bool isExpandable = model->rowCount(modelIndex) > 0;
QCOMPARE(treeView->isExpanded(currentRow), isExpandable);
}
@@ -562,7 +566,9 @@ void tst_qquicktreeview::collapseRecursivelyRoot()
WAIT_UNTIL_POLISHED;
// Verify that the tree is now fully expanded
- const int expectedRowCount = 1 + (model->maxDepth() * 4); // root + 4 children per level
+ // The number of rows should be the root, + 4 children per level. All parents
+ // (minus the root), will also have a node with 4 non-recursive children.
+ const int expectedRowCount = 1 + (model->maxDepth() * 8) - 4;
QCOMPARE(treeView->rows(), expectedRowCount);
QSignalSpy spy(treeView, SIGNAL(collapsed(int, bool)));
@@ -570,7 +576,7 @@ void tst_qquicktreeview::collapseRecursivelyRoot()
// Collapse the whole tree again. This time, only the root should end up visible
treeView->collapseRecursively();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
const auto signalArgs = spy.takeFirst();
QVERIFY(signalArgs.at(0).toInt() == -1);
QVERIFY(signalArgs.at(1).toBool() == true);
@@ -585,7 +591,7 @@ void tst_qquicktreeview::collapseRecursivelyRoot()
// We can do that by simply iterate over the rows in the view as we expand.
int currentRow = 0;
while (currentRow < treeView->rows()) {
- const QModelIndex currentIndex = treeView->modelIndex(0, currentRow);
+ const QModelIndex currentIndex = treeView->index(currentRow, 0);
if (model->hasChildren(currentIndex)) {
QVERIFY(!treeView->isExpanded(currentRow));
treeView->expand(currentRow);
@@ -607,24 +613,28 @@ void tst_qquicktreeview::collapseRecursivelyChild()
WAIT_UNTIL_POLISHED;
// Verify that the tree is now fully expanded
- const int expectedRowCount = 1 + (model->maxDepth() * 4); // root + 4 children per level
+ // The number of rows should be the root, + 4 children per level. All parents
+ // (minus the root), will also have a node with 4 non-recursive children.
+ const int expectedRowCount = 1 + (model->maxDepth() * 8) - 4;
QCOMPARE(treeView->rows(), expectedRowCount);
QSignalSpy spy(treeView, SIGNAL(collapsed(int, bool)));
- // Collapse the 4th child recursive
- const int rowToCollapse = 4;
- QCOMPARE(model->data(treeView->modelIndex(0, rowToCollapse), Qt::DisplayRole), QStringLiteral("3, 0"));
+ // Collapse the 8th child recursive
+ const int rowToCollapse = 8;
+ const QModelIndex collapseIndex = treeView->index(rowToCollapse, 0);
+ const auto expectedLabel = model->data(collapseIndex, Qt::DisplayRole);
+ QCOMPARE(expectedLabel, QStringLiteral("3, 0"));
treeView->collapseRecursively(rowToCollapse);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
const auto signalArgs = spy.takeFirst();
QVERIFY(signalArgs.at(0).toInt() == rowToCollapse);
QVERIFY(signalArgs.at(1).toBool() == true);
WAIT_UNTIL_POLISHED;
- QCOMPARE(treeView->rows(), 5); // root + 4 children
+ QCOMPARE(treeView->rows(), 9); // root + 4 children + 4 grand children of the 3rd row
// We need to check that all descendants are collapsed as well. But since they're
// now no longer visible in the view, we need to expand each parent one by one again to make
@@ -632,11 +642,17 @@ void tst_qquicktreeview::collapseRecursivelyChild()
// We can do that by simply iterate over the rows in the view as we expand.
int currentRow = 1; // start at first child
while (currentRow < treeView->rows()) {
- const QModelIndex currentIndex = treeView->modelIndex(0, currentRow);
+ const QModelIndex currentIndex = treeView->index(currentRow, 0);
if (model->hasChildren(currentIndex)) {
- QVERIFY(!treeView->isExpanded(currentRow));
- treeView->expand(currentRow);
- WAIT_UNTIL_POLISHED;
+ if (treeView->depth(currentRow) == 1 && currentIndex.row() == 2) {
+ // We did only recursively expand the 4th child, so the
+ // third should still be expanded
+ QVERIFY(treeView->isExpanded(currentRow));
+ } else {
+ QVERIFY(!treeView->isExpanded(currentRow));
+ treeView->expand(currentRow);
+ WAIT_UNTIL_POLISHED;
+ }
}
currentRow++;
}
@@ -653,7 +669,7 @@ void tst_qquicktreeview::collapseRecursivelyWholeTree()
treeView->expandRecursively();
treeView->collapseRecursively();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
auto signalArgs = spy.takeFirst();
QVERIFY(signalArgs.at(0).toInt() == -1);
QVERIFY(signalArgs.at(1).toBool() == true);
@@ -689,7 +705,7 @@ void tst_qquicktreeview::expandToIndex()
QVERIFY(treeView->isExpanded(treeView->rowAtIndex(child1)));
QVERIFY(treeView->isExpanded(treeView->rowAtIndex(child2)));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
auto signalArgs = spy.takeFirst();
QVERIFY(signalArgs.at(0).toInt() == 0);
QVERIFY(signalArgs.at(1).toInt() == 3);
@@ -711,7 +727,7 @@ void tst_qquicktreeview::toggleExpandedUsingArrowKeys()
QQuickWindow *window = treeView->window();
// Start by making cell 0, 0 current
- treeView->selectionModel()->setCurrentIndex(treeView->modelIndex(0, 0), QItemSelectionModel::NoUpdate);
+ treeView->selectionModel()->setCurrentIndex(treeView->index(0, 0), QItemSelectionModel::NoUpdate);
// Expand row 0
const int row0 = 0;
@@ -727,7 +743,7 @@ void tst_qquicktreeview::toggleExpandedUsingArrowKeys()
// Hitting Key_Right again should be a no-op
QTest::keyPress(window, Qt::Key_Right);
QVERIFY(treeView->isExpanded(row0));
- QCOMPARE(treeView->selectionModel()->currentIndex(), treeView->modelIndex(0, row0));
+ QCOMPARE(treeView->selectionModel()->currentIndex(), treeView->index(row0, 0));
// Move down to row 1 and try to expand it. Since Row 1
// doesn't have children, expanding it will be a no-op.
@@ -738,7 +754,7 @@ void tst_qquicktreeview::toggleExpandedUsingArrowKeys()
QTest::keyPress(window, Qt::Key_Down);
QTest::keyPress(window, Qt::Key_Right);
QVERIFY(!treeView->isExpanded(row1));
- QCOMPARE(treeView->selectionModel()->currentIndex(), treeView->modelIndex(0, row1));
+ QCOMPARE(treeView->selectionModel()->currentIndex(), treeView->index(row1, 0));
// Move down to row 4 and expand it
const int row4 = 4;
@@ -748,7 +764,7 @@ void tst_qquicktreeview::toggleExpandedUsingArrowKeys()
QVERIFY(!treeView->isExpanded(row4));
QTest::keyPress(window, Qt::Key_Right);
QVERIFY(treeView->isExpanded(row4));
- QCOMPARE(treeView->selectionModel()->currentIndex(), treeView->modelIndex(0, row4));
+ QCOMPARE(treeView->selectionModel()->currentIndex(), treeView->index(row4, 0));
// Move up again to row 0 and collapse it
while (treeView->currentRow() != row0)
@@ -761,7 +777,7 @@ void tst_qquicktreeview::toggleExpandedUsingArrowKeys()
// Hitting Key_Left again should be a no-op
QTest::keyPress(window, Qt::Key_Left);
QVERIFY(!treeView->isExpanded(row0));
- QCOMPARE(treeView->selectionModel()->currentIndex(), treeView->modelIndex(0, row0));
+ QCOMPARE(treeView->selectionModel()->currentIndex(), treeView->index(row0, 0));
}
void tst_qquicktreeview::selectionBehaviorCells_data()
@@ -837,13 +853,13 @@ void tst_qquicktreeview::selectionBehaviorCells()
for (int x = x1; x < x2; ++x) {
for (int y = y1; y < y2; ++y) {
- const auto index = treeView->modelIndex(x, y);
+ const auto index = treeView->index(y, x);
QVERIFY(selectionModel->isSelected(index));
}
}
const int expectedCount = (x2 - x1 + 1) * (y2 - y1 + 1);
- const int actualCount = selectionModel->selectedIndexes().count();
+ const int actualCount = selectionModel->selectedIndexes().size();
QCOMPARE(actualCount, expectedCount);
// Wrap the selection
@@ -856,7 +872,7 @@ void tst_qquicktreeview::selectionBehaviorCells()
}
}
- const int actualCountAfterWrap = selectionModel->selectedIndexes().count();
+ const int actualCountAfterWrap = selectionModel->selectedIndexes().size();
QCOMPARE(actualCountAfterWrap, expectedCount);
treeViewPrivate->clearSelection();
@@ -885,12 +901,12 @@ void tst_qquicktreeview::selectionBehaviorRows()
QCOMPARE(selectionModel->hasSelection(), true);
const int expectedCount = treeView->columns() * 3; // all columns * three rows
- int actualCount = selectionModel->selectedIndexes().count();
+ int actualCount = selectionModel->selectedIndexes().size();
QCOMPARE(actualCount, expectedCount);
for (int x = 0; x < treeView->columns(); ++x) {
for (int y = 0; y < 3; ++y) {
- const auto index = treeView->modelIndex(x, y);
+ const auto index = treeView->index(y, x);
QVERIFY(selectionModel->isSelected(index));
}
}
@@ -904,12 +920,12 @@ void tst_qquicktreeview::selectionBehaviorRows()
QCOMPARE(selectionModel->hasSelection(), true);
- actualCount = selectionModel->selectedIndexes().count();
+ actualCount = selectionModel->selectedIndexes().size();
QCOMPARE(actualCount, expectedCount);
for (int x = 0; x < treeView->columns(); ++x) {
for (int y = 0; y < 3; ++y) {
- const auto index = treeView->modelIndex(x, y);
+ const auto index = treeView->index(y, x);
QVERIFY(selectionModel->isSelected(index));
}
}
@@ -936,12 +952,12 @@ void tst_qquicktreeview::selectionBehaviorColumns()
QCOMPARE(selectionModel->hasSelection(), true);
const int expectedCount = treeView->rows() * 3; // all rows * three columns
- int actualCount = selectionModel->selectedIndexes().count();
+ int actualCount = selectionModel->selectedIndexes().size();
QCOMPARE(actualCount, expectedCount);
for (int x = 0; x < 3; ++x) {
for (int y = 0; y < treeView->rows(); ++y) {
- const auto index = treeView->modelIndex(x, y);
+ const auto index = treeView->index(y, x);
QVERIFY(selectionModel->isSelected(index));
}
}
@@ -955,12 +971,12 @@ void tst_qquicktreeview::selectionBehaviorColumns()
QCOMPARE(selectionModel->hasSelection(), true);
- actualCount = selectionModel->selectedIndexes().count();
+ actualCount = selectionModel->selectedIndexes().size();
QCOMPARE(actualCount, expectedCount);
for (int x = 0; x < 3; ++x) {
for (int y = 0; y < treeView->rows(); ++y) {
- const auto index = treeView->modelIndex(x, y);
+ const auto index = treeView->index(y, x);
QVERIFY(selectionModel->isSelected(index));
}
}
@@ -986,6 +1002,130 @@ void tst_qquicktreeview::selectionBehaviorDisabled()
QCOMPARE(selectionModel->hasSelection(), false);
}
+void tst_qquicktreeview::sortTreeModel_data()
+{
+ QTest::addColumn<QSharedPointer<QAbstractItemModel>>("treeModel");
+
+ const auto stringList = QStringList() << "1" << "2" << "3";
+ QTest::newRow("TreeModel") << QSharedPointer<QAbstractItemModel>(new TestModel());
+ QTest::newRow("Number model") << QSharedPointer<QAbstractItemModel>(new QStringListModel(stringList));
+}
+
+void tst_qquicktreeview::sortTreeModel()
+{
+ // Check that if you assign a QSortFilterProxyModel to to a TreeView, the
+ // view will end up sorted correctly if the proxy model is sorted.
+ QFETCH(QSharedPointer<QAbstractItemModel>, treeModel);
+ LOAD_TREEVIEW("normaltreeview.qml");
+
+ QSortFilterProxyModel proxyModel;
+ proxyModel.setSourceModel(treeModel.data());
+ treeView->setModel(QVariant::fromValue(&proxyModel));
+
+ // Expand some nodes
+ treeView->expand(0);
+ treeView->expand(4);
+ treeView->expand(3);
+
+ WAIT_UNTIL_POLISHED;
+
+ // Go through all rows in the view, and check that display in the model
+ // is the same as in the view. That means that QQmlTreeModelToTableModel
+ // and QSortFilterProxyModel are in sync.
+ for (int row = 0; row < treeView->rows(); ++row) {
+ const auto index = treeView->index(row, 0);
+ const QString modelDisplay = proxyModel.data(index, Qt::DisplayRole).toString();
+ const auto childFxItem = treeViewPrivate->loadedTableItem(QPoint(0, row));
+ QVERIFY(childFxItem);
+ const auto childItem = childFxItem->item;
+ QVERIFY(childItem);
+ const auto context = qmlContext(childItem.data());
+ const auto itemDisplay = context->contextProperty("display").toString();
+ QCOMPARE(itemDisplay, modelDisplay);
+ }
+
+ // Now sort the model, and do the same test again
+ proxyModel.sort(0, Qt::DescendingOrder);
+ WAIT_UNTIL_POLISHED;
+
+ for (int row = 0; row < treeView->rows(); ++row) {
+ const auto index = treeView->index(row, 0);
+ const QString modelDisplay = proxyModel.data(index, Qt::DisplayRole).toString();
+ const auto childFxItem = treeViewPrivate->loadedTableItem(QPoint(0, row));
+ QVERIFY(childFxItem);
+ const auto childItem = childFxItem->item;
+ QVERIFY(childItem);
+ const auto context = qmlContext(childItem.data());
+ const auto itemDisplay = context->contextProperty("display").toString();
+ QCOMPARE(itemDisplay, modelDisplay);
+ }
+}
+
+void tst_qquicktreeview::sortTreeModelDynamic_data()
+{
+ QTest::addColumn<QSharedPointer<QAbstractItemModel>>("treeModel");
+ QTest::addColumn<int>("row");
+
+ const auto stringList = QStringList() << "1" << "2" << "3";
+ QTest::newRow("TreeModel 0") << QSharedPointer<QAbstractItemModel>(new TestModel()) << 0;
+ QTest::newRow("TreeModel 1") << QSharedPointer<QAbstractItemModel>(new TestModel()) << 1;
+ QTest::newRow("TreeModel 3") << QSharedPointer<QAbstractItemModel>(new TestModel()) << 3;
+ QTest::newRow("TreeModel 6") << QSharedPointer<QAbstractItemModel>(new TestModel()) << 6;
+ QTest::newRow("Number model") << QSharedPointer<QAbstractItemModel>(new QStringListModel(stringList)) << 1;
+}
+
+void tst_qquicktreeview::sortTreeModelDynamic()
+{
+ // Check that if you assign a QSortFilterProxyModel to a TreeView, and
+ // set DynamicSortFilter to true, the view will end up sorted correctly
+ // if you change the text for one of the items.
+ QFETCH(QSharedPointer<QAbstractItemModel>, treeModel);
+ QFETCH(int, row);
+ LOAD_TREEVIEW("normaltreeview.qml");
+
+ QSortFilterProxyModel proxyModel;
+ proxyModel.setSourceModel(treeModel.data());
+ proxyModel.setDynamicSortFilter(true);
+ proxyModel.sort(Qt::AscendingOrder);
+ treeView->setModel(QVariant::fromValue(&proxyModel));
+
+ // Expand some nodes
+ treeView->expand(0);
+ treeView->expand(4);
+ treeView->expand(3);
+
+ // Go through all rows in the view, and check that display in the model
+ // is the same as in the view. That means that QQmlTreeModelToTableModel
+ // and QSortFilterProxyModel are in sync.
+ for (int row = 0; row < treeView->rows(); ++row) {
+ const auto index = treeView->index(row, 0);
+ const QString modelDisplay = proxyModel.data(index, Qt::DisplayRole).toString();
+ const auto childFxItem = treeViewPrivate->loadedTableItem(QPoint(0, row));
+ QVERIFY(childFxItem);
+ const auto childItem = childFxItem->item;
+ QVERIFY(childItem);
+ const auto context = qmlContext(childItem.data());
+ const auto itemDisplay = context->contextProperty("display").toString();
+ QCOMPARE(itemDisplay, modelDisplay);
+ }
+
+ // Now change the text in one of the items. This will trigger
+ // a sort for only one of the parents in the model.
+ proxyModel.setData(treeView->index(row, 0), u"xxx"_qs, Qt::DisplayRole);
+
+ for (int row = 0; row < treeView->rows(); ++row) {
+ const auto index = treeView->index(row, 0);
+ const QString modelDisplay = proxyModel.data(index, Qt::DisplayRole).toString();
+ const auto childFxItem = treeViewPrivate->loadedTableItem(QPoint(0, row));
+ QVERIFY(childFxItem);
+ const auto childItem = childFxItem->item;
+ QVERIFY(childItem);
+ const auto context = qmlContext(childItem.data());
+ const auto itemDisplay = context->contextProperty("display").toString();
+ QCOMPARE(itemDisplay, modelDisplay);
+ }
+}
+
QTEST_MAIN(tst_qquicktreeview)
#include "tst_qquicktreeview.moc"
diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp
index cb7cdb1c5d..e226cfdca7 100644
--- a/tests/auto/quick/qquickview/tst_qquickview.cpp
+++ b/tests/auto/quick/qquickview/tst_qquickview.cpp
@@ -123,7 +123,7 @@ void tst_QQuickView::resizemodeitem()
view->resize(QSize(200,300));
QTRY_COMPARE(item->width(), 200.0);
- for (int i = 0; i < sizeListener.count(); ++i) {
+ for (int i = 0; i < sizeListener.size(); ++i) {
// Check that we have the correct geometry on all signals
QCOMPARE(sizeListener.at(i), view->size());
}
@@ -171,7 +171,7 @@ void tst_QQuickView::errors()
QQmlTestMessageHandler messageHandler;
view.setSource(testFileUrl("error1.qml"));
QCOMPARE(view.status(), QQuickView::Error);
- QCOMPARE(view.errors().count(), 1);
+ QCOMPARE(view.errors().size(), 1);
}
{
@@ -179,7 +179,7 @@ void tst_QQuickView::errors()
QQmlTestMessageHandler messageHandler;
view.setSource(testFileUrl("error2.qml"));
QCOMPARE(view.status(), QQuickView::Error);
- QCOMPARE(view.errors().count(), 1);
+ QCOMPARE(view.errors().size(), 1);
view.show();
}
}
diff --git a/tests/auto/quick/qquickview_extra/tst_qquickview_extra.cpp b/tests/auto/quick/qquickview_extra/tst_qquickview_extra.cpp
index 114b97779a..0cd4b69e00 100644
--- a/tests/auto/quick/qquickview_extra/tst_qquickview_extra.cpp
+++ b/tests/auto/quick/qquickview_extra/tst_qquickview_extra.cpp
@@ -44,7 +44,7 @@ void tst_QQuickViewExtra::qtbug_87228()
// for the sake of this test, any child would be suitable, so pick first
deletionSpy.reset(new QSignalSpy(children[0], SIGNAL(destroyed(QObject *))));
}
- QCOMPARE(deletionSpy->count(), 1);
+ QCOMPARE(deletionSpy->size(), 1);
}
QTEST_APPLESS_MAIN(tst_QQuickViewExtra)
diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
index 2a567cb307..dd845b37d5 100644
--- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
+++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
@@ -61,7 +61,7 @@ public:
Branch(Branch *parent = nullptr) : parent(parent) {}
~Branch() { foreach (const Node &child, children) delete child.branch; }
int indexOf(Branch *branch) const {
- for (int i = 0; i < children.count(); ++i) {
+ for (int i = 0; i < children.size(); ++i) {
if (children.at(i).branch == branch)
return i;
}
@@ -109,7 +109,7 @@ public:
if (row < 0 || column != 0)
return QModelIndex();
Branch * const branch = branchForIndex(parent);
- return branch && row < branch->children.count()
+ return branch && row < branch->children.size()
? createIndex(row, column, branch)
: QModelIndex();
}
@@ -123,7 +123,7 @@ public:
int rowCount(const QModelIndex &parent) const override {
Branch * const branch = branchForIndex(parent);
- return branch ? branch->children.count() : 0;
+ return branch ? branch->children.size() : 0;
}
int columnCount(const QModelIndex &parent) const override {
@@ -138,9 +138,9 @@ public:
}
void insert(const QModelIndex &parent, int index, const QStringList &data) {
- beginInsertRows(parent, index, index + data.count() - 1);
+ beginInsertRows(parent, index, index + data.size() - 1);
Branch * const branch = createBranchForIndex(parent);
- for (int i = 0; i < data.count(); ++i)
+ for (int i = 0; i < data.size(); ++i)
branch->children.insert(index + i, Node(data.at(i)));
endInsertRows();
}
@@ -188,14 +188,14 @@ public:
}
void setList(const QStringList &l) {
- if (trunk.children.count() > 0) {
- beginRemoveRows(QModelIndex(), 0, trunk.children.count() - 1);
+ if (trunk.children.size() > 0) {
+ beginRemoveRows(QModelIndex(), 0, trunk.children.size() - 1);
foreach (const Node &child, trunk.children) delete child.branch;
trunk.children.clear();
endRemoveRows();
}
- if (l.count() > 0) {
- beginInsertRows(QModelIndex(), 0, l.count() -1);
+ if (l.size() > 0) {
+ beginInsertRows(QModelIndex(), 0, l.size() -1);
foreach (const QString &string, l)
trunk.children.append(Node(string));
endInsertRows();
@@ -1040,14 +1040,14 @@ void tst_qquickvisualdatamodel::qaimRowsMoved()
QSignalSpy spy(obj, SIGNAL(modelUpdated(QQmlChangeSet,bool)));
model.emitMove(sourceFirst, sourceLast, destinationChild);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
- QCOMPARE(spy[0].count(), 2);
+ QCOMPARE(spy[0].size(), 2);
QQmlChangeSet changeSet = spy[0][0].value<QQmlChangeSet>();
- QCOMPARE(changeSet.removes().count(), 1);
+ QCOMPARE(changeSet.removes().size(), 1);
QCOMPARE(changeSet.removes().at(0).index, expectFrom);
QCOMPARE(changeSet.removes().at(0).count, expectCount);
- QCOMPARE(changeSet.inserts().count(), 1);
+ QCOMPARE(changeSet.inserts().size(), 1);
QCOMPARE(changeSet.inserts().at(0).index, expectTo);
QCOMPARE(changeSet.inserts().at(0).count, expectCount);
QCOMPARE(changeSet.removes().at(0).moveId, changeSet.inserts().at(0).moveId);
@@ -1109,33 +1109,33 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved()
// Move items from the current root index to a sub tree.
model.move(QModelIndex(), 1, model.index(0, 0), 3, 2);
QCOMPARE(vdm->count(), 2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
- QCOMPARE(changeSet.removes().count(), 1);
+ QCOMPARE(changeSet.removes().size(), 1);
QCOMPARE(changeSet.removes().at(0).index, 1);
QCOMPARE(changeSet.removes().at(0).count, 2);
- QCOMPARE(changeSet.inserts().count(), 0);
+ QCOMPARE(changeSet.inserts().size(), 0);
// Move items from a sub tree to the current root index.
model.move(model.index(0, 0), 4, QModelIndex(), 2, 1);
QCOMPARE(vdm->count(), 3);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
- QCOMPARE(changeSet.removes().count(), 0);
- QCOMPARE(changeSet.inserts().count(), 1);
+ QCOMPARE(changeSet.removes().size(), 0);
+ QCOMPARE(changeSet.inserts().size(), 1);
QCOMPARE(changeSet.inserts().at(0).index, 2);
QCOMPARE(changeSet.inserts().at(0).count, 1);
vdm->setRootIndex(QVariant::fromValue(model.index(2, 0)));
QCOMPARE(vdm->rootIndex().value<QModelIndex>(), model.index(2, 0));
QCOMPARE(vdm->count(), 3);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
changeSet = spy.at(2).at(0).value<QQmlChangeSet>();
- QCOMPARE(changeSet.removes().count(), 1);
+ QCOMPARE(changeSet.removes().size(), 1);
QCOMPARE(changeSet.removes().at(0).index, 0);
QCOMPARE(changeSet.removes().at(0).count, 3);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
- QCOMPARE(changeSet.inserts().count(), 1);
+ QCOMPARE(changeSet.inserts().size(), 1);
QCOMPARE(changeSet.inserts().at(0).index, 0);
QCOMPARE(changeSet.inserts().at(0).count, 3);
@@ -1143,41 +1143,41 @@ void tst_qquickvisualdatamodel::subtreeRowsMoved()
model.move(QModelIndex(), 2, QModelIndex(), 0, 1);
QCOMPARE(vdm->rootIndex().value<QModelIndex>(), model.index(0, 0));
QCOMPARE(vdm->count(), 3);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
// Move the current root index, changing its parent.
model.move(QModelIndex(), 0, model.index(1, 0), 0, 1);
QCOMPARE(vdm->rootIndex().value<QModelIndex>(), model.index(0, 0, model.index(0, 0)));
QCOMPARE(vdm->count(), 3);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
model.insert(model.index(0, 0), 0, QStringList() << "new1" << "new2");
QCOMPARE(vdm->rootIndex().value<QModelIndex>(), model.index(2, 0, model.index(0, 0)));
QCOMPARE(vdm->count(), 3);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
model.remove(model.index(0, 0), 1, 1);
QCOMPARE(vdm->rootIndex().value<QModelIndex>(), model.index(1, 0, model.index(0, 0)));
QCOMPARE(vdm->count(), 3);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
model.remove(model.index(0, 0), 1, 1);
QCOMPARE(vdm->rootIndex().value<QModelIndex>(), QModelIndex());
QCOMPARE(vdm->count(), 0);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
- QCOMPARE(changeSet.removes().count(), 1);
+ QCOMPARE(changeSet.removes().size(), 1);
QCOMPARE(changeSet.removes().at(0).index, 0);
QCOMPARE(changeSet.removes().at(0).count, 3);
- QCOMPARE(changeSet.inserts().count(), 0);
+ QCOMPARE(changeSet.inserts().size(), 0);
vdm->setRootIndex(QVariant::fromValue(QModelIndex()));
QCOMPARE(vdm->rootIndex().value<QModelIndex>(), QModelIndex());
QCOMPARE(vdm->count(), 2);
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
- QCOMPARE(changeSet.removes().count(), 0);
- QCOMPARE(changeSet.inserts().count(), 1);
+ QCOMPARE(changeSet.removes().size(), 0);
+ QCOMPARE(changeSet.inserts().size(), 1);
QCOMPARE(changeSet.inserts().at(0).index, 0);
QCOMPARE(changeSet.inserts().at(0).count, 2);
}
@@ -1209,44 +1209,44 @@ void tst_qquickvisualdatamodel::watchedRoles()
QCOMPARE(vdm->count(), 30);
emit model.dataChanged(model.index(0), model.index(4));
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
emit model.dataChanged(model.index(0), model.index(4), QVector<int>() << QaimModel::Name);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
emit model.dataChanged(model.index(0), model.index(4), QVector<int>() << QaimModel::Number);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
vdm->setWatchedRoles(QList<QByteArray>() << "name" << "dummy");
emit model.dataChanged(model.index(0), model.index(4));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 0);
QCOMPARE(changeSet.changes().at(0).count, 5);
emit model.dataChanged(model.index(1), model.index(6), QVector<int>() << QaimModel::Name);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 1);
QCOMPARE(changeSet.changes().at(0).count, 6);
emit model.dataChanged(model.index(8), model.index(8), QVector<int>() << QaimModel::Number);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
vdm->setWatchedRoles(QList<QByteArray>() << "number" << "dummy");
emit model.dataChanged(model.index(0), model.index(4));
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 0);
QCOMPARE(changeSet.changes().at(0).count, 5);
emit model.dataChanged(model.index(1), model.index(6), QVector<int>() << QaimModel::Name);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
emit model.dataChanged(model.index(8), model.index(8), QVector<int>() << QaimModel::Number);
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 8);
QCOMPARE(changeSet.changes().at(0).count, 1);
@@ -1254,19 +1254,19 @@ void tst_qquickvisualdatamodel::watchedRoles()
vdm->setWatchedRoles(QList<QByteArray>() << "number" << "name");
emit model.dataChanged(model.index(0), model.index(4));
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 0);
QCOMPARE(changeSet.changes().at(0).count, 5);
emit model.dataChanged(model.index(1), model.index(6), QVector<int>() << QaimModel::Name);
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 1);
QCOMPARE(changeSet.changes().at(0).count, 6);
emit model.dataChanged(model.index(8), model.index(8), QVector<int>() << QaimModel::Number);
- QCOMPARE(spy.count(), 7);
+ QCOMPARE(spy.size(), 7);
changeSet = spy.last().at(0).value<QQmlChangeSet>();
QCOMPARE(changeSet.changes().at(0).index, 8);
QCOMPARE(changeSet.changes().at(0).count, 1);
@@ -2427,24 +2427,24 @@ void tst_qquickvisualdatamodel::incompleteModel()
QSignalSpy persistedItemsSpy(model->items(), SIGNAL(countChanged()));
evaluate<void>(model, "items.removeGroups(0, items.count, \"items\")");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
+ QCOMPARE(itemsSpy.size(), 0);
+ QCOMPARE(persistedItemsSpy.size(), 0);
evaluate<void>(model, "items.setGroups(0, items.count, \"persistedItems\")");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
+ QCOMPARE(itemsSpy.size(), 0);
+ QCOMPARE(persistedItemsSpy.size(), 0);
evaluate<void>(model, "items.addGroups(0, items.count, \"persistedItems\")");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
+ QCOMPARE(itemsSpy.size(), 0);
+ QCOMPARE(persistedItemsSpy.size(), 0);
evaluate<void>(model, "items.remove(0, items.count)");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
+ QCOMPARE(itemsSpy.size(), 0);
+ QCOMPARE(persistedItemsSpy.size(), 0);
evaluate<void>(model, "items.insert([ \"color\": \"blue\" ])");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
+ QCOMPARE(itemsSpy.size(), 0);
+ QCOMPARE(persistedItemsSpy.size(), 0);
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*get: index out of range"));
QVERIFY(evaluate<bool>(model, "items.get(0) === undefined"));
@@ -3070,7 +3070,7 @@ void tst_qquickvisualdatamodel::insert()
QCOMPARE(evaluate<int>(visualModel, "visibleItems.count"), visible ? visualCount : modelCount);
QCOMPARE(evaluate<int>(visualModel, "selectedItems.count"), selected ? 1 : 0);
- QCOMPARE(propertyData.count(), visualCount);
+ QCOMPARE(propertyData.size(), visualCount);
for (int i = 0; i < visualCount; ++i) {
int modelIndex = i;
if (modelIndex > index)
@@ -3538,7 +3538,7 @@ void tst_qquickvisualdatamodel::resolve()
QCOMPARE(evaluate<int>(visualModel, "visibleItems.count"), visible ? visualCount : modelCount);
QCOMPARE(evaluate<int>(visualModel, "selectedItems.count"), selected ? 1 : 0);
- QCOMPARE(propertyData.count(), visualCount);
+ QCOMPARE(propertyData.size(), visualCount);
for (int i = 0; i < visualCount; ++i) {
int modelIndex = i;
@@ -3939,7 +3939,7 @@ void tst_qquickvisualdatamodel::invalidAttachment()
QScopedPointer<QObject> object(component.create());
QVERIFY(object);
- QCOMPARE(component.errors().count(), 0);
+ QCOMPARE(component.errors().size(), 0);
QVariant property = object->property("invalidVdm");
QCOMPARE(property.userType(), qMetaTypeId<QQmlDelegateModel *>());
@@ -4268,7 +4268,7 @@ public:
static qsizetype listLength(QQmlListProperty<QObject> *property)
{
auto objectsProvider = qobject_cast<ObjectsProvider*>(property->object);
- return objectsProvider ? objectsProvider->m_objects.length() : 0;
+ return objectsProvider ? objectsProvider->m_objects.size() : 0;
}
static QObject* listAt(QQmlListProperty<QObject> *property, qsizetype index)
diff --git a/tests/auto/quick/qquickwindow/data/shortcutOverride.qml b/tests/auto/quick/qquickwindow/data/shortcutOverride.qml
new file mode 100644
index 0000000000..e5d35a984d
--- /dev/null
+++ b/tests/auto/quick/qquickwindow/data/shortcutOverride.qml
@@ -0,0 +1,30 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+import QtQuick
+import QtQuick.Window
+
+Window {
+ id: root
+ visible: true
+ width: 200
+ height: 200
+
+ property bool overridden: false
+ property bool receivedA: false
+ property bool receivedB: false
+ Item {
+ Keys.onShortcutOverride: (e) => e.accepted = root.overridden = (e.key === Qt.Key_A)
+
+ Item {
+ focus: true
+ Shortcut {
+ sequence: "A"
+ onActivated: root.receivedA = true
+ }
+ Shortcut {
+ sequence: "B"
+ onActivated: root.receivedB = true
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index fca5ebb06d..f7265888cb 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -421,6 +421,9 @@ public:
, touchDevice(QTest::createTouchDevice())
, touchDeviceWithVelocity(QTest::createTouchDevice(QInputDevice::DeviceType::TouchScreen,
QInputDevice::Capability::Position | QPointingDevice::Capability::Velocity))
+ , tabletStylusDevice(QPointingDevicePrivate::tabletDevice(QInputDevice::DeviceType::Stylus,
+ QPointingDevice::PointerType::Pen,
+ QPointingDeviceUniqueId::fromNumericId(1234567890)))
{
QQuickWindow::setDefaultAlphaBuffer(true);
}
@@ -531,6 +534,8 @@ private slots:
#if QT_CONFIG(shortcut)
void testShortCut();
+ void shortcutOverride_data();
+ void shortcutOverride();
#endif
void rendererInterface();
@@ -541,6 +546,7 @@ private slots:
private:
QPointingDevice *touchDevice;
QPointingDevice *touchDeviceWithVelocity;
+ const QPointingDevice *tabletStylusDevice;
};
#if QT_CONFIG(opengl)
@@ -3610,16 +3616,16 @@ void tst_qquickwindow::cleanupGrabsOnRelease()
void tst_qquickwindow::subclassWithPointerEventVirtualOverrides_data()
{
- QTest::addColumn<QPointingDevice::DeviceType>("deviceType");
+ QTest::addColumn<const QPointingDevice *>("device");
- QTest::newRow("mouse click") << QPointingDevice::DeviceType::Mouse;
- QTest::newRow("touch tap") << QPointingDevice::DeviceType::TouchScreen;
- QTest::newRow("stylus tap") << QPointingDevice::DeviceType::Stylus;
+ QTest::newRow("mouse click") << QPointingDevice::primaryPointingDevice();
+ QTest::newRow("touch tap") << touchDevice;
+ QTest::newRow("stylus tap") << tabletStylusDevice;
}
void tst_qquickwindow::subclassWithPointerEventVirtualOverrides() // QTBUG-97859
{
- QFETCH(QPointingDevice::DeviceType, deviceType);
+ QFETCH(const QPointingDevice *, device);
PointerRecordingWindow window;
window.resize(250, 250);
@@ -3627,32 +3633,23 @@ void tst_qquickwindow::subclassWithPointerEventVirtualOverrides() // QTBUG-97859
window.setTitle(QTest::currentTestFunction());
window.show();
QVERIFY(QTest::qWaitForWindowActive(&window));
- const qint64 stylusId = 1234567890;
-
const QPoint pos(120, 120);
- switch (static_cast<QPointingDevice::DeviceType>(deviceType)) {
+
+ QQuickTest::pointerPress(device, &window, 0, pos);
+ QQuickTest::pointerRelease(device, &window, 0, pos);
+
+ switch (device->type()) {
case QPointingDevice::DeviceType::Mouse:
- QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, pos);
- QTRY_COMPARE(window.m_mouseEvents.count(), 3); // separate move before press
- QCOMPARE(window.m_events.count(), 3);
+ QTRY_COMPARE(window.m_mouseEvents.size(), 3); // separate move before press
+ QCOMPARE(window.m_events.size(), 3);
break;
case QPointingDevice::DeviceType::TouchScreen:
- QTest::touchEvent(&window, touchDevice).press(0, pos, &window);
- QTest::touchEvent(&window, touchDevice).release(0, pos, &window);
- QTRY_COMPARE(window.m_touchEvents.count(), 2);
- QCOMPARE(window.m_events.count(), 2);
+ QTRY_COMPARE(window.m_touchEvents.size(), 2);
+ QCOMPARE(window.m_events.size(), 2);
break;
case QPointingDevice::DeviceType::Stylus:
- // press (pressure is 0.8)
- QWindowSystemInterface::handleTabletEvent(&window, pos, window.mapToGlobal(pos),
- int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen),
- Qt::LeftButton, 0.8, 0, 0, 0, 0, 0, stylusId, Qt::NoModifier);
- // release (pressure is 0)
- QWindowSystemInterface::handleTabletEvent(&window, pos, window.mapToGlobal(pos),
- int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen),
- Qt::NoButton, 0, 0, 0, 0, 0, 0, stylusId, Qt::NoModifier);
- QTRY_COMPARE(window.m_tabletEvents.count(), 2);
- QVERIFY(window.m_events.count() >= window.m_tabletEvents.count()); // tablet + synth-mouse events
+ QTRY_COMPARE(window.m_tabletEvents.size(), 2);
+ QVERIFY(window.m_events.size() >= window.m_tabletEvents.size()); // tablet + synth-mouse events
break;
default:
break;
@@ -3681,6 +3678,39 @@ void tst_qquickwindow::testShortCut()
QVERIFY(eventFilter.events.contains(int(QEvent::ShortcutOverride)));
QVERIFY(window->property("received").value<bool>());
}
+
+void tst_qquickwindow::shortcutOverride_data()
+{
+ QTest::addColumn<Qt::Key>("key");
+ QTest::addColumn<bool>("overridden");
+ QTest::addColumn<bool>("receivedA");
+ QTest::addColumn<bool>("receivedB");
+
+ QTest::addRow("Space") << Qt::Key_Space << false << false << false;
+ QTest::addRow("A") << Qt::Key_A << true << false << false;
+ QTest::addRow("B") << Qt::Key_B << false << false << true;
+}
+
+void tst_qquickwindow::shortcutOverride()
+{
+ QFETCH(Qt::Key, key);
+ QFETCH(bool, overridden);
+ QFETCH(bool, receivedA);
+ QFETCH(bool, receivedB);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("shortcutOverride.qml"));
+
+ QScopedPointer<QWindow> window(qobject_cast<QQuickWindow *>(component.create()));
+ QVERIFY(window);
+ QVERIFY(QTest::qWaitForWindowActive(window.get()));
+
+ QTest::keyPress(window.get(), key);
+ QCOMPARE(window->property("overridden").value<bool>(), overridden);
+ QCOMPARE(window->property("receivedA").value<bool>(), receivedA);
+ QCOMPARE(window->property("receivedB").value<bool>(), receivedB);
+}
#endif
void tst_qquickwindow::rendererInterface()
diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
index e595175fee..ec98013c8b 100644
--- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp
+++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
@@ -54,7 +54,7 @@ QDebug operator<<(QDebug dbg, const struct Event &event) {
if (event.points.isEmpty())
dbg << " @ " << event.mousePos << " global " << event.mousePosGlobal;
else
- dbg << ", " << event.points.count() << " touchpoints: " << event.points;
+ dbg << ", " << event.points.size() << " touchpoints: " << event.points;
dbg << ')';
return dbg;
}
@@ -166,12 +166,22 @@ class GrabMonitor : public QObject
{
public:
QObject *exclusiveGrabber = nullptr;
+ int transitionCount = 0;
bool fromMouseEvent = false;
bool canceled = false;
+ void reset()
+ {
+ exclusiveGrabber = nullptr;
+ transitionCount = 0;
+ fromMouseEvent = false;
+ canceled = false;
+ }
+
void onGrabChanged(QObject *grabber, QPointingDevice::GrabTransition transition, const QPointerEvent *event, const QEventPoint &point)
{
qCDebug(lcTests) << grabber << transition << event << point << point.device();
+ ++transitionCount;
switch (transition) {
case QPointingDevice::GrabTransition::GrabExclusive:
exclusiveGrabber = grabber;
@@ -232,6 +242,8 @@ private slots:
void oneTouchInsideAndOneOutside();
+ void strayTouchDoesntAutograb();
+
protected:
bool eventFilter(QObject *, QEvent *event) override
{
@@ -784,7 +796,7 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable()
qCDebug(lcTests) << "expected filtered events: actual TouchBegin and replayed TouchBegin" << filteredEventList;
QTRY_COMPARE(eventItem1->eventList.size(), 1);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::MouseButtonPress);
- QCOMPARE(filteredEventList.count(), 2); // actual touch begin and replayed touch begin
+ QCOMPARE(filteredEventList.size(), 2); // actual touch begin and replayed touch begin
}
if (!releaseBeforeDelayIsOver) {
@@ -799,7 +811,7 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable()
if (scrollBeforeDelayIsOver) {
QCOMPARE(eventItem1->eventList.size(), 0);
qCDebug(lcTests) << "expected filtered events: 1 TouchBegin and 3 TouchUpdate" << filteredEventList;
- QCOMPARE(filteredEventList.count(), 4);
+ QCOMPARE(filteredEventList.size(), 4);
} else {
qCDebug(lcTests) << "expected delivered events: press(mouse), move(mouse), move(mouse), ungrab(mouse)" << eventItem1->eventList;
QCOMPARE(eventItem1->eventList.size(), 4);
@@ -807,7 +819,7 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable()
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseMove);
QCOMPARE(eventItem1->eventList.last().type, QEvent::UngrabMouse);
qCDebug(lcTests) << "expected filtered events: 2 TouchBegin and 3 TouchUpdate" << filteredEventList;
- QCOMPARE(filteredEventList.count(), 5);
+ QCOMPARE(filteredEventList.size(), 5);
}
// flickable should have the touchpoint grab: it no longer relies on synth-mouse
@@ -828,17 +840,17 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable()
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonRelease);
QCOMPARE(eventItem1->eventList.last().type, QEvent::UngrabMouse);
// QQuickWindow filters the delayed press and release
- QCOMPARE(filteredEventList.count(), 4);
- QCOMPARE(filteredEventList.at(filteredEventList.count() - 2).type, QEvent::TouchBegin);
+ QCOMPARE(filteredEventList.size(), 4);
+ QCOMPARE(filteredEventList.at(filteredEventList.size() - 2).type, QEvent::TouchBegin);
QCOMPARE(filteredEventList.last().type, QEvent::TouchEnd);
} else {
// QQuickWindow filters the delayed press if there was one
if (scrollBeforeDelayIsOver) {
qCDebug(lcTests) << "expected filtered events: 1 TouchBegin, 3 TouchUpdate, 1 TouchEnd" << filteredEventList;
- QCOMPARE(filteredEventList.count(), 5);
+ QCOMPARE(filteredEventList.size(), 5);
} else {
qCDebug(lcTests) << "expected filtered events: 2 TouchBegin, 3 TouchUpdate, 1 TouchEnd" << filteredEventList;
- QCOMPARE(filteredEventList.count(), 6);
+ QCOMPARE(filteredEventList.size(), 6);
QCOMPARE(filteredEventList.at(0).type, QEvent::TouchBegin);
QCOMPARE(filteredEventList.last().type, QEvent::TouchEnd);
}
@@ -953,7 +965,7 @@ void tst_TouchMouse::buttonOnTouch()
touchSeq.press(0, p1, &window).press(1, p2, &window).commit();
QQuickTouchUtils::flush(&window);
QCOMPARE(button1->scale(), 1);
- QCOMPARE(eventItem1->eventList.count(), 1);
+ QCOMPARE(eventItem1->eventList.size(), 1);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::MouseButtonPress);
p1 -= QPoint(10, 0);
@@ -1265,16 +1277,16 @@ void tst_TouchMouse::tapOnDismissiveTopMouseAreaClicksBottomOne()
QTest::touchEvent(&window, device).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
- QCOMPARE(bottomClickedSpy.count(), 1);
- QCOMPARE(bottomDoubleClickedSpy.count(), 0);
+ QCOMPARE(bottomClickedSpy.size(), 1);
+ QCOMPARE(bottomDoubleClickedSpy.size(), 0);
QTest::touchEvent(&window, device).press(0, p1, &window);
QQuickTouchUtils::flush(&window);
QTest::touchEvent(&window, device).release(0, p1, &window);
QQuickTouchUtils::flush(&window);
- QCOMPARE(bottomClickedSpy.count(), 1);
- QCOMPARE(bottomDoubleClickedSpy.count(), 1);
+ QCOMPARE(bottomClickedSpy.size(), 1);
+ QCOMPARE(bottomDoubleClickedSpy.size(), 1);
}
/*
@@ -1449,21 +1461,21 @@ void tst_TouchMouse::hoverEnabled() // QTBUG-40856
// ------------------------- Mouse move to mouseArea1
QTest::mouseMove(&window, p1);
- QVERIFY(enterSpy1.count() == 1);
+ QVERIFY(enterSpy1.size() == 1);
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea2->hovered());
// ------------------------- Touch click on mouseArea1
QTest::touchEvent(&window, device).press(0, p1, &window);
- QCOMPARE(enterSpy1.count(), 1);
- QCOMPARE(enterSpy2.count(), 0);
+ QCOMPARE(enterSpy1.size(), 1);
+ QCOMPARE(enterSpy2.size(), 0);
QVERIFY(mouseArea1->pressed());
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea2->hovered());
QTest::touchEvent(&window, device).release(0, p1, &window);
- QVERIFY(clickSpy1.count() == 1);
+ QVERIFY(clickSpy1.size() == 1);
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea2->hovered());
@@ -1473,28 +1485,28 @@ void tst_TouchMouse::hoverEnabled() // QTBUG-40856
QVERIFY(mouseArea1->hovered());
QVERIFY(mouseArea2->hovered());
QVERIFY(mouseArea2->pressed());
- QCOMPARE(enterSpy1.count(), 1);
- QCOMPARE(enterSpy2.count(), 1);
+ QCOMPARE(enterSpy1.size(), 1);
+ QCOMPARE(enterSpy2.size(), 1);
QTest::touchEvent(&window, device).release(0, p2, &window);
- QVERIFY(clickSpy2.count() == 1);
+ QVERIFY(clickSpy2.size() == 1);
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea2->hovered());
- QCOMPARE(exitSpy1.count(), 0);
- QCOMPARE(exitSpy2.count(), 1);
+ QCOMPARE(exitSpy1.size(), 0);
+ QCOMPARE(exitSpy2.size(), 1);
// ------------------------- Another touch click on mouseArea1
QTest::touchEvent(&window, device).press(0, p1, &window);
- QCOMPARE(enterSpy1.count(), 1);
- QCOMPARE(enterSpy2.count(), 1);
+ QCOMPARE(enterSpy1.size(), 1);
+ QCOMPARE(enterSpy2.size(), 1);
QVERIFY(mouseArea1->pressed());
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea2->hovered());
QTest::touchEvent(&window, device).release(0, p1, &window);
- QCOMPARE(clickSpy1.count(), 2);
+ QCOMPARE(clickSpy1.size(), 2);
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea1->pressed());
QVERIFY(!mouseArea2->hovered());
@@ -1545,20 +1557,20 @@ void tst_TouchMouse::touchCancelWillCancelMousePress()
// Begin a new touch, that gets converted to a mouse press
QTest::touchEvent(&window, device).press(0, p1);
- QCOMPARE(eventItem->eventList.count(), 1);
+ QCOMPARE(eventItem->eventList.size(), 1);
QCOMPARE(eventItem->eventList.at(0).type, QEvent::MouseButtonPress);
// Cancel it...
QTouchEvent cancelEvent(QEvent::TouchCancel, device);
QCoreApplication::sendEvent(&window, &cancelEvent);
- QCOMPARE(eventItem->eventList.count(), 3);
+ QCOMPARE(eventItem->eventList.size(), 3);
QCOMPARE(eventItem->eventList.at(1).type, QEvent::TouchCancel);
QCOMPARE(eventItem->eventList.at(2).type, QEvent::UngrabMouse);
// Begin a second touch. Since the last one was cancelled, this
// should end up as a new mouse press on the target item.
QTest::touchEvent(&window, device).press(0, p1);
- QVERIFY(eventItem->eventList.count() >= 5);
+ QVERIFY(eventItem->eventList.size() >= 5);
QCOMPARE(eventItem->eventList.at(3).type, QEvent::MouseButtonPress);
QTest::touchEvent(&window, device).release(0, p1); // clean up potential state
@@ -1600,6 +1612,47 @@ void tst_TouchMouse::oneTouchInsideAndOneOutside() // QTBUG-102996
QQuickTouchUtils::flush(&window);
}
+void tst_TouchMouse::strayTouchDoesntAutograb() // QTBUG-107867
+{
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("singleitem.qml")));
+ QQuickItem *root = window.rootObject();
+ QVERIFY(root);
+ EventItem *eventItem = root->findChild<EventItem*>();
+ QVERIFY(eventItem);
+ // This item accepts (synth-)mouse events but NOT touch
+ eventItem->acceptMouse = true;
+ QCOMPARE(eventItem->acceptTouchEvents(), false); // the default in Qt 6
+ QPoint p1(6, 6);
+ grabMonitor.reset();
+
+ // Begin a new touch, that gets converted to a mouse press
+ QTest::touchEvent(&window, device).press(0, p1);
+ QQuickTouchUtils::flush(&window);
+ qCDebug(lcTests) << "after touch press:" << eventItem->eventList;
+ QCOMPARE(eventItem->eventList.size(), 1);
+ QCOMPARE(eventItem->eventList.at(0).type, QEvent::MouseButtonPress);
+ QCOMPARE(grabMonitor.exclusiveGrabber, eventItem);
+
+ // Drag
+ for (int i = 0; i < 3; ++i) {
+ QTest::touchEvent(&window, device).move(0, p1 + QPoint(i * 5, i * 5), &window);
+ QQuickTouchUtils::flush(&window);
+ QCOMPARE(grabMonitor.transitionCount, 1); // no new grab
+ QCOMPARE(eventItem->eventList.size(), i + 2);
+ QCOMPARE(eventItem->eventList.last().type, QEvent::MouseMove);
+ }
+
+ // Press an extra point: EventItem should see nothing
+ QTest::touchEvent(&window, device).stationary(0).press(1, p1);
+ QQuickTouchUtils::flush(&window);
+ qCDebug(lcTests) << "after press of second touchpoint:" << eventItem->eventList;
+ QCOMPARE(eventItem->eventList.size(), 4);
+ QCOMPARE(grabMonitor.transitionCount, 1); // no new grab
+
+ QTest::touchEvent(&window, device).release(0, p1).release(1, p1);
+}
+
QTEST_MAIN(tst_TouchMouse)
#include "tst_touchmouse.moc"
diff --git a/tests/auto/quickcontrols2/CMakeLists.txt b/tests/auto/quickcontrols2/CMakeLists.txt
index 5bd05b95ee..e2b37a6202 100644
--- a/tests/auto/quickcontrols2/CMakeLists.txt
+++ b/tests/auto/quickcontrols2/CMakeLists.txt
@@ -30,6 +30,8 @@ add_subdirectory(qquickmenubar)
add_subdirectory(qquickninepatchimage)
add_subdirectory(qquickpopup)
add_subdirectory(qquickstyle)
+add_subdirectory(qquicktextarea)
+add_subdirectory(qquicktextfield)
add_subdirectory(qquickuniversalstyle)
add_subdirectory(qquickuniversalstyleconf)
add_subdirectory(revisions)
diff --git a/tests/auto/quickcontrols2/controls/data/tst_dialog.qml b/tests/auto/quickcontrols2/controls/data/tst_dialog.qml
index 6aa9d39af0..821c7999e0 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_dialog.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_dialog.qml
@@ -125,6 +125,8 @@ TestCase {
control.closePolicy = Popup.CloseOnPressOutside
control.open()
verify(control.visible)
+ // wait for enter transitions to finish
+ openedSpy.wait()
mousePress(testCase, 1, 1)
compare(rejectedSpy.count, 3)
@@ -143,6 +145,7 @@ TestCase {
control.closePolicy = Popup.CloseOnReleaseOutside
control.open()
verify(control.visible)
+ openedSpy.wait()
mousePress(testCase, 1, 1)
compare(rejectedSpy.count, 3)
@@ -298,6 +301,7 @@ TestCase {
compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding
+ control.header.implicitHeight + control.footer.implicitHeight)
+ control.footer.implicitWidth = 0
control.header.implicitWidth = 150
compare(control.implicitWidth, control.header.implicitWidth)
diff --git a/tests/auto/quickcontrols2/controls/data/tst_popup.qml b/tests/auto/quickcontrols2/controls/data/tst_popup.qml
index 58ab662f48..278ee62f06 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_popup.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_popup.qml
@@ -6,6 +6,7 @@ import QtTest
import QtQuick.Controls
import QtQuick.Templates as T
import QtQuick.NativeStyle as NativeStyle
+import Qt.test.controls
TestCase {
id: testCase
@@ -1405,6 +1406,16 @@ TestCase {
property alias popup: popup
property alias popupTitle: popupTitle
+ property alias popupContent: popupContent
+ property bool gotMouseEvent: false
+
+ MouseArea {
+ id: windowMouseArea
+ enabled: true
+ anchors.fill: parent
+ onPressed: gotMouseEvent = true
+ }
+
Popup {
id: popup
@@ -1412,6 +1423,7 @@ TestCase {
height: 200
background: Rectangle {
+ id: popupContent
color: "#505050"
Rectangle {
id: popupTitle
@@ -1456,6 +1468,11 @@ TestCase {
let popup = window.popup
popup.open()
+
+ // mouse clicks into the popup must not propagate to the parent
+ mouseClick(window)
+ compare(window.gotMouseEvent, false)
+
let title = window.popupTitle
verify(title)
@@ -1469,5 +1486,26 @@ TestCase {
fuzzyCompare(popup.y, oldPos.y + 5, 1)
mouseRelease(title, pressPoint.x, pressPoint.y)
compare(title.pressedPosition, Qt.point(0, 0))
+
+ }
+
+ Component {
+ id: cppDimmerComponent
+
+ Popup {
+ dim: true
+ Overlay.modeless: ComponentCreator.createComponent(
+ "import QtQuick; Rectangle { objectName: \"rect\"; color: \"tomato\" }")
+ }
+ }
+
+ function test_dimmerComponentCreatedInCpp() {
+ let control = createTemporaryObject(cppDimmerComponent, testCase)
+ verify(control)
+
+ control.open()
+ tryCompare(control, "opened", true)
+ let rect = findChild(control.Overlay.overlay, "rect")
+ verify(rect)
}
}
diff --git a/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml b/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml
index 73332e0b4d..1ab2475c45 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml
@@ -578,4 +578,88 @@ TestCase {
compare(mouseWheelSpy.count, 1)
compare(mouseArea.flickable.contentY, 0)
}
+
+ Component {
+ id: bindingToContentItemAndStandaloneFlickable
+
+ Item {
+ width: 200
+ height: 200
+
+ property alias scrollView: scrollView
+
+ ScrollView {
+ id: scrollView
+ anchors.fill: parent
+ contentItem: listView
+
+ property Item someBinding: contentItem
+ }
+ ListView {
+ id: listView
+ model: 10
+ delegate: ItemDelegate {
+ text: modelData
+ width: listView.width
+ }
+ }
+ }
+ }
+
+ // Tests that scroll bars show up for a ScrollView where
+ // - its contentItem is declared as a standalone, separate item
+ // - there is a binding to contentItem (which causes a default Flickable to be created)
+ function test_bindingToContentItemAndStandaloneFlickable() {
+ let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
+ verify(root)
+
+ let control = root.scrollView
+ let verticalScrollBar = control.ScrollBar.vertical
+ let horizontalScrollBar = control.ScrollBar.horizontal
+ compare(verticalScrollBar.parent, control)
+ compare(horizontalScrollBar.parent, control)
+ verify(verticalScrollBar.visible)
+ verify(horizontalScrollBar.visible)
+
+ mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
+ verify(verticalScrollBar.active)
+ verify(horizontalScrollBar.active)
+ }
+
+ Component {
+ id: contentItemAssignedImperatively
+
+ Item {
+ width: 100
+ height: 100
+
+ property alias scrollView: scrollView
+
+ ListView {
+ id: listView
+ model: 20
+ delegate: Text {
+ text: modelData
+ }
+ }
+
+ Component.onCompleted: scrollView.contentItem = listView
+
+ ScrollView {
+ id: scrollView
+ anchors.fill: parent
+
+ ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
+ }
+ }
+ }
+
+ // Tests that a ListView declared before the ScrollView (as the QObject destruction order
+ // is relevant for the bug) and assigned imperatively to ScrollView does not cause a crash
+ // on exit.
+ function test_contentItemAssignedImperatively() {
+ let root = createTemporaryObject(contentItemAssignedImperatively, testCase)
+ verify(root)
+ // Shouldn't crash.
+ }
}
diff --git a/tests/auto/quickcontrols2/controls/data/tst_splitview.qml b/tests/auto/quickcontrols2/controls/data/tst_splitview.qml
index add4d7b7ec..c7b5819c3d 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_splitview.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_splitview.qml
@@ -6,6 +6,7 @@ import QtQuick.Controls
import QtQuick.Window
import QtTest
import Qt.labs.settings
+import Qt.test.controls
TestCase {
id: testCase
@@ -2528,4 +2529,65 @@ TestCase {
mouseMove(control, control.width - 100, control.height / 2)
verify(!targetHandle.SplitHandle.hovered)
}
+
+ Component {
+ id: cppHandleSplitViewComponent
+
+ SplitView {
+ anchors.fill: parent
+ handle: ComponentCreator.createComponent(`
+ import QtQuick
+
+ Rectangle {
+ objectName: "handle"
+ implicitWidth: 10
+ implicitHeight: 10
+ color: "tomato"
+ }`)
+
+ Rectangle {
+ objectName: "navajowhite"
+ color: objectName
+ implicitWidth: 100
+ implicitHeight: 100
+ }
+ Rectangle {
+ objectName: "steelblue"
+ color: objectName
+ implicitWidth: 200
+ implicitHeight: 200
+ }
+ }
+ }
+
+ function test_handleComponentCreatedInCpp() {
+ let control = createTemporaryObject(cppHandleSplitViewComponent, testCase)
+ verify(control)
+
+ let handles = findHandles(control)
+ compare(handles.length, 1)
+ compare(handles[0].color, Qt.color("tomato"))
+ }
+
+ function test_touch() {
+ let control = createTemporaryObject(threeSizedItemsComponent, testCase)
+ verify(control)
+
+ let touch = touchEvent(control)
+
+ let handles = findHandles(control)
+ let firstHandle = handles[0]
+ let handleCenter = control.mapFromItem(firstHandle, firstHandle.width / 2, firstHandle.height / 2)
+ touch.press(0, control, handleCenter.x, handleCenter.y).commit()
+ verify(firstHandle.SplitHandle.pressed)
+
+ touch.move(0, control, handleCenter.x + 100, handleCenter.y).commit()
+ verify(firstHandle.SplitHandle.pressed)
+ let firstItem = control.itemAt(0)
+ compare(firstItem.width, 125)
+
+ touch.release(0, control, handleCenter.x + 100, handleCenter.y).commit()
+ verify(!firstHandle.SplitHandle.pressed)
+ compare(firstItem.width, 125)
+ }
}
diff --git a/tests/auto/quickcontrols2/controls/data/tst_stackview.qml b/tests/auto/quickcontrols2/controls/data/tst_stackview.qml
index f2a3781fb1..901c9609a0 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_stackview.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_stackview.qml
@@ -4,6 +4,7 @@
import QtQuick
import QtTest
import QtQuick.Controls
+import Qt.test.controls
TestCase {
id: testCase
@@ -1225,7 +1226,12 @@ TestCase {
Item {
objectName: "clearUponDestructionItem"
- Component.onDestruction: container.onDestructionCallback(stackView)
+ onParentChanged: {
+ // We don't actually do this on destruction because destruction is delayed.
+ // Rather, we do it when we get un-parented.
+ if (parent === null)
+ container.onDestructionCallback(stackView)
+ }
}
}
@@ -1544,4 +1550,48 @@ TestCase {
tryCompare(control, "busy", true)
tryCompare(control, "busy", false)
}
+
+ Component {
+ id: cppComponent
+
+ StackView {
+ id: stackView
+ anchors.fill: parent
+ initialItem: cppComponent
+
+ property Component cppComponent: ComponentCreator.createComponent("import QtQuick; Rectangle { color: \"navajowhite\" }")
+ }
+ }
+
+ // Test that a component created in C++ works with StackView.
+ function test_componentCreatedInCpp() {
+ let control = createTemporaryObject(cppComponent, testCase)
+ verify(control)
+ compare(control.currentItem.color, Qt.color("navajowhite"))
+
+ control.push(control.cppComponent, { color: "tomato" })
+ compare(control.currentItem.color, Qt.color("tomato"))
+ }
+
+ Component {
+ id: noProperties
+ Item {}
+ }
+
+ Component {
+ id: invalidProperties
+
+ StackView {
+ anchors.fill: parent
+ }
+ }
+
+ function test_invalidProperties() {
+ let control = createTemporaryObject(invalidProperties, testCase)
+ verify(control)
+ verify(control.empty)
+ ignoreWarning(/Cannot resolve property "unknownProperty.test"/)
+ control.push(noProperties, { "unknownProperty.test": "crashes" })
+ verify(!control.empty)
+ }
}
diff --git a/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml b/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml
index 1a544e4c8c..77204015b7 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml
@@ -4,7 +4,7 @@
import QtQuick
import QtTest
import QtQuick.Controls
-
+import Qt.test.controls
TestCase {
id: testCase
@@ -1726,4 +1726,23 @@ TestCase {
compare(control.background.width, 200)
compare(control.contentItem.width, 200 - control.leftPadding - control.rightPadding)
}
+
+ Component {
+ id: cppDelegateComponent
+
+ SwipeDelegate {
+ text: "SwipeDelegate"
+ width: 150
+ swipe.right: ComponentCreator.createComponent(
+ "import QtQuick; Rectangle { width: 100; height: parent.height; color: \"tomato\" }")
+ }
+ }
+
+ function test_delegateComponentCreatedInCpp() {
+ let control = createTemporaryObject(cppDelegateComponent, testCase)
+ verify(control)
+
+ swipe(control, 0, -1.0)
+ compare(control.swipe.rightItem.color, Qt.color("tomato"))
+ }
}
diff --git a/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml b/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml
index af661def9d..9874988c44 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml
@@ -249,7 +249,13 @@ TestCase {
function test_activateShortcutWhileToolTipVisible() {
if ((Qt.platform.pluginName === "offscreen")
|| (Qt.platform.pluginName === "minimal"))
- skip("Mouse hoovering not functional on offscreen/minimal platforms")
+ skip("Mouse hovering not functional on offscreen/minimal platforms")
+
+ // Window shortcuts (the default context for Shortcut) require the window to have focus.
+ var window = testCase.Window.window
+ verify(window)
+ window.requestActivate()
+ tryCompare(window, "active", true)
var root = createTemporaryObject(buttonAndShortcutComponent, testCase)
verify(root)
diff --git a/tests/auto/quickcontrols2/cursor/BLACKLIST b/tests/auto/quickcontrols2/cursor/BLACKLIST
new file mode 100644
index 0000000000..cebb2c9438
--- /dev/null
+++ b/tests/auto/quickcontrols2/cursor/BLACKLIST
@@ -0,0 +1,3 @@
+# QTBUG-105611
+[scrollBar]
+webos
diff --git a/tests/auto/quickcontrols2/customization/tst_customization.cpp b/tests/auto/quickcontrols2/customization/tst_customization.cpp
index f22af1d5b8..1ee39ae254 100644
--- a/tests/auto/quickcontrols2/customization/tst_customization.cpp
+++ b/tests/auto/quickcontrols2/customization/tst_customization.cpp
@@ -293,7 +293,7 @@ void tst_customization::creation()
QCOMPARE(control->objectName(), controlName);
QVERIFY2(qt_createdQObjects()->removeOne(controlName), qPrintable(controlName + " was not created as expected"));
- for (QString delegate : qAsConst(delegates)) {
+ for (QString delegate : std::as_const(delegates)) {
QStringList properties = delegate.split(".", Qt::SkipEmptyParts);
// <control>-<delegate>-<style>(-<override>)
@@ -390,7 +390,7 @@ void tst_customization::override()
QCOMPARE(control->objectName(), controlName);
QVERIFY2(qt_createdQObjects()->removeOne(controlName), qPrintable(controlName + " was not created as expected"));
- for (QString delegate : qAsConst(delegates)) {
+ for (QString delegate : std::as_const(delegates)) {
QStringList properties = delegate.split(".", Qt::SkipEmptyParts);
// <control>-<delegate>-<style>(-override)
@@ -420,7 +420,7 @@ void tst_customization::override()
if (!nonDeferred.isEmpty()) {
// There were items for which deferred execution was not possible.
- for (QString delegateName : qAsConst(delegates)) {
+ for (QString delegateName : std::as_const(delegates)) {
if (!delegateName.contains("-"))
delegateName.append("-" + nonDeferred);
delegateName.prepend(type.toLower() + "-");
diff --git a/tests/auto/quickcontrols2/focus/tst_focus.cpp b/tests/auto/quickcontrols2/focus/tst_focus.cpp
index fc38865921..ca70146885 100644
--- a/tests/auto/quickcontrols2/focus/tst_focus.cpp
+++ b/tests/auto/quickcontrols2/focus/tst_focus.cpp
@@ -93,7 +93,7 @@ void tst_focus::navigation()
QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(QGuiApplication::focusWindow() == &view);
- for (const QString &name : qAsConst(order)) {
+ for (const QString &name : std::as_const(order)) {
QKeyEvent event(QEvent::KeyPress, key, Qt::NoModifier);
QGuiApplication::sendEvent(&view, &event);
QVERIFY(event.isAccepted());
@@ -421,7 +421,7 @@ void tst_focus::visualFocus()
QQuickItem *column = view.rootObject();
QVERIFY(column);
- QCOMPARE(column->childItems().count(), 2);
+ QCOMPARE(column->childItems().size(), 2);
QQuickControl *button = qobject_cast<QQuickControl *>(column->childItems().first());
QVERIFY(button);
diff --git a/tests/auto/quickcontrols2/platform/CMakeLists.txt b/tests/auto/quickcontrols2/platform/CMakeLists.txt
index 6633de5c02..8e6df7d2b4 100644
--- a/tests/auto/quickcontrols2/platform/CMakeLists.txt
+++ b/tests/auto/quickcontrols2/platform/CMakeLists.txt
@@ -17,6 +17,7 @@ qt_internal_add_test(tst_platform
tst_platform.cpp
PUBLIC_LIBRARIES
Qt::Gui
+ Qt::Qml
TESTDATA ${test_data}
)
diff --git a/tests/auto/quickcontrols2/platform/data/tst_menu.qml b/tests/auto/quickcontrols2/platform/data/tst_menu.qml
index 00a75fe110..fb9949c8b7 100644
--- a/tests/auto/quickcontrols2/platform/data/tst_menu.qml
+++ b/tests/auto/quickcontrols2/platform/data/tst_menu.qml
@@ -4,6 +4,8 @@
import QtQuick
import QtTest
import Qt.labs.platform
+import QtQuick.Controls as Controls
+import org.qtproject.Test
TestCase {
id: testCase
@@ -28,6 +30,11 @@ TestCase {
signalName: "itemsChanged"
}
+ Component {
+ id: signalSpyComponent
+ SignalSpy {}
+ }
+
function init() {
verify(!itemsSpy.target)
compare(itemsSpy.count, 0)
@@ -214,4 +221,68 @@ TestCase {
compare(subMenu.title, "Title")
compare(subMenuItem.text, "Title")
}
+
+ Component {
+ id: disabledMenuItemAndActionComponent
+
+ Item {
+ property alias action: action
+ property alias menu: menu
+
+ Controls.Action {
+ id: action
+ shortcut: StandardKey.Copy
+ }
+
+ Menu {
+ id: menu
+
+ MenuItem {
+ enabled: !action.enabled
+ shortcut: StandardKey.Copy
+ text: "test"
+ }
+ }
+ }
+ }
+
+ function test_shortcuts() {
+ if (!TestHelper.shortcutsSupported)
+ skip("This test requires shortcut support")
+
+ let root = createTemporaryObject(disabledMenuItemAndActionComponent, testCase)
+ verify(root)
+ let menu = root.menu
+ let menuItem = menu.items[0]
+ verify(menuItem)
+ let action = root.action
+
+ let actionTriggeredSpy = signalSpyComponent.createObject(root,
+ { target: action, signalName: "triggered" })
+ verify(actionTriggeredSpy.valid)
+ let menuItemTriggeredSpy = signalSpyComponent.createObject(root,
+ { target: menuItem, signalName: "triggered" })
+ verify(menuItemTriggeredSpy.valid)
+
+ // Perform the shortcut; the Action should be triggered since the MenuItem is disabled.
+ keySequence(StandardKey.Copy)
+ compare(actionTriggeredSpy.count, 1)
+ compare(menuItemTriggeredSpy.count, 0)
+
+ // Disable the Action, enabling the MenuItem in the process.
+ action.enabled = false
+ verify(menuItem.enabled)
+ // Perform the shortcut; the MenuItem should be triggered since the Action is disabled.
+ keySequence(StandardKey.Copy)
+ compare(actionTriggeredSpy.count, 1)
+ compare(menuItemTriggeredSpy.count, 1)
+
+ // Re-enable the Action, disabling the MenuItem in the process.
+ action.enabled = true
+ verify(!menuItem.enabled)
+ // Perform the shortcut; the Action should be triggered since the MenuItem is disabled.
+ keySequence(StandardKey.Copy)
+ compare(actionTriggeredSpy.count, 2)
+ compare(menuItemTriggeredSpy.count, 1)
+ }
}
diff --git a/tests/auto/quickcontrols2/platform/tst_platform.cpp b/tests/auto/quickcontrols2/platform/tst_platform.cpp
index 335ad9b533..94bf1d6a59 100644
--- a/tests/auto/quickcontrols2/platform/tst_platform.cpp
+++ b/tests/auto/quickcontrols2/platform/tst_platform.cpp
@@ -1,5 +1,31 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#include <QtQml/qqmlengine.h>
#include <QtQuickTest/quicktest.h>
-QUICK_TEST_MAIN(tst_platform)
+
+class Setup : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool shortcutsSupported READ areShortcutsSupported CONSTANT FINAL)
+
+public:
+ bool areShortcutsSupported() const
+ {
+#if QT_CONFIG(shortcut)
+ return true;
+#else
+ return false;
+#endif
+ }
+
+public slots:
+ void qmlEngineAvailable(QQmlEngine *)
+ {
+ qmlRegisterSingletonInstance("org.qtproject.Test", 1, 0, "TestHelper", this);
+ }
+};
+
+QUICK_TEST_MAIN_WITH_SETUP(tst_platform, Setup)
+
+#include "tst_platform.moc"
diff --git a/tests/auto/quickcontrols2/pointerhandlers/data/draggableButton.qml b/tests/auto/quickcontrols2/pointerhandlers/data/draggableButton.qml
new file mode 100644
index 0000000000..ca0c4263b1
--- /dev/null
+++ b/tests/auto/quickcontrols2/pointerhandlers/data/draggableButton.qml
@@ -0,0 +1,11 @@
+import QtQuick
+import QtQuick.Controls
+
+Rectangle {
+ width: 150; height: 150
+ Button {
+ text: "Drag me"
+ width: 150 // workaround for QTBUG-104954
+ DragHandler { }
+ }
+}
diff --git a/tests/auto/quickcontrols2/pointerhandlers/data/tapHandlerButton.qml b/tests/auto/quickcontrols2/pointerhandlers/data/tapHandlerButton.qml
new file mode 100644
index 0000000000..74e0166d0e
--- /dev/null
+++ b/tests/auto/quickcontrols2/pointerhandlers/data/tapHandlerButton.qml
@@ -0,0 +1,12 @@
+import QtQuick
+import QtQuick.Controls
+
+Rectangle {
+ width: 150; height: 150
+ color: th.pressed ? "lightsteelblue" : "beige"
+ Button {
+ text: pressed ? "pressed" : ""
+ width: 150 // workaround for QTBUG-104954
+ TapHandler { id: th }
+ }
+}
diff --git a/tests/auto/quickcontrols2/pointerhandlers/tst_pointerhandlers.cpp b/tests/auto/quickcontrols2/pointerhandlers/tst_pointerhandlers.cpp
index ba1fbd2dd1..aa83175252 100644
--- a/tests/auto/quickcontrols2/pointerhandlers/tst_pointerhandlers.cpp
+++ b/tests/auto/quickcontrols2/pointerhandlers/tst_pointerhandlers.cpp
@@ -6,16 +6,23 @@
#include <QtQuick/qquickview.h>
#include <QtQuick/private/qquickmousearea_p.h>
+#include <QtQuick/private/qquickpointerhandler_p.h>
+#include <QtQuick/private/qquicktaphandler_p.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcontext.h>
#include <QtQuickTemplates2/private/qquickbutton_p.h>
+#include <QtGui/qguiapplication.h>
+#include <QtGui/private/qpointingdevice_p.h>
+
#include <QtQuickTestUtils/private/qmlutils_p.h>
#include <QtQuickTestUtils/private/viewtestutils_p.h>
#include <QtQuickTestUtils/private/visualtestutils_p.h>
+Q_LOGGING_CATEGORY(lcPointerTests, "qt.quick.pointer.tests")
+
using namespace QQuickViewTestUtils;
using namespace QQuickVisualTestUtils;
@@ -28,6 +35,13 @@ public:
private slots:
void hover_controlInsideControl();
void hover_controlAndMouseArea();
+ void buttonTapHandler_data();
+ void buttonTapHandler();
+ void buttonDragHandler_data();
+ void buttonDragHandler();
+
+private:
+ QScopedPointer<QPointingDevice> touchscreen = QScopedPointer<QPointingDevice>(QTest::createTouchDevice());
};
tst_pointerhandlers::tst_pointerhandlers()
@@ -154,6 +168,127 @@ void tst_pointerhandlers::hover_controlAndMouseArea()
QCOMPARE(innerMouseArea->hovered(), false);
}
+void tst_pointerhandlers::buttonTapHandler_data()
+{
+ QTest::addColumn<QPointingDevice::DeviceType>("deviceType");
+ QTest::addColumn<Qt::MouseButton>("mouseButton");
+
+ QTest::newRow("left mouse") << QPointingDevice::DeviceType::Mouse << Qt::LeftButton;
+ QTest::newRow("right mouse") << QPointingDevice::DeviceType::Mouse << Qt::RightButton;
+ QTest::newRow("touch") << QPointingDevice::DeviceType::TouchScreen << Qt::NoButton;
+}
+
+void tst_pointerhandlers::buttonTapHandler() // QTBUG-105609
+{
+ QFETCH(QPointingDevice::DeviceType, deviceType);
+ QFETCH(Qt::MouseButton, mouseButton);
+
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("tapHandlerButton.qml")));
+
+ QPointer<QQuickTapHandler> handler = window.rootObject()->findChild<QQuickTapHandler*>();
+ QVERIFY(handler);
+ handler->setAcceptedButtons(mouseButton);
+ QQuickItem *target = handler->target();
+ QVERIFY(target);
+ QSignalSpy tappedSpy(handler, &QQuickTapHandler::tapped);
+ QSignalSpy clickedSpy(target, SIGNAL(clicked())); // avoid #include for this signal
+
+ const QPoint pos(10, 10);
+ switch (static_cast<QPointingDevice::DeviceType>(deviceType)) {
+ case QPointingDevice::DeviceType::Mouse:
+ // click it
+ QTest::mouseClick(&window, mouseButton, Qt::NoModifier, pos);
+ QTRY_COMPARE(clickedSpy.size(), 1); // perhaps Button should not react to right-click, but it does
+ QCOMPARE(tappedSpy.size(), 1);
+ break;
+
+ case QPointingDevice::DeviceType::TouchScreen: {
+ // tap it
+ QTest::QTouchEventSequence touch = QTest::touchEvent(&window, touchscreen.data());
+ touch.press(0, pos, &window).commit();
+ QTRY_COMPARE(target->property("pressed").toBool(), true);
+ touch.release(0, pos, &window).commit();
+ QTRY_COMPARE(clickedSpy.size(), 1);
+ QCOMPARE(tappedSpy.size(), 1);
+ break;
+ }
+ default:
+ break;
+ }
+ QCOMPARE(handler->isPressed(), false);
+}
+
+void tst_pointerhandlers::buttonDragHandler_data()
+{
+ QTest::addColumn<QPointingDevice::DeviceType>("deviceType");
+
+ QTest::newRow("mouse") << QPointingDevice::DeviceType::Mouse;
+ QTest::newRow("touch") << QPointingDevice::DeviceType::TouchScreen;
+}
+
+void tst_pointerhandlers::buttonDragHandler() // QTBUG-105610
+{
+ QFETCH(QPointingDevice::DeviceType, deviceType);
+
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("draggableButton.qml")));
+
+ const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
+
+ QPointer<QQuickPointerHandler> handler = window.rootObject()->findChild<QQuickPointerHandler*>();
+ QVERIFY(handler);
+ QQuickItem *target = handler->target();
+ QVERIFY(target);
+ QSignalSpy clickedSpy(target, SIGNAL(clicked()));
+
+ QPoint dragPos(10, 10);
+ switch (static_cast<QPointingDevice::DeviceType>(deviceType)) {
+ case QPointingDevice::DeviceType::Mouse:
+ // click it
+ QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, dragPos);
+ QTRY_COMPARE(clickedSpy.size(), 1);
+
+ // drag it
+ QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, dragPos);
+ dragPos += QPoint(dragThreshold, dragThreshold);
+ QTest::mouseMove(&window, dragPos);
+ dragPos += QPoint(1, 1);
+ QTest::mouseMove(&window, dragPos);
+ qCDebug(lcPointerTests) << handler << "dragged" << target << "to" << target->position();
+ QTRY_VERIFY(handler->active());
+ QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, dragPos);
+ break;
+
+ case QPointingDevice::DeviceType::TouchScreen: {
+ QTest::QTouchEventSequence touch = QTest::touchEvent(&window, touchscreen.data());
+
+ // tap it
+ touch.press(0, dragPos, &window).commit();
+ touch.release(0, dragPos, &window).commit();
+ QTRY_COMPARE(clickedSpy.size(), 1);
+
+ // drag it
+ touch.press(0, dragPos, &window).commit();
+ dragPos += QPoint(dragThreshold, dragThreshold);
+ touch.move(0, dragPos, &window).commit();
+ dragPos += QPoint(1, 1);
+ touch.move(0, dragPos, &window).commit();
+ qCDebug(lcPointerTests) << handler << "dragged" << target << "to" << target->position();
+ QTRY_VERIFY(handler->active());
+ touch.release(0, dragPos, &window).commit();
+ break;
+ }
+ default:
+ break;
+ }
+ QTRY_COMPARE(handler->active(), false);
+
+ // click it again
+ QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, dragPos);
+ QTRY_COMPARE(clickedSpy.size(), 2);
+}
+
QTEST_MAIN(tst_pointerhandlers)
#include "tst_pointerhandlers.moc"
diff --git a/tests/auto/quickcontrols2/pressandhold/tst_pressandhold.cpp b/tests/auto/quickcontrols2/pressandhold/tst_pressandhold.cpp
index 170e61cafa..98013a1d0c 100644
--- a/tests/auto/quickcontrols2/pressandhold/tst_pressandhold.cpp
+++ b/tests/auto/quickcontrols2/pressandhold/tst_pressandhold.cpp
@@ -79,16 +79,16 @@ void tst_PressAndHold::pressAndHold()
// pressAndHold() emitted
QGuiApplication::sendEvent(control.data(), &press);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QGuiApplication::sendEvent(control.data(), &release);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
// pressAndHold() canceled by release
QGuiApplication::sendEvent(control.data(), &press);
QGuiApplication::processEvents();
QGuiApplication::sendEvent(control.data(), &release);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// pressAndHold() canceled by move
QGuiApplication::sendEvent(control.data(), &press);
@@ -97,12 +97,12 @@ void tst_PressAndHold::pressAndHold()
// by the time the second control emits pressAndHold(), we can reliably
// assume that the first control would have emitted pressAndHold() if it
// wasn't canceled as appropriate by the move event above
- QTRY_COMPARE(waitSpy.count(), 1);
- QCOMPARE(spy.count(), 0);
+ QTRY_COMPARE(waitSpy.size(), 1);
+ QCOMPARE(spy.size(), 0);
QGuiApplication::sendEvent(control.data(), &release);
QGuiApplication::sendEvent(waitControl.data(), &release);
- QCOMPARE(waitSpy.count(), 1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(waitSpy.size(), 1);
+ QCOMPARE(spy.size(), 0);
waitSpy.clear();
// pressAndHold() canceled by 2nd press
@@ -112,12 +112,12 @@ void tst_PressAndHold::pressAndHold()
// by the time the second control emits pressAndHold(), we can reliably
// assume that the first control would have emitted pressAndHold() if it
// wasn't canceled as appropriate by the 2nd press event above
- QTRY_COMPARE(waitSpy.count(), 1);
- QCOMPARE(spy.count(), 0);
+ QTRY_COMPARE(waitSpy.size(), 1);
+ QCOMPARE(spy.size(), 0);
QGuiApplication::sendEvent(control.data(), &release);
QGuiApplication::sendEvent(waitControl.data(), &release);
- QCOMPARE(waitSpy.count(), 1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(waitSpy.size(), 1);
+ QCOMPARE(spy.size(), 0);
waitSpy.clear();
}
@@ -158,9 +158,9 @@ void tst_PressAndHold::keepSelection()
// pressAndHold() emitted => selection remains
QGuiApplication::sendEvent(control.data(), &press);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QGuiApplication::sendEvent(control.data(), &release);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(control->property("selectedText"), control->property("text"));
spy.clear();
@@ -168,7 +168,7 @@ void tst_PressAndHold::keepSelection()
QGuiApplication::sendEvent(control.data(), &press);
QGuiApplication::processEvents();
QGuiApplication::sendEvent(control.data(), &release);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QVERIFY(control->property("selectedText").toString().isEmpty());
QVERIFY(QMetaObject::invokeMethod(control.data(), "selectAll"));
@@ -181,12 +181,12 @@ void tst_PressAndHold::keepSelection()
// by the time the second control emits pressAndHold(), we can reliably
// assume that the first control would have emitted pressAndHold() if it
// wasn't canceled as appropriate by the move event above
- QTRY_COMPARE(waitSpy.count(), 1);
- QCOMPARE(spy.count(), 0);
+ QTRY_COMPARE(waitSpy.size(), 1);
+ QCOMPARE(spy.size(), 0);
QGuiApplication::sendEvent(control.data(), &release);
QGuiApplication::sendEvent(waitControl.data(), &release);
- QCOMPARE(waitSpy.count(), 1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(waitSpy.size(), 1);
+ QCOMPARE(spy.size(), 0);
QVERIFY(control->property("selectedText").toString().isEmpty());
waitSpy.clear();
}
diff --git a/tests/auto/quickcontrols2/qquickapplicationwindow/tst_qquickapplicationwindow.cpp b/tests/auto/quickcontrols2/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
index 000b4e22af..e055340dde 100644
--- a/tests/auto/quickcontrols2/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
+++ b/tests/auto/quickcontrols2/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
@@ -700,7 +700,7 @@ void tst_QQuickApplicationWindow::focusAfterPopupClosed()
QSignalSpy focusScopeSpy(window.data(), SIGNAL(focusScopeKeyPressed()));
QTest::keyClick(window.data(), Qt::Key_Space);
- QCOMPARE(focusScopeSpy.count(), 1);
+ QCOMPARE(focusScopeSpy.size(), 1);
// Open the menu.
QQuickItem* toolButton = window->property("toolButton").value<QQuickItem*>();
@@ -711,14 +711,14 @@ void tst_QQuickApplicationWindow::focusAfterPopupClosed()
// The FocusScope shouldn't receive any key events while the menu is open.
QTest::keyClick(window.data(), Qt::Key_Space);
- QCOMPARE(focusScopeSpy.count(), 1);
+ QCOMPARE(focusScopeSpy.size(), 1);
// Close the menu. The FocusScope should regain focus.
QTest::keyClick(window.data(), Qt::Key_Escape);
QVERIFY(focusScope->hasActiveFocus());
QTest::keyClick(window.data(), Qt::Key_Space);
- QCOMPARE(focusScopeSpy.count(), 2);
+ QCOMPARE(focusScopeSpy.size(), 2);
QQuickPopup *focusPopup = window->property("focusPopup").value<QQuickPopup*>();
QVERIFY(focusPopup);
@@ -729,7 +729,7 @@ void tst_QQuickApplicationWindow::focusAfterPopupClosed()
QSignalSpy focusPopupSpy(window.data(), SIGNAL(focusPopupKeyPressed()));
QTest::keyClick(window.data(), Qt::Key_Space);
- QCOMPARE(focusPopupSpy.count(), 1);
+ QCOMPARE(focusPopupSpy.size(), 1);
QQuickMenu *fileMenu = window->property("fileMenu").value<QQuickMenu*>();
QVERIFY(fileMenu);
@@ -738,21 +738,21 @@ void tst_QQuickApplicationWindow::focusAfterPopupClosed()
// The Popup shouldn't receive any key events while the menu is open.
QTest::keyClick(window.data(), Qt::Key_Space);
- QCOMPARE(focusPopupSpy.count(), 1);
+ QCOMPARE(focusPopupSpy.size(), 1);
// Close the menu. The Popup should regain focus.
QTest::keyClick(window.data(), Qt::Key_Escape);
QVERIFY(focusPopup->hasActiveFocus());
QTest::keyClick(window.data(), Qt::Key_Space);
- QCOMPARE(focusPopupSpy.count(), 2);
+ QCOMPARE(focusPopupSpy.size(), 2);
// Close the popup. The FocusScope should regain focus.
QTest::keyClick(window.data(), Qt::Key_Escape);
QVERIFY(focusScope->hasActiveFocus());
QTest::keyClick(window.data(), Qt::Key_Space);
- QCOMPARE(focusScopeSpy.count(), 3);
+ QCOMPARE(focusScopeSpy.size(), 3);
}
void tst_QQuickApplicationWindow::clearFocusOnDestruction()
@@ -796,7 +796,7 @@ void tst_QQuickApplicationWindow::clearFocusOnDestruction()
Therefore, if you have good reasons to change the behavior (and not emit
it) take the test below with a grain of salt.
*/
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QQuickApplicationWindow::layout()
diff --git a/tests/auto/quickcontrols2/qquickcontrol/tst_qquickcontrol.cpp b/tests/auto/quickcontrols2/qquickcontrol/tst_qquickcontrol.cpp
index ca6183e41d..ddb4b7ff8b 100644
--- a/tests/auto/quickcontrols2/qquickcontrol/tst_qquickcontrol.cpp
+++ b/tests/auto/quickcontrols2/qquickcontrol/tst_qquickcontrol.cpp
@@ -66,12 +66,12 @@ void tst_QQuickControl::flickable()
QPoint p(button->width() / 2, button->height() / 2);
QTest::touchEvent(window, touchDevice.data()).press(0, p);
- QTRY_COMPARE(buttonPressedSpy.count(), 1);
+ QTRY_COMPARE(buttonPressedSpy.size(), 1);
p += QPoint(1, 1); // less than the drag threshold
QTest::touchEvent(window, touchDevice.data()).move(0, p);
QTest::touchEvent(window, touchDevice.data()).release(0, p);
- QTRY_COMPARE(buttonReleasedSpy.count(), 1);
- QTRY_COMPARE(buttonClickedSpy.count(), 1);
+ QTRY_COMPARE(buttonReleasedSpy.size(), 1);
+ QTRY_COMPARE(buttonClickedSpy.size(), 1);
}
void tst_QQuickControl::fractionalFontSize()
diff --git a/tests/auto/quickcontrols2/qquickdrawer/data/itemPartialOverlayModal.qml b/tests/auto/quickcontrols2/qquickdrawer/data/itemPartialOverlayModal.qml
new file mode 100644
index 0000000000..23aa4ca3c2
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickdrawer/data/itemPartialOverlayModal.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+
+Item {
+ width: 400; height: 400
+
+ Drawer {
+ edge: Qt.LeftEdge
+ height: 200
+ width: 200
+ modal: true
+ }
+}
diff --git a/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp
index 48e1a541be..4b2260d4ea 100644
--- a/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp
+++ b/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp
@@ -14,14 +14,16 @@
#include <QtQml/QQmlComponent>
#include <QtQuick/private/qquickwindow_p.h>
#include <QtQuick/private/qquickflickable_p.h>
+#include <QtQuick/qquickview.h>
#include <QtQuickTestUtils/private/qmlutils_p.h>
#include <QtQuickTestUtils/private/visualtestutils_p.h>
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
-#include <QtQuickTemplates2/private/qquickoverlay_p.h>
+#include <QtQuickTemplates2/private/qquickoverlay_p_p.h>
#include <QtQuickTemplates2/private/qquickpopup_p_p.h>
#include <QtQuickTemplates2/private/qquickdrawer_p.h>
#include <QtQuickTemplates2/private/qquickbutton_p.h>
#include <QtQuickTemplates2/private/qquickslider_p.h>
+#include <QtQuickTestUtils/private/viewtestutils_p.h>
#include <QtQuickControlsTestUtils/private/controlstestutils_p.h>
#include <QtQuickControlsTestUtils/private/qtest_quickcontrols_p.h>
@@ -90,6 +92,10 @@ private slots:
void topEdgeScreenEdge();
+ void bookkeepingInOverlay();
+
+ void touchOutsideOverlay();
+
private:
QScopedPointer<QPointingDevice> touchDevice;
};
@@ -225,71 +231,71 @@ void tst_QQuickDrawer::state()
// open programmatically...
drawer->open();
- QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount);
- QCOMPARE(aboutToShowSpy.count(), ++aboutToShowCount);
- QCOMPARE(aboutToHideSpy.count(), aboutToHideCount);
- QCOMPARE(openedSpy.count(), openedCount);
- QCOMPARE(closedSpy.count(), closedCount);
+ QCOMPARE(visibleChangedSpy.size(), ++visibleChangedCount);
+ QCOMPARE(aboutToShowSpy.size(), ++aboutToShowCount);
+ QCOMPARE(aboutToHideSpy.size(), aboutToHideCount);
+ QCOMPARE(openedSpy.size(), openedCount);
+ QCOMPARE(closedSpy.size(), closedCount);
// ...and wait until fully open
QVERIFY(openedSpy.wait());
- QCOMPARE(visibleChangedSpy.count(), visibleChangedCount);
- QCOMPARE(aboutToShowSpy.count(), aboutToShowCount);
- QCOMPARE(aboutToHideSpy.count(), aboutToHideCount);
- QCOMPARE(openedSpy.count(), ++openedCount);
- QCOMPARE(closedSpy.count(), closedCount);
+ QCOMPARE(visibleChangedSpy.size(), visibleChangedCount);
+ QCOMPARE(aboutToShowSpy.size(), aboutToShowCount);
+ QCOMPARE(aboutToHideSpy.size(), aboutToHideCount);
+ QCOMPARE(openedSpy.size(), ++openedCount);
+ QCOMPARE(closedSpy.size(), closedCount);
// close programmatically...
drawer->close();
- QCOMPARE(visibleChangedSpy.count(), visibleChangedCount);
- QCOMPARE(aboutToShowSpy.count(), aboutToShowCount);
- QCOMPARE(aboutToHideSpy.count(), ++aboutToHideCount);
- QCOMPARE(openedSpy.count(), openedCount);
- QCOMPARE(closedSpy.count(), closedCount);
+ QCOMPARE(visibleChangedSpy.size(), visibleChangedCount);
+ QCOMPARE(aboutToShowSpy.size(), aboutToShowCount);
+ QCOMPARE(aboutToHideSpy.size(), ++aboutToHideCount);
+ QCOMPARE(openedSpy.size(), openedCount);
+ QCOMPARE(closedSpy.size(), closedCount);
// ...and wait until fully closed
QVERIFY(closedSpy.wait());
- QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount);
- QCOMPARE(aboutToShowSpy.count(), aboutToShowCount);
- QCOMPARE(aboutToHideSpy.count(), aboutToHideCount);
- QCOMPARE(openedSpy.count(), openedCount);
- QCOMPARE(closedSpy.count(), ++closedCount);
+ QCOMPARE(visibleChangedSpy.size(), ++visibleChangedCount);
+ QCOMPARE(aboutToShowSpy.size(), aboutToShowCount);
+ QCOMPARE(aboutToHideSpy.size(), aboutToHideCount);
+ QCOMPARE(openedSpy.size(), openedCount);
+ QCOMPARE(closedSpy.size(), ++closedCount);
// open interactively...
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, drawer->height() / 2));
QTest::mouseMove(window, QPoint(drawer->width() * 0.2, drawer->height() / 2), 16);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width() * 0.8, drawer->height() / 2), 16);
- QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount);
- QCOMPARE(aboutToShowSpy.count(), ++aboutToShowCount);
- QCOMPARE(aboutToHideSpy.count(), aboutToHideCount);
- QCOMPARE(openedSpy.count(), openedCount);
- QCOMPARE(closedSpy.count(), closedCount);
+ QCOMPARE(visibleChangedSpy.size(), ++visibleChangedCount);
+ QCOMPARE(aboutToShowSpy.size(), ++aboutToShowCount);
+ QCOMPARE(aboutToHideSpy.size(), aboutToHideCount);
+ QCOMPARE(openedSpy.size(), openedCount);
+ QCOMPARE(closedSpy.size(), closedCount);
// ...and wait until fully open
QVERIFY(openedSpy.wait());
- QCOMPARE(visibleChangedSpy.count(), visibleChangedCount);
- QCOMPARE(aboutToShowSpy.count(), aboutToShowCount);
- QCOMPARE(aboutToHideSpy.count(), aboutToHideCount);
- QCOMPARE(openedSpy.count(), ++openedCount);
- QCOMPARE(closedSpy.count(), closedCount);
+ QCOMPARE(visibleChangedSpy.size(), visibleChangedCount);
+ QCOMPARE(aboutToShowSpy.size(), aboutToShowCount);
+ QCOMPARE(aboutToHideSpy.size(), aboutToHideCount);
+ QCOMPARE(openedSpy.size(), ++openedCount);
+ QCOMPARE(closedSpy.size(), closedCount);
// close interactively...
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width(), drawer->height() / 2));
QTest::mouseMove(window, QPoint(drawer->width() * 0.8, drawer->height() / 2), 16);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width() * 0.2, drawer->height() / 2), 16);
- QCOMPARE(visibleChangedSpy.count(), visibleChangedCount);
- QCOMPARE(aboutToShowSpy.count(), aboutToShowCount);
- QCOMPARE(aboutToHideSpy.count(), ++aboutToHideCount);
- QCOMPARE(openedSpy.count(), openedCount);
- QCOMPARE(closedSpy.count(), closedCount);
+ QCOMPARE(visibleChangedSpy.size(), visibleChangedCount);
+ QCOMPARE(aboutToShowSpy.size(), aboutToShowCount);
+ QCOMPARE(aboutToHideSpy.size(), ++aboutToHideCount);
+ QCOMPARE(openedSpy.size(), openedCount);
+ QCOMPARE(closedSpy.size(), closedCount);
// ...and wait until fully closed
QVERIFY(closedSpy.wait());
- QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount);
- QCOMPARE(aboutToShowSpy.count(), aboutToShowCount);
- QCOMPARE(aboutToHideSpy.count(), aboutToHideCount);
- QCOMPARE(openedSpy.count(), openedCount);
- QCOMPARE(closedSpy.count(), ++closedCount);
+ QCOMPARE(visibleChangedSpy.size(), ++visibleChangedCount);
+ QCOMPARE(aboutToShowSpy.size(), aboutToShowCount);
+ QCOMPARE(aboutToHideSpy.size(), aboutToHideCount);
+ QCOMPARE(openedSpy.size(), openedCount);
+ QCOMPARE(closedSpy.size(), ++closedCount);
}
void tst_QQuickDrawer::position_data()
@@ -518,7 +524,7 @@ void tst_QQuickDrawer::header()
QSignalSpy clickSpy(button, SIGNAL(clicked()));
QVERIFY(clickSpy.isValid());
QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + button->width() / 2, button->y() + button->height() / 2));
- QCOMPARE(clickSpy.count(), 1);
+ QCOMPARE(clickSpy.size(), 1);
}
void tst_QQuickDrawer::dragHandlerInteraction()
@@ -577,7 +583,7 @@ void tst_QQuickDrawer::hover()
QSignalSpy openedSpy(drawer, SIGNAL(opened()));
QVERIFY(openedSpy.isValid());
drawer->open();
- QVERIFY(openedSpy.count() == 1 || openedSpy.wait());
+ QVERIFY(openedSpy.size() == 1 || openedSpy.wait());
// hover the background button outside the drawer
QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1));
@@ -600,7 +606,7 @@ void tst_QQuickDrawer::hover()
QSignalSpy closedSpy(drawer, SIGNAL(closed()));
QVERIFY(closedSpy.isValid());
drawer->close();
- QVERIFY(closedSpy.count() == 1 || closedSpy.wait());
+ QVERIFY(closedSpy.size() == 1 || closedSpy.wait());
// hover the background button after closing the drawer
QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2));
@@ -665,7 +671,7 @@ void tst_QQuickDrawer::wheel()
QSignalSpy openedSpy(drawer, SIGNAL(opened()));
QVERIFY(openedSpy.isValid());
drawer->open();
- QVERIFY(openedSpy.count() == 1 || openedSpy.wait());
+ QVERIFY(openedSpy.size() == 1 || openedSpy.wait());
{
// wheel over the drawer content
@@ -725,9 +731,9 @@ void tst_QQuickDrawer::multiple()
// no drawers open, click the content
QTest::mouseClick(window, Qt::LeftButton);
- QCOMPARE(contentClickSpy.count(), 1);
- QCOMPARE(leftClickSpy.count(), 0);
- QCOMPARE(rightClickSpy.count(), 0);
+ QCOMPARE(contentClickSpy.size(), 1);
+ QCOMPARE(leftClickSpy.size(), 0);
+ QCOMPARE(rightClickSpy.size(), 0);
// drag the left drawer open
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, window->height() / 2));
@@ -754,30 +760,30 @@ void tst_QQuickDrawer::multiple()
// click the left drawer's button
QTest::mouseClick(window, Qt::LeftButton);
- QCOMPARE(contentClickSpy.count(), 1);
- QCOMPARE(leftClickSpy.count(), 1);
- QCOMPARE(rightClickSpy.count(), 0);
+ QCOMPARE(contentClickSpy.size(), 1);
+ QCOMPARE(leftClickSpy.size(), 1);
+ QCOMPARE(rightClickSpy.size(), 0);
// click the left drawer's background (button disabled, don't leak through to the right drawer below)
leftButton->setEnabled(false);
QTest::mouseClick(window, Qt::LeftButton);
- QCOMPARE(contentClickSpy.count(), 1);
- QCOMPARE(leftClickSpy.count(), 1);
- QCOMPARE(rightClickSpy.count(), 0);
+ QCOMPARE(contentClickSpy.size(), 1);
+ QCOMPARE(leftClickSpy.size(), 1);
+ QCOMPARE(rightClickSpy.size(), 0);
leftButton->setEnabled(true);
// click the overlay of the left drawer (don't leak through to right drawer below)
QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - (window->width() - leftDrawer->width()) / 2, window->height() / 2));
- QCOMPARE(contentClickSpy.count(), 1);
- QCOMPARE(leftClickSpy.count(), 1);
- QCOMPARE(rightClickSpy.count(), 0);
+ QCOMPARE(contentClickSpy.size(), 1);
+ QCOMPARE(leftClickSpy.size(), 1);
+ QCOMPARE(rightClickSpy.size(), 0);
QTRY_VERIFY(!leftDrawer->isVisible());
// click the right drawer's button
QTest::mouseClick(window, Qt::LeftButton);
- QCOMPARE(contentClickSpy.count(), 1);
- QCOMPARE(leftClickSpy.count(), 1);
- QCOMPARE(rightClickSpy.count(), 1);
+ QCOMPARE(contentClickSpy.size(), 1);
+ QCOMPARE(leftClickSpy.size(), 1);
+ QCOMPARE(rightClickSpy.size(), 1);
// cannot drag the left drawer while the right drawer is open
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, window->height() / 2));
@@ -791,23 +797,23 @@ void tst_QQuickDrawer::multiple()
// click the right drawer's background (button disabled, don't leak through to the content below)
rightButton->setEnabled(false);
QTest::mouseClick(window, Qt::LeftButton);
- QCOMPARE(contentClickSpy.count(), 1);
- QCOMPARE(leftClickSpy.count(), 1);
- QCOMPARE(rightClickSpy.count(), 1);
+ QCOMPARE(contentClickSpy.size(), 1);
+ QCOMPARE(leftClickSpy.size(), 1);
+ QCOMPARE(rightClickSpy.size(), 1);
rightButton->setEnabled(true);
// click the overlay of the right drawer (don't leak through to the content below)
QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint((window->width() - rightDrawer->width()) / 2, window->height() / 2));
- QCOMPARE(contentClickSpy.count(), 1);
- QCOMPARE(leftClickSpy.count(), 1);
- QCOMPARE(rightClickSpy.count(), 1);
+ QCOMPARE(contentClickSpy.size(), 1);
+ QCOMPARE(leftClickSpy.size(), 1);
+ QCOMPARE(rightClickSpy.size(), 1);
QTRY_VERIFY(!rightDrawer->isVisible());
// no drawers open, click the content
QTest::mouseClick(window, Qt::LeftButton);
- QCOMPARE(contentClickSpy.count(), 2);
- QCOMPARE(leftClickSpy.count(), 1);
- QCOMPARE(rightClickSpy.count(), 1);
+ QCOMPARE(contentClickSpy.size(), 2);
+ QCOMPARE(leftClickSpy.size(), 1);
+ QCOMPARE(rightClickSpy.size(), 1);
// drag the right drawer open
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, window->height() / 2));
@@ -920,33 +926,33 @@ void tst_QQuickDrawer::multiTouch()
QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100));
QVERIFY(popup->isVisible());
QVERIFY(drawer->isVisible());
- QCOMPARE(buttonPressedSpy.count(), 0);
- QCOMPARE(overlayPressedSpy.count(), 1);
+ QCOMPARE(buttonPressedSpy.size(), 0);
+ QCOMPARE(overlayPressedSpy.size(), 1);
// 2nd press (blocked & ignored)
QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200));
QVERIFY(popup->isVisible());
QVERIFY(drawer->isVisible());
- QCOMPARE(buttonPressedSpy.count(), 0);
- QCOMPARE(overlayPressedSpy.count(), 2);
+ QCOMPARE(buttonPressedSpy.size(), 0);
+ QCOMPARE(overlayPressedSpy.size(), 2);
// 2nd release (blocked & ignored)
QTest::touchEvent(window, touchDevice.data()).stationary(0).release(1, QPoint(300, 200));
QVERIFY(popup->isVisible());
QVERIFY(drawer->isVisible());
- QCOMPARE(buttonPressedSpy.count(), 0);
- QCOMPARE(buttonReleasedSpy.count(), 0);
- QCOMPARE(overlayPressedSpy.count(), 2);
- QCOMPARE(overlayReleasedSpy.count(), 1);
+ QCOMPARE(buttonPressedSpy.size(), 0);
+ QCOMPARE(buttonReleasedSpy.size(), 0);
+ QCOMPARE(overlayPressedSpy.size(), 2);
+ QCOMPARE(overlayReleasedSpy.size(), 1);
// 1st release
QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100));
QVERIFY(popup->isVisible());
QTRY_VERIFY(!drawer->isVisible());
- QCOMPARE(buttonPressedSpy.count(), 0);
- QCOMPARE(buttonReleasedSpy.count(), 0);
- QCOMPARE(overlayPressedSpy.count(), 2);
- QCOMPARE(overlayReleasedSpy.count(), 2);
+ QCOMPARE(buttonPressedSpy.size(), 0);
+ QCOMPARE(buttonReleasedSpy.size(), 0);
+ QCOMPARE(overlayPressedSpy.size(), 2);
+ QCOMPARE(overlayReleasedSpy.size(), 2);
drawer->open();
QVERIFY(drawer->isVisible());
@@ -954,8 +960,8 @@ void tst_QQuickDrawer::multiTouch()
// 1st drag
QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100));
- QCOMPARE(buttonPressedSpy.count(), 0);
- QCOMPARE(overlayPressedSpy.count(), 3);
+ QCOMPARE(buttonPressedSpy.size(), 0);
+ QCOMPARE(overlayPressedSpy.size(), 3);
for (int x = 300; x >= 100; x -= 10) {
QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, 100));
QVERIFY(popup->isVisible());
@@ -965,8 +971,8 @@ void tst_QQuickDrawer::multiTouch()
// 2nd drag (blocked & ignored)
QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200));
- QCOMPARE(buttonPressedSpy.count(), 0);
- QCOMPARE(overlayPressedSpy.count(), 4);
+ QCOMPARE(buttonPressedSpy.size(), 0);
+ QCOMPARE(overlayPressedSpy.size(), 4);
for (int x = 300; x >= 0; x -= 10) {
QTest::touchEvent(window, touchDevice.data()).stationary(0).move(1, QPoint(x, 200));
QVERIFY(popup->isVisible());
@@ -979,15 +985,15 @@ void tst_QQuickDrawer::multiTouch()
QVERIFY(popup->isVisible());
QVERIFY(drawer->isVisible());
QCOMPARE(drawer->position(), 0.5);
- QCOMPARE(buttonReleasedSpy.count(), 0);
- QCOMPARE(overlayReleasedSpy.count(), 3);
+ QCOMPARE(buttonReleasedSpy.size(), 0);
+ QCOMPARE(overlayReleasedSpy.size(), 3);
// 1st release
QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100));
QVERIFY(popup->isVisible());
QTRY_VERIFY(!drawer->isVisible());
- QCOMPARE(buttonReleasedSpy.count(), 0);
- QCOMPARE(overlayReleasedSpy.count(), 4);
+ QCOMPARE(buttonReleasedSpy.size(), 0);
+ QCOMPARE(overlayReleasedSpy.size(), 4);
}
void tst_QQuickDrawer::grabber()
@@ -1021,10 +1027,10 @@ void tst_QQuickDrawer::grabber()
QVERIFY(popupClosedSpy.isValid());
popup->open();
- QTRY_COMPARE(popupOpenedSpy.count(), 1);
+ QTRY_COMPARE(popupOpenedSpy.size(), 1);
QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(100, 300));
- QTRY_COMPARE(popupClosedSpy.count(), 1);
+ QTRY_COMPARE(popupClosedSpy.size(), 1);
}
void tst_QQuickDrawer::interactive_data()
@@ -1062,7 +1068,7 @@ void tst_QQuickDrawer::interactive()
// click outside
QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(300, 100));
- QCOMPARE(aboutToHideSpy.count(), 0);
+ QCOMPARE(aboutToHideSpy.size(), 0);
// drag inside
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width(), 0));
@@ -1070,7 +1076,7 @@ void tst_QQuickDrawer::interactive()
QCOMPARE(drawer->position(), 1.0);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, 0));
QCOMPARE(drawer->position(), 1.0);
- QCOMPARE(aboutToHideSpy.count(), 0);
+ QCOMPARE(aboutToHideSpy.size(), 0);
// drag outside
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, 0));
@@ -1078,11 +1084,11 @@ void tst_QQuickDrawer::interactive()
QCOMPARE(drawer->position(), 1.0);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, 0));
QCOMPARE(drawer->position(), 1.0);
- QCOMPARE(aboutToHideSpy.count(), 0);
+ QCOMPARE(aboutToHideSpy.size(), 0);
// close on escape
QTest::keyClick(window, Qt::Key_Escape);
- QCOMPARE(aboutToHideSpy.count(), 0);
+ QCOMPARE(aboutToHideSpy.size(), 0);
}
void tst_QQuickDrawer::flickable_data()
@@ -1362,6 +1368,66 @@ void tst_QQuickDrawer::topEdgeScreenEdge()
QTRY_COMPARE(drawer->position(), 1.0);
}
+void tst_QQuickDrawer::bookkeepingInOverlay()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("window.qml"));
+
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY2(!root.isNull(), qPrintable(component.errorString()));
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(root.get());
+ QVERIFY(window);
+ QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer *>();
+ QVERIFY(drawer);
+ QQuickOverlay *overlay = QQuickOverlay::overlay(window);
+ QVERIFY(overlay);
+#ifdef QT_BUILD_INTERNAL
+ QQuickOverlayPrivate *overlayD = QQuickOverlayPrivate::get(overlay);
+ QVERIFY(!overlayD->stackingOrderDrawers().isEmpty());
+#endif
+
+ delete drawer;
+#ifdef QT_BUILD_INTERNAL
+ QVERIFY(overlayD->stackingOrderDrawers().isEmpty());
+#endif
+}
+
+void tst_QQuickDrawer::touchOutsideOverlay() // QTBUG-103811
+{
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("itemPartialOverlayModal.qml")));
+ auto *drawer = window.rootObject()->findChild<QQuickDrawer*>();
+ QVERIFY(drawer);
+ QSignalSpy openedSpy(drawer, &QQuickDrawer::opened);
+ QSignalSpy closedSpy(drawer, &QQuickDrawer::closed);
+
+ drawer->open();
+ QVERIFY(openedSpy.size() == 1 || openedSpy.wait());
+ QVERIFY(drawer->isOpened());
+
+ // tap-dance in bottom area beyond the overlay
+ QPoint p1(100, 250);
+ QPoint p2(300, 250);
+ QTest::touchEvent(&window, touchDevice.data()).press(1, p1);
+ p1 -= QPoint(1, 0);
+ QTest::touchEvent(&window, touchDevice.data()).move(1, p1).press(2, p2);
+ p2 -= QPoint(1, 0);
+ QTest::touchEvent(&window, touchDevice.data()).release(1, p1).move(2, p2);
+ QTest::touchEvent(&window, touchDevice.data()).press(1, p1).stationary(2);
+ QTest::touchEvent(&window, touchDevice.data()).release(1, p1).release(2, p2);
+ QQuickTouchUtils::flush(&window);
+
+ // tap the overlay to try to close the drawer
+ QVERIFY(drawer->closePolicy().testFlag(QQuickPopup::CloseOnReleaseOutside));
+ const QPoint p3(300, 100);
+ QTest::touchEvent(&window, touchDevice.data()).press(3, p3);
+ QTest::touchEvent(&window, touchDevice.data()).release(3, p3);
+ QQuickTouchUtils::flush(&window);
+ QVERIFY(closedSpy.size() == 1 || closedSpy.wait());
+ QCOMPARE(drawer->isOpened(), false);
+}
+
QTEST_QUICKCONTROLS_MAIN(tst_QQuickDrawer)
#include "tst_qquickdrawer.moc"
diff --git a/tests/auto/quickcontrols2/qquickheaderview/tst_qquickheaderview.cpp b/tests/auto/quickcontrols2/qquickheaderview/tst_qquickheaderview.cpp
index d9d2ab5691..28b92fef71 100644
--- a/tests/auto/quickcontrols2/qquickheaderview/tst_qquickheaderview.cpp
+++ b/tests/auto/quickcontrols2/qquickheaderview/tst_qquickheaderview.cpp
@@ -329,16 +329,16 @@ void tst_QQuickHeaderView::testModel()
QVERIFY(modelChangedSpy.isValid());
hhv->setModel(QVariant::fromValue(thm));
- QCOMPARE(modelChangedSpy.count(), 0);
+ QCOMPARE(modelChangedSpy.size(), 0);
hhv->setModel(QVariant::fromValue(pm));
- QCOMPARE(modelChangedSpy.count(), 1);
+ QCOMPARE(modelChangedSpy.size(), 1);
TestTableModel ttm2;
ttm2.setRowCount(100);
ttm2.setColumnCount(30);
hhv->setModel(QVariant::fromValue(&ttm2));
- QCOMPARE(modelChangedSpy.count(), 2);
+ QCOMPARE(modelChangedSpy.size(), 2);
}
void tst_QQuickHeaderView::listModel()
diff --git a/tests/auto/quickcontrols2/qquickiconlabel/tst_qquickiconlabel.cpp b/tests/auto/quickcontrols2/qquickiconlabel/tst_qquickiconlabel.cpp
index 5aab4a0f09..8d42cf5faf 100644
--- a/tests/auto/quickcontrols2/qquickiconlabel/tst_qquickiconlabel.cpp
+++ b/tests/auto/quickcontrols2/qquickiconlabel/tst_qquickiconlabel.cpp
@@ -130,7 +130,7 @@ void tst_qquickiconlabel::display()
// Test that the icon and text are correctly positioned and sized after
// setting several different display types in succession.
- for (QQuickIconLabel::Display displayType : qAsConst(displayTypes)) {
+ for (QQuickIconLabel::Display displayType : std::as_const(displayTypes)) {
label->setDisplay(displayType);
QCOMPARE(label->display(), displayType);
diff --git a/tests/auto/quickcontrols2/qquickimaginestyle/data/tst_imagine.qml b/tests/auto/quickcontrols2/qquickimaginestyle/data/tst_imagine.qml
index 01e9bed693..c6bb83f72a 100644
--- a/tests/auto/quickcontrols2/qquickimaginestyle/data/tst_imagine.qml
+++ b/tests/auto/quickcontrols2/qquickimaginestyle/data/tst_imagine.qml
@@ -141,9 +141,9 @@ TestCase {
{ target: testCase.Window.window, signalName: "afterRendering" })
verify(afterRenderingSpy.valid)
- afterRenderingSpy.wait(100)
+ afterRenderingSpy.wait(1000)
container.ninePatchImage.source = ""
// Shouldn't result in a crash.
- afterRenderingSpy.wait(100)
+ afterRenderingSpy.wait(1000)
}
}
diff --git a/tests/auto/quickcontrols2/qquickmaterialstyle/CMakeLists.txt b/tests/auto/quickcontrols2/qquickmaterialstyle/CMakeLists.txt
index 332f376d9f..3dabf123ad 100644
--- a/tests/auto/quickcontrols2/qquickmaterialstyle/CMakeLists.txt
+++ b/tests/auto/quickcontrols2/qquickmaterialstyle/CMakeLists.txt
@@ -17,7 +17,6 @@ qt_internal_add_test(tst_qquickmaterialstyle
tst_qquickmaterialstyle.cpp
PUBLIC_LIBRARIES
Qt::Gui
- Qt::Qml
TESTDATA ${test_data}
)
diff --git a/tests/auto/quickcontrols2/qquickmaterialstyle/data/tst_material.qml b/tests/auto/quickcontrols2/qquickmaterialstyle/data/tst_material.qml
index a9c401d155..689d90ca25 100644
--- a/tests/auto/quickcontrols2/qquickmaterialstyle/data/tst_material.qml
+++ b/tests/auto/quickcontrols2/qquickmaterialstyle/data/tst_material.qml
@@ -8,8 +8,6 @@ import QtQuick.Templates as T
import QtQuick.Controls
import QtQuick.Controls.Material
-import org.qtproject.Test
-
TestCase {
id: testCase
width: 200
@@ -18,6 +16,12 @@ TestCase {
when: windowShown
name: "Material"
+ function init() {
+ // This is particularly important for test_propertyBindingLoop,
+ // which relies on binding loop warnings failing the test.
+ failOnWarning(/.?/)
+ }
+
Component {
id: button
Button { }
@@ -35,17 +39,12 @@ TestCase {
}
Component {
- id: window
+ id: windowComponent
Window { }
}
Component {
- id: applicationWindow
- ApplicationWindow { }
- }
-
- Component {
- id: styledWindow
+ id: styledWindowComponent
Window {
Material.theme: Material.Dark
Material.primary: Material.Brown
@@ -56,7 +55,7 @@ TestCase {
}
Component {
- id: loader
+ id: buttonLoaderComponent
Loader {
active: false
sourceComponent: Button { }
@@ -64,7 +63,7 @@ TestCase {
}
Component {
- id: swipeView
+ id: swipeViewComponent
SwipeView {
Material.theme: Material.Dark
Button { }
@@ -72,7 +71,7 @@ TestCase {
}
Component {
- id: menu
+ id: menuComponent
ApplicationWindow {
Material.primary: Material.Blue
Material.accent: Material.Red
@@ -115,7 +114,7 @@ TestCase {
}
Component {
- id: comboBox
+ id: comboBoxComponent
ApplicationWindow {
width: 200
height: 200
@@ -132,7 +131,7 @@ TestCase {
}
Component {
- id: windowPane
+ id: windowPaneComponent
ApplicationWindow {
width: 200
height: 200
@@ -151,7 +150,7 @@ TestCase {
}
function test_defaults() {
- var control = button.createObject(testCase)
+ let control = createTemporaryObject(button, testCase)
verify(control)
verify(control.Material)
compare(control.Material.primary, Material.color(Material.Indigo))
@@ -159,11 +158,10 @@ TestCase {
compare(control.Material.foreground, "#dd000000")
compare(control.Material.background, "#fafafa")
compare(control.Material.theme, Material.Light)
- control.destroy()
}
function test_set() {
- var control = button.createObject(testCase)
+ let control = createTemporaryObject(button, testCase)
verify(control)
control.Material.primary = Material.Green
control.Material.accent = Material.Brown
@@ -175,11 +173,10 @@ TestCase {
compare(control.Material.background, Material.color(Material.Red, themeshade(control.Material.theme)))
compare(control.Material.foreground, Material.color(Material.Blue))
compare(control.Material.theme, Material.Dark)
- control.destroy()
}
function test_reset() {
- var control = styledButton.createObject(testCase)
+ let control = createTemporaryObject(styledButton, testCase)
verify(control)
compare(control.Material.primary, Material.color(Material.DeepOrange))
compare(control.Material.accent, Material.color(Material.DeepPurple, themeshade(control.Material.theme)))
@@ -196,7 +193,6 @@ TestCase {
compare(control.Material.background, testCase.Material.background)
compare(control.Material.foreground, testCase.Material.foreground)
compare(control.Material.theme, testCase.Material.theme)
- control.destroy()
}
function test_inheritance_data() {
@@ -210,19 +206,19 @@ TestCase {
}
function test_inheritance(data) {
- var prop = data.tag
- var parent = button.createObject(testCase)
+ let prop = data.tag
+ let parent = createTemporaryObject(button, testCase)
parent.Material[prop] = data.value1
compare(parent.Material[prop], data.value1)
- var child1 = button.createObject(parent)
+ let child1 = button.createObject(parent)
compare(child1.Material[prop], data.value1)
parent.Material[prop] = data.value2
compare(parent.Material[prop], data.value2)
compare(child1.Material[prop], data.value2)
- var child2 = button.createObject(parent)
+ let child2 = button.createObject(parent)
compare(child2.Material[prop], data.value2)
child2.Material[prop] = data.value1
@@ -236,21 +232,19 @@ TestCase {
compare(child1.Material[prop], parent.Material[prop])
verify(child2.Material[prop] !== parent.Material[prop])
- var grandChild1 = button.createObject(child1)
- var grandChild2 = button.createObject(child2)
+ let grandChild1 = button.createObject(child1)
+ let grandChild2 = button.createObject(child2)
compare(grandChild1.Material[prop], child1.Material[prop])
compare(grandChild2.Material[prop], child2.Material[prop])
- var themelessGrandGrandChild = button.createObject(grandChild1)
- var grandGrandGrandChild1 = button.createObject(themelessGrandGrandChild)
+ let themelessGrandGrandChild = button.createObject(grandChild1)
+ let grandGrandGrandChild1 = button.createObject(themelessGrandGrandChild)
compare(grandGrandGrandChild1.Material[prop], parent.Material[prop])
child1.Material[prop] = data.value2
compare(child1.Material[prop], data.value2)
compare(grandChild1.Material[prop], data.value2)
compare(grandGrandGrandChild1.Material[prop], data.value2)
-
- parent.destroy()
}
function test_inheritance_popup_data() {
@@ -262,8 +256,8 @@ TestCase {
}
function test_inheritance_popup(data) {
- var prop = data.tag
- var popupObject = popupComponent.createObject(testCase)
+ let prop = data.tag
+ let popupObject = createTemporaryObject(popupComponent, testCase)
compare(popupObject.popup.Material.textSelectionColor.toString(), popupObject.Material.textSelectionColor.toString())
compare(popupObject.label.color.toString(), popupObject.Material.textSelectionColor.toString())
compare(popupObject.label2.color.toString(), popupObject.Material.textSelectionColor.toString())
@@ -279,28 +273,26 @@ TestCase {
compare(popupObject.popup.Material.textSelectionColor.toString(), popupObject.Material.textSelectionColor.toString())
compare(popupObject.label.color.toString(), popupObject.Material.textSelectionColor.toString())
compare(popupObject.label2.color.toString(), popupObject.Material.textSelectionColor.toString())
-
- popupObject.destroy()
}
function test_window() {
- var parent = window.createObject()
+ let parent = createTemporaryObject(windowComponent)
- var control = button.createObject(parent.contentItem)
+ let control = button.createObject(parent.contentItem)
compare(control.Material.primary, parent.Material.primary)
compare(control.Material.accent, parent.Material.accent)
compare(control.Material.background, parent.Material.background)
compare(control.Material.foreground, parent.Material.foreground)
compare(control.Material.theme, parent.Material.theme)
- var styledChild = styledWindow.createObject(window)
+ let styledChild = styledWindowComponent.createObject(parent)
verify(styledChild.Material.primary !== parent.Material.primary)
verify(styledChild.Material.accent !== parent.Material.accent)
verify(styledChild.Material.background !== parent.Material.background)
verify(styledChild.Material.foreground !== parent.Material.foreground)
verify(styledChild.Material.theme !== parent.Material.theme)
- var unstyledChild = window.createObject(window)
+ let unstyledChild = windowComponent.createObject(parent)
compare(unstyledChild.Material.primary, parent.Material.primary)
compare(unstyledChild.Material.accent, parent.Material.accent)
compare(unstyledChild.Material.background, parent.Material.background)
@@ -326,12 +318,10 @@ TestCase {
compare(control.Material.foreground, Material.color(Material.Pink))
verify(styledChild.Material.foreground !== Material.color(Material.Pink))
// ### TODO: compare(unstyledChild.Material.foreground, Material.color(Material.Pink))
-
- parent.destroy()
}
function test_loader() {
- var control = loader.createObject(testCase)
+ let control = createTemporaryObject(buttonLoaderComponent, testCase)
control.Material.primary = Material.Yellow
control.Material.accent = Material.Lime
control.Material.background = Material.LightGreen
@@ -359,26 +349,24 @@ TestCase {
compare(control.item.Material.accent, Material.color(Material.Brown))
compare(control.item.Material.background, Material.color(Material.Red))
compare(control.item.Material.foreground, Material.color(Material.Pink))
- control.destroy()
}
function test_swipeView() {
- var control = swipeView.createObject(testCase)
+ let control = createTemporaryObject(swipeViewComponent, testCase)
verify(control)
- var child = control.itemAt(0)
+ let child = control.itemAt(0)
verify(child)
compare(control.Material.theme, Material.Dark)
compare(child.Material.theme, Material.Dark)
- control.destroy()
}
function test_menu() {
- var container = menu.createObject(testCase)
+ let container = createTemporaryObject(menuComponent, testCase)
verify(container)
verify(container.menu)
container.menu.open()
verify(container.menu.visible)
- var child = container.menu.itemAt(0)
+ let child = container.menu.itemAt(0)
verify(child)
compare(container.Material.theme, Material.Light)
compare(container.menu.Material.theme, Material.Dark)
@@ -389,11 +377,10 @@ TestCase {
compare(container.Material.accent, Material.color(Material.Red))
compare(container.menu.Material.accent, Material.color(Material.Red, themeshade(container.menu.Material.theme)))
compare(child.Material.accent, Material.color(Material.Red, themeshade(child.Material.theme)))
- container.destroy()
}
function test_comboBox() {
- var window = comboBox.createObject(testCase)
+ let window = createTemporaryObject(comboBoxComponent, testCase)
verify(window)
verify(window.combo)
waitForRendering(window.combo)
@@ -401,9 +388,9 @@ TestCase {
verify(window.combo.activeFocus)
keyClick(Qt.Key_Space)
verify(window.combo.popup.visible)
- var listView = window.combo.popup.contentItem
+ let listView = window.combo.popup.contentItem
verify(listView)
- var child = listView.contentItem.children[0]
+ let child = listView.contentItem.children[0]
verify(child)
compare(window.Material.theme, Material.Light)
compare(window.combo.Material.theme, Material.Dark)
@@ -414,14 +401,13 @@ TestCase {
compare(window.Material.accent, Material.color(Material.Red))
compare(window.combo.Material.accent, Material.color(Material.Red, themeshade(window.combo.Material.theme)))
compare(child.Material.accent, Material.color(Material.Red, themeshade(child.Material.theme)))
- window.destroy()
}
function test_windowChange() {
- var ldr = loader.createObject()
+ let ldr = buttonLoaderComponent.createObject()
verify(ldr)
- var wnd = window.createObject()
+ let wnd = createTemporaryObject(windowComponent)
verify(wnd)
wnd.Material.theme = Material.Dark
@@ -433,8 +419,6 @@ TestCase {
ldr.parent = wnd.contentItem
compare(ldr.item.Material.theme, Material.Dark)
-
- wnd.destroy()
}
function test_colors_data() {
@@ -444,10 +428,10 @@ TestCase {
}
function test_colors(data) {
- var control = button.createObject(testCase)
+ let control = createTemporaryObject(button, testCase)
verify(control)
- var prop = data.tag
+ let prop = data.tag
// Material.Color - enum
control.Material[prop] = Material.Red
@@ -484,8 +468,6 @@ TestCase {
control.Material[prop] = "foo"
ignoreWarning(new RegExp("QML Button: unknown Material." + prop + " value: #1"))
control.Material[prop] = "#1"
-
- control.destroy()
}
function test_font_data() {
@@ -557,11 +539,11 @@ TestCase {
}
function test_font(data) {
- var window = windowPane.createObject(testCase)
+ let window = createTemporaryObject(windowPaneComponent, testCase)
verify(window)
verify(window.pane)
- var control = Qt.createQmlObject("import QtQuick.Controls; " + data.type + " { }", window.pane)
+ let control = Qt.createQmlObject("import QtQuick.Controls; " + data.type + " { }", window.pane)
verify(control)
compare(control.font[data.attribute], data.value)
@@ -580,14 +562,11 @@ TestCase {
compare(window.font[data.attribute], data.window)
compare(window.pane.font[data.attribute], data.window)
compare(control.font[data.attribute], data.window)
-
- window.destroy()
}
Component {
- id: backgroundControls
+ id: backgroundControlsComponent
ApplicationWindow {
- id: window
property Button button: Button { }
property ComboBox combobox: ComboBox { }
property Drawer drawer: Drawer { }
@@ -621,16 +600,16 @@ TestCase {
}
function test_background(data) {
- var window = backgroundControls.createObject(testCase)
+ let window = createTemporaryObject(backgroundControlsComponent, testCase)
verify(window)
- var control = window[data.tag]
+ let control = window[data.tag]
verify(control)
control.parent = window.contentItem
control.visible = true
- var defaultBackground = control.background.color
+ let defaultBackground = control.background.color
window.Material.background = "#ff0000"
compare(window.color, "#ff0000")
@@ -652,23 +631,19 @@ TestCase {
control.Material.background = "#0000ff"
tryCompare(control.background, "color", "#0000ff")
-
- window.destroy()
}
Component {
- id: busyIndicator
+ id: busyIndicatorComponent
BusyIndicator { }
}
function test_shade() {
- var control = busyIndicator.createObject(testCase)
+ let control = createTemporaryObject(busyIndicatorComponent, testCase)
compare(control.contentItem.color.toString(), Material.color(Material.Pink, Material.Shade500))
control.Material.theme = Material.Dark
compare(control.contentItem.color.toString(), Material.color(Material.Pink, Material.Shade200))
-
- control.destroy()
}
// We can't declare components with JS syntax (when creating a data row),
@@ -738,7 +713,5 @@ TestCase {
function test_propertyBindingLoop(data) {
let item = createTemporaryObject(data.component, testCase)
verify(item)
- verify(!BindingLoopDetector.bindingLoopDetected, "Detected binding loop")
- BindingLoopDetector.reset()
}
}
diff --git a/tests/auto/quickcontrols2/qquickmaterialstyle/tst_qquickmaterialstyle.cpp b/tests/auto/quickcontrols2/qquickmaterialstyle/tst_qquickmaterialstyle.cpp
index 79238cff90..3594f4b1b0 100644
--- a/tests/auto/quickcontrols2/qquickmaterialstyle/tst_qquickmaterialstyle.cpp
+++ b/tests/auto/quickcontrols2/qquickmaterialstyle/tst_qquickmaterialstyle.cpp
@@ -1,42 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-#include <QtQml/qqmlengine.h>
-#include <QtQml/qqmlcontext.h>
#include <QtQuickTest/quicktest.h>
-
-class Setup : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(bool bindingLoopDetected READ wasBindingLoopDetected FINAL)
-
-public:
- Setup() {}
-
- bool wasBindingLoopDetected() const { return mBindingLoopDetected; }
-
-public slots:
- void reset() { mBindingLoopDetected = false; }
-
- void qmlEngineAvailable(QQmlEngine *engine)
- {
- connect(engine, &QQmlEngine::warnings, this, &Setup::qmlWarnings);
-
- qmlRegisterSingletonInstance("org.qtproject.Test", 1, 0, "BindingLoopDetector", this);
- }
-
- void qmlWarnings(const QList<QQmlError> &warnings)
- {
- for (const auto &error : warnings) {
- if (error.messageType() == QtWarningMsg && error.description().contains(QStringLiteral("Binding loop detected")))
- mBindingLoopDetected = true;
- }
- }
-
-private:
- bool mBindingLoopDetected = false;
-};
-
-QUICK_TEST_MAIN_WITH_SETUP(tst_qquickmaterialstyle, Setup)
-
-#include "tst_qquickmaterialstyle.moc"
+QUICK_TEST_MAIN(tst_qquickmaterialstyle)
diff --git a/tests/auto/quickcontrols2/qquickmenu/data/popup.qml b/tests/auto/quickcontrols2/qquickmenu/data/popup.qml
index 46ea45ef17..8201c9e03f 100644
--- a/tests/auto/quickcontrols2/qquickmenu/data/popup.qml
+++ b/tests/auto/quickcontrols2/qquickmenu/data/popup.qml
@@ -5,7 +5,7 @@ import QtQuick
import QtQuick.Controls
ApplicationWindow {
- width: 400
+ width: 500
height: 600
property alias menu: menu
diff --git a/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp b/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp
index fc5ea55b9b..0afb385fa9 100644
--- a/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp
+++ b/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp
@@ -854,16 +854,16 @@ void tst_QQuickMenu::popup()
QCOMPARE(menu->parentItem(), window->contentItem());
QCOMPARE(menu->currentIndex(), -1);
QCOMPARE(menu->contentItem()->property("currentIndex").toInt(), -1);
- QTRY_VERIFY(qFuzzyCompare(menu->x(), 33));
- QTRY_VERIFY(qFuzzyCompare(menu->y(), 44));
+ QTRY_VERIFY(qFuzzyCompare(menu->x(), qMax(qreal(33), menu->leftMargin())));
+ QTRY_VERIFY(qFuzzyCompare(menu->y(), qMax(qreal(44), menu->topMargin())));
menu->close();
QVERIFY(QMetaObject::invokeMethod(window, "popupAtCoord", Q_ARG(QVariant, 55), Q_ARG(QVariant, 66)));
QCOMPARE(menu->parentItem(), window->contentItem());
QCOMPARE(menu->currentIndex(), -1);
QCOMPARE(menu->contentItem()->property("currentIndex").toInt(), -1);
- QTRY_VERIFY(qFuzzyCompare(menu->x(), 55));
- QTRY_VERIFY(qFuzzyCompare(menu->y(), 66));
+ QTRY_VERIFY(qFuzzyCompare(menu->x(), qMax(qreal(55), menu->leftMargin())));
+ QTRY_VERIFY(qFuzzyCompare(menu->y(), qMax(qreal(66), menu->topMargin())));
menu->close();
menu->setParentItem(nullptr);
@@ -1833,10 +1833,10 @@ void tst_QQuickMenu::disableWhenTriggered()
QVERIFY(subMenuItem);
// First, open the sub-menu.
-#ifndef Q_OS_ANDROID
+#if !defined(Q_OS_ANDROID) and !defined(Q_OS_WEBOS)
QTest::mouseMove(window, menuItem->mapToScene(QPoint(1, 1)).toPoint());
#else
- // On Android mouseHover does not open sub-menu, so just click on it
+ // On Android and webOS mouseHover does not open sub-menu, so just click on it
QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
menuItem->mapToScene(QPointF(menuItem->width() / 2, menuItem->height() / 2)).toPoint());
#endif
diff --git a/tests/auto/quickcontrols2/qquickmenubar/tst_qquickmenubar.cpp b/tests/auto/quickcontrols2/qquickmenubar/tst_qquickmenubar.cpp
index 2544aa4d79..f4b3aaf210 100644
--- a/tests/auto/quickcontrols2/qquickmenubar/tst_qquickmenubar.cpp
+++ b/tests/auto/quickcontrols2/qquickmenubar/tst_qquickmenubar.cpp
@@ -568,19 +568,19 @@ void tst_qquickmenubar::mnemonics()
// trigger a menu item to close the menu, which shouldn't trigger a button
// action behind the menu (QTBUG-86276)
- QCOMPARE(oopsButtonSpy.count(), 0);
+ QCOMPARE(oopsButtonSpy.size(), 0);
keySim.click(Qt::Key_O); // "&Open..."
keySim.release(Qt::Key_Alt);
QVERIFY(!fileMenuBarItem->isHighlighted());
QVERIFY(!fileMenuBarMenu->isOpened());
QTRY_VERIFY(!fileMenuBarMenu->isVisible());
- QCOMPARE(oopsButtonSpy.count(), 0);
+ QCOMPARE(oopsButtonSpy.size(), 0);
// trigger a button action while menu is closed
keySim.press(Qt::Key_Alt);
keySim.click(Qt::Key_O); // "&Oops"
keySim.release(Qt::Key_Alt);
- QCOMPARE(oopsButtonSpy.count(), 1);
+ QCOMPARE(oopsButtonSpy.size(), 1);
}
void tst_qquickmenubar::addRemove()
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt b/tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt
index 56edab461d..b0fdebd1aa 100644
--- a/tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt
@@ -7,11 +7,7 @@
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/data/*.qml)
-list(APPEND test_data ${test_data_glob})
-file(GLOB_RECURSE test_data_glob
- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/data/*.png)
+ ${CMAKE_CURRENT_SOURCE_DIR}/data/*)
list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qquickninepatchimage
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/logo.pkm b/tests/auto/quickcontrols2/qquickninepatchimage/data/logo.pkm
new file mode 100644
index 0000000000..c0987c5c36
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/logo.pkm
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/o1_bc1.ktx b/tests/auto/quickcontrols2/qquickninepatchimage/data/o1_bc1.ktx
new file mode 100644
index 0000000000..d61194a745
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/o1_bc1.ktx
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/qt4.astc b/tests/auto/quickcontrols2/qquickninepatchimage/data/qt4.astc
new file mode 100644
index 0000000000..7f7a3f4739
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/qt4.astc
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp b/tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp
index d11e5c8536..dc88d0c5ed 100644
--- a/tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp
@@ -11,8 +11,10 @@
#include <QtQuick/qquickview.h>
#include <QtQuick/qquickitemgrabresult.h>
#include <QtQuick/private/qquickimage_p.h>
+#include <QtQuick/private/qquickimage_p_p.h>
#include <QtQuickTestUtils/private/qmlutils_p.h>
#include <QtQuickTestUtils/private/visualtestutils_p.h>
+#include <QtGui/private/qrhi_p.h>
using namespace QQuickVisualTestUtils;
@@ -32,6 +34,8 @@ private slots:
void inset();
void implicitSize_data();
void implicitSize();
+ void hwCompressedImages_data();
+ void hwCompressedImages();
};
static QImage grabItemToImage(QQuickItem *item)
@@ -152,7 +156,7 @@ void tst_qquickninepatchimage::inset_data()
const QStringList files = QStringList() << "inset-all.9.png" << "inset-topleft.9.png" << "inset-bottomright.9.png";
const QList<QMarginsF> insets = QList<QMarginsF>() << QMarginsF(2, 1, 3, 4) << QMarginsF(2, 1, 0, 0) << QMarginsF(0, 0, 3, 4);
- for (int i = 0; i < files.count(); ++i) {
+ for (int i = 0; i < files.size(); ++i) {
QString file = files.at(i);
for (int dpr = 1; dpr <= 4; ++dpr)
QTest::newRow(qPrintable(QString::fromLatin1("%1 DPR=%2").arg(file).arg(dpr))) << dpr << file << insets.at(i);
@@ -230,6 +234,61 @@ void tst_qquickninepatchimage::implicitSize()
QCOMPARE(ninePatchImage->implicitHeight(), implicitSize.height());
}
+void tst_qquickninepatchimage::hwCompressedImages_data()
+{
+ QTest::addColumn<int>("dpr");
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QRhiTexture::Format>("format");
+
+ const struct TestFile {
+ QString name;
+ QSize size;
+ QRhiTexture::Format format;
+ } testFiles [] = {
+ { "o1_bc1.ktx", QSize(64, 64), QRhiTexture::BC1 },
+ { "logo.pkm", QSize(256, 256), QRhiTexture::ETC2_RGB8 },
+ { "qt4.astc", QSize(250, 200), QRhiTexture::ASTC_8x8 }
+ };
+
+ for (const TestFile &file : testFiles) {
+ for (int dpr = 1; dpr <= 4; ++dpr)
+ QTest::newRow(qPrintable(QString::fromLatin1("%1 DPR=%2").arg(file.name).arg(dpr))) << dpr << file.name << file.size << file.format;
+ }
+}
+
+void tst_qquickninepatchimage::hwCompressedImages()
+{
+ QFETCH(int, dpr);
+ QFETCH(QString, file);
+ QFETCH(QSize, size);
+ QFETCH(QRhiTexture::Format, format);
+
+ QHighDpiScaling::setGlobalFactor(dpr);
+
+ QQuickView view(testFileUrl("ninepatchimage.qml"));
+ QCOMPARE(view.status(), QQuickView::Ready);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ if (!QSGRendererInterface::isApiRhiBased(view.rendererInterface()->graphicsApi()))
+ QSKIP("Skipping due to using software backend");
+
+ QRhi *rhi = static_cast<QRhi *>(view.rendererInterface()->getResource(&view, QSGRendererInterface::RhiResource));
+ if (!rhi->isTextureFormatSupported(format))
+ QSKIP(qPrintable(QString::fromLatin1("%1 not supported, skip").arg(format)));
+
+ QQuickImage *ninePatchImage = qobject_cast<QQuickImage *>(view.rootObject());
+ QVERIFY(ninePatchImage);
+ ninePatchImage->setSource(testFileUrl(file));
+ ninePatchImage->setSize(size);
+ QSignalSpy spy(&view, SIGNAL(afterSynchronizing()));
+ QTRY_VERIFY(spy.size() >= 1);
+
+ QQuickImagePrivate *ninePatchImagePrivate = static_cast<QQuickImagePrivate *>(QQuickItemPrivate::get(ninePatchImage));
+ QVERIFY(ninePatchImagePrivate->paintNode);
+}
+
QTEST_MAIN(tst_qquickninepatchimage)
#include "tst_qquickninepatchimage.moc"
diff --git a/tests/auto/quickcontrols2/qquickpopup/data/applicationwindow-wheel.qml b/tests/auto/quickcontrols2/qquickpopup/data/applicationwindow-wheel.qml
index 073300a36c..1668b042e0 100644
--- a/tests/auto/quickcontrols2/qquickpopup/data/applicationwindow-wheel.qml
+++ b/tests/auto/quickcontrols2/qquickpopup/data/applicationwindow-wheel.qml
@@ -11,6 +11,7 @@ ApplicationWindow {
height: 400
property alias popup: popup
+ property alias nestedPopup: nestedPopup
property alias popupSlider: popupSlider
property alias contentSlider: contentSlider
@@ -30,5 +31,13 @@ ApplicationWindow {
id: popupSlider
wheelEnabled: true
}
+
+ Popup {
+ id: nestedPopup
+ x: 0; y: 0
+ clip: true
+ implicitWidth: 50
+ implicitHeight: 50
+ }
}
}
diff --git a/tests/auto/quickcontrols2/qquickpopup/data/mirroredCombobox.qml b/tests/auto/quickcontrols2/qquickpopup/data/mirroredCombobox.qml
new file mode 100644
index 0000000000..ed48179bce
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickpopup/data/mirroredCombobox.qml
@@ -0,0 +1,26 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Window {
+ width: 400
+ height: 400
+
+ contentItem.rotation: 180
+
+ ComboBox {
+ objectName: "first"
+ x: 100
+ y: 300 // is missing space, needs to unroll in the "mirrored" direction
+ model: ["First", "Second", "Third", "Fourth", "Fifth"]
+ }
+
+ ComboBox {
+ objectName: "second"
+ x: 200
+ y: 100 // has enough space to unroll
+ model: ["A", "B", "C"]
+ }
+}
diff --git a/tests/auto/quickcontrols2/qquickpopup/data/nested-wheel.qml b/tests/auto/quickcontrols2/qquickpopup/data/nested-wheel.qml
new file mode 100644
index 0000000000..a0b319fd24
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickpopup/data/nested-wheel.qml
@@ -0,0 +1,44 @@
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 400
+ height: 400
+
+ property alias modalPopup: popup
+ property alias comboBox: combobox
+
+ Popup {
+ id: popup
+ objectName: "Modal Dialog"
+ width: 300
+ height: 300
+ anchors.centerIn: parent
+ visible: true
+ modal: true
+
+ ComboBox {
+ id: combobox
+ anchors.centerIn: parent
+ width: 120
+ model: 30
+
+ popup: Popup {
+ objectName: "Combobox Popup"
+ y: combobox.height
+ width: combobox.width
+ height: contentItem.implicitHeight
+ contentItem: ListView {
+ objectName: "Combobox ListView"
+ clip: true
+ implicitHeight: 150
+ model: combobox.delegateModel
+ currentIndex: combobox.highlightedIndex
+ ScrollBar.vertical: ScrollBar {
+ objectName: "vbar"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols2/qquickpopup/data/rotatedCombobox.qml b/tests/auto/quickcontrols2/qquickpopup/data/rotatedCombobox.qml
new file mode 100644
index 0000000000..df217be4b7
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickpopup/data/rotatedCombobox.qml
@@ -0,0 +1,26 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Window {
+ width: 400
+ height: 400
+
+ contentItem.rotation: 90
+
+ ComboBox {
+ objectName: "first"
+ x: 100
+ y: 320 // is missing space, needs to unroll in the "mirrored" direction
+ model: ["First", "Second", "Third", "Fourth", "Fifth"]
+ }
+
+ ComboBox {
+ objectName: "second"
+ x: 200
+ y: 100 // has enough space to unroll
+ model: ["A", "B", "C"]
+ }
+}
diff --git a/tests/auto/quickcontrols2/qquickpopup/data/window-wheel.qml b/tests/auto/quickcontrols2/qquickpopup/data/window-wheel.qml
index 315c3f2a78..ae9c2ecdfd 100644
--- a/tests/auto/quickcontrols2/qquickpopup/data/window-wheel.qml
+++ b/tests/auto/quickcontrols2/qquickpopup/data/window-wheel.qml
@@ -11,6 +11,7 @@ Window {
height: 400
property alias popup: popup
+ property alias nestedPopup: nestedPopup
property alias popupSlider: popupSlider
property alias contentSlider: contentSlider
@@ -30,5 +31,13 @@ Window {
id: popupSlider
wheelEnabled: true
}
+
+ Popup {
+ id: nestedPopup
+ x: 0; y: 0
+ clip: true
+ implicitWidth: 50
+ implicitHeight: 50
+ }
}
}
diff --git a/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp
index 5b14c6b867..c6e491618d 100644
--- a/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp
+++ b/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp
@@ -11,6 +11,7 @@
#include <QtQuick/qquickview.h>
#include <QtQuick/private/qquickpalette_p.h>
#include <QtQuickTestUtils/private/qmlutils_p.h>
+#include <QtQuickTestUtils/private/viewtestutils_p.h>
#include <QtQuickTestUtils/private/visualtestutils_p.h>
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
#include <QtQuickTemplates2/private/qquickcombobox_p.h>
@@ -64,6 +65,7 @@ private slots:
void wheel();
void parentDestroyed();
void nested();
+ void nestedWheel();
void modelessOnModalOnModeless();
void grabber();
void cursorShape();
@@ -87,11 +89,16 @@ private slots:
void dimmerContainmentMask();
void shrinkPopupThatWasLargerThanWindow_data();
void shrinkPopupThatWasLargerThanWindow();
+ void mirroredCombobox();
+ void rotatedCombobox();
private:
static bool hasWindowActivation();
+ QScopedPointer<QPointingDevice> touchScreen = QScopedPointer<QPointingDevice>(QTest::createTouchDevice());
};
+using namespace Qt::StringLiterals;
+
tst_QQuickPopup::tst_QQuickPopup()
: QQmlDataTest(QT_QMLTEST_DATADIR)
{
@@ -176,18 +183,18 @@ void tst_QQuickPopup::state()
QVERIFY(closedSpy.isValid());
popup->open();
- QCOMPARE(visibleChangedSpy.count(), 1);
- QCOMPARE(aboutToShowSpy.count(), 1);
- QCOMPARE(aboutToHideSpy.count(), 0);
- QTRY_COMPARE(openedSpy.count(), 1);
- QCOMPARE(closedSpy.count(), 0);
+ QCOMPARE(visibleChangedSpy.size(), 1);
+ QCOMPARE(aboutToShowSpy.size(), 1);
+ QCOMPARE(aboutToHideSpy.size(), 0);
+ QTRY_COMPARE(openedSpy.size(), 1);
+ QCOMPARE(closedSpy.size(), 0);
popup->close();
- QTRY_COMPARE(visibleChangedSpy.count(), 2);
- QCOMPARE(aboutToShowSpy.count(), 1);
- QCOMPARE(aboutToHideSpy.count(), 1);
- QCOMPARE(openedSpy.count(), 1);
- QTRY_COMPARE(closedSpy.count(), 1);
+ QTRY_COMPARE(visibleChangedSpy.size(), 2);
+ QCOMPARE(aboutToShowSpy.size(), 1);
+ QCOMPARE(aboutToHideSpy.size(), 1);
+ QCOMPARE(openedSpy.size(), 1);
+ QTRY_COMPARE(closedSpy.size(), 1);
}
void tst_QQuickPopup::overlay_data()
@@ -213,7 +220,6 @@ void tst_QQuickPopup::overlay()
QFETCH(bool, modal);
QFETCH(bool, dim);
- QScopedPointer<QPointingDevice> device(QTest::createTouchDevice());
QQuickControlsApplicationHelper helper(this, source);
QVERIFY2(helper.ready, helper.failureMessage());
@@ -232,8 +238,8 @@ void tst_QQuickPopup::overlay()
QVERIFY(!overlay->isVisible()); // no popups open
QTest::mouseClick(window, Qt::LeftButton);
- QCOMPARE(overlayPressedSignal.count(), 0);
- QCOMPARE(overlayReleasedSignal.count(), 0);
+ QCOMPARE(overlayPressedSignal.size(), 0);
+ QCOMPARE(overlayReleasedSignal.size(), 0);
QQuickPopup *popup = window->property("popup").value<QQuickPopup*>();
QVERIFY(popup);
@@ -259,19 +265,19 @@ void tst_QQuickPopup::overlay()
QTRY_VERIFY(popup->isOpened());
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
QTRY_VERIFY(!popup->isVisible());
QVERIFY(!overlay->isVisible());
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); // no modal-popups open
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount); // no modal-popups open
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
popup->setDim(dim);
popup->setModal(modal);
@@ -284,16 +290,16 @@ void tst_QQuickPopup::overlay()
QTRY_VERIFY(popup->isOpened());
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount);
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), ++overlayReleaseCount);
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
QTRY_VERIFY(!popup->isVisible());
QVERIFY(!overlay->isVisible());
@@ -304,17 +310,17 @@ void tst_QQuickPopup::overlay()
QVERIFY(overlay->isVisible());
QTRY_VERIFY(popup->isOpened());
- QTest::touchEvent(window, device.data()).press(0, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QTest::touchEvent(window, touchScreen.data()).press(0, QPoint(1, 1));
+ QCOMPARE(overlayPressedSignal.size(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
- QTest::touchEvent(window, device.data()).release(0, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount);
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QTest::touchEvent(window, touchScreen.data()).release(0, QPoint(1, 1));
+ QCOMPARE(overlayPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), ++overlayReleaseCount);
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
QTRY_VERIFY(!popup->isVisible());
QVERIFY(!overlay->isVisible());
@@ -326,33 +332,33 @@ void tst_QQuickPopup::overlay()
QVERIFY(!button->isPressed());
QTRY_VERIFY(popup->isOpened());
- QTest::touchEvent(window, device.data()).press(0, button->mapToScene(QPointF(1, 1)).toPoint());
+ QTest::touchEvent(window, touchScreen.data()).press(0, button->mapToScene(QPointF(1, 1)).toPoint());
QVERIFY(popup->isVisible());
QVERIFY(overlay->isVisible());
QCOMPARE(button->isPressed(), !modal);
- QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
- QTest::touchEvent(window, device.data()).stationary(0).press(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
+ QTest::touchEvent(window, touchScreen.data()).stationary(0).press(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
QVERIFY(popup->isVisible());
QVERIFY(overlay->isVisible());
QCOMPARE(button->isPressed(), !modal);
- QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
- QTest::touchEvent(window, device.data()).release(0, button->mapToScene(QPointF(1, 1)).toPoint()).stationary(1);
+ QTest::touchEvent(window, touchScreen.data()).release(0, button->mapToScene(QPointF(1, 1)).toPoint()).stationary(1);
QTRY_VERIFY(!popup->isVisible());
QVERIFY(!overlay->isVisible());
QVERIFY(!button->isPressed());
- QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), ++overlayReleaseCount);
- QTest::touchEvent(window, device.data()).release(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
+ QTest::touchEvent(window, touchScreen.data()).release(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
QVERIFY(!popup->isVisible());
QVERIFY(!overlay->isVisible());
QVERIFY(!button->isPressed());
- QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
}
void tst_QQuickPopup::zOrder_data()
@@ -405,40 +411,40 @@ void tst_QQuickPopup::windowChange()
QQuickItem item;
popup.setParentItem(&item);
QVERIFY(!popup.window());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QQuickWindow window;
item.setParentItem(window.contentItem());
QCOMPARE(popup.window(), &window);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
item.setParentItem(nullptr);
QVERIFY(!popup.window());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
popup.setParentItem(window.contentItem());
QCOMPARE(popup.window(), &window);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
popup.resetParentItem();
QVERIFY(!popup.window());
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
popup.setParent(&window);
popup.resetParentItem();
QCOMPARE(popup.window(), &window);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
popup.setParent(this);
popup.resetParentItem();
QVERIFY(!popup.window());
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
item.setParentItem(window.contentItem());
popup.setParent(&item);
popup.resetParentItem();
QCOMPARE(popup.window(), &window);
- QCOMPARE(spy.count(), 7);
+ QCOMPARE(spy.size(), 7);
popup.setParent(nullptr);
}
@@ -448,25 +454,44 @@ Q_DECLARE_METATYPE(QQuickPopup::ClosePolicy)
void tst_QQuickPopup::closePolicy_data()
{
qRegisterMetaType<QQuickPopup::ClosePolicy>();
+ const auto *mouse = QPointingDevice::primaryPointingDevice();
+ const auto *touch = touchScreen.data();
QTest::addColumn<QString>("source");
+ QTest::addColumn<const QPointingDevice *>("device");
QTest::addColumn<QQuickPopup::ClosePolicy>("closePolicy");
- QTest::newRow("Window:NoAutoClose") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
- QTest::newRow("Window:CloseOnPressOutside") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
- QTest::newRow("Window:CloseOnPressOutsideParent") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
- QTest::newRow("Window:CloseOnPressOutside|Parent") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
- QTest::newRow("Window:CloseOnReleaseOutside") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
- QTest::newRow("Window:CloseOnReleaseOutside|Parent") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
- QTest::newRow("Window:CloseOnEscape") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
-
- QTest::newRow("ApplicationWindow:NoAutoClose") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
- QTest::newRow("ApplicationWindow:CloseOnPressOutside") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
- QTest::newRow("ApplicationWindow:CloseOnPressOutsideParent") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
- QTest::newRow("ApplicationWindow:CloseOnPressOutside|Parent") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
- QTest::newRow("ApplicationWindow:CloseOnReleaseOutside") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
- QTest::newRow("ApplicationWindow:CloseOnReleaseOutside|Parent") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
- QTest::newRow("ApplicationWindow:CloseOnEscape") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
+ QTest::newRow("Window:NoAutoClose mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
+ QTest::newRow("Window:CloseOnPressOutside mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
+ QTest::newRow("Window:CloseOnPressOutsideParent mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("Window:CloseOnPressOutside|Parent mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("Window:CloseOnReleaseOutside mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
+ QTest::newRow("Window:CloseOnReleaseOutside|Parent mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
+ QTest::newRow("Window:CloseOnEscape mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
+
+ QTest::newRow("ApplicationWindow:NoAutoClose mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutside mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutsideParent mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutside|Parent mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnReleaseOutside mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
+ QTest::newRow("ApplicationWindow:CloseOnReleaseOutside|Parent mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnEscape mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
+
+ QTest::newRow("Window:NoAutoClose touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
+ QTest::newRow("Window:CloseOnPressOutside touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
+ QTest::newRow("Window:CloseOnPressOutsideParent touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("Window:CloseOnPressOutside|Parent touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("Window:CloseOnReleaseOutside touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
+ QTest::newRow("Window:CloseOnReleaseOutside|Parent touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
+ QTest::newRow("Window:CloseOnEscape touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
+
+ QTest::newRow("ApplicationWindow:NoAutoClose touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutside touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutsideParent touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutside|Parent touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnReleaseOutside touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
+ QTest::newRow("ApplicationWindow:CloseOnReleaseOutside|Parent touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnEscape touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
}
void tst_QQuickPopup::closePolicy()
@@ -475,6 +500,7 @@ void tst_QQuickPopup::closePolicy()
QSKIP("Window activation is not supported");
QFETCH(QString, source);
+ QFETCH(const QPointingDevice *, device);
QFETCH(QQuickPopup::ClosePolicy, closePolicy);
QQuickControlsApplicationHelper helper(this, source);
@@ -502,56 +528,58 @@ void tst_QQuickPopup::closePolicy()
// wait for dimmer
QTest::qWait(50);
- // press outside popup and its parent
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) || closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent))
- QTRY_VERIFY(!popup->isVisible());
- else
- QVERIFY(popup->isOpened());
+ for (int i = 0; i < 2; ++i) {
+ // press outside popup and its parent
+ QQuickTest::pointerPress(device, window, 0, {1, 1});
+ if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) || closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent))
+ QTRY_VERIFY(!popup->isVisible());
+ else
+ QVERIFY(popup->isOpened());
- popup->open();
- QVERIFY(popup->isVisible());
- QTRY_VERIFY(popup->isOpened());
+ popup->open();
+ QVERIFY(popup->isVisible());
+ QTRY_VERIFY(popup->isOpened());
- // release outside popup and its parent
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) || closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent))
- QTRY_VERIFY(!popup->isVisible());
- else
- QVERIFY(popup->isOpened());
+ // release outside popup and its parent
+ QQuickTest::pointerRelease(device, window, 0, {1, 1});
+ if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) || closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent))
+ QTRY_VERIFY(!popup->isVisible());
+ else
+ QVERIFY(popup->isOpened());
- popup->open();
- QVERIFY(popup->isVisible());
- QTRY_VERIFY(popup->isOpened());
+ popup->open();
+ QVERIFY(popup->isVisible());
+ QTRY_VERIFY(popup->isOpened());
- // press outside popup but inside its parent
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + 1, button->y() + 1));
- if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent))
- QTRY_VERIFY(!popup->isVisible());
- else
- QVERIFY(popup->isOpened());
+ // press outside popup but inside its parent
+ QQuickTest::pointerPress(device, window, 0, QPoint(button->x() + 1, button->y() + 1));
+ if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent))
+ QTRY_VERIFY(!popup->isVisible());
+ else
+ QVERIFY(popup->isOpened());
- popup->open();
- QVERIFY(popup->isVisible());
- QTRY_VERIFY(popup->isOpened());
+ popup->open();
+ QVERIFY(popup->isVisible());
+ QTRY_VERIFY(popup->isOpened());
- // release outside popup but inside its parent
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + 1, button->y() + 1));
- if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent))
- QTRY_VERIFY(!popup->isVisible());
- else
- QVERIFY(popup->isOpened());
+ // release outside popup but inside its parent
+ QQuickTest::pointerRelease(device, window, 0, QPoint(button->x() + 1, button->y() + 1));
+ if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent))
+ QTRY_VERIFY(!popup->isVisible());
+ else
+ QVERIFY(popup->isOpened());
- popup->open();
- QVERIFY(popup->isVisible());
- QTRY_VERIFY(popup->isOpened());
+ popup->open();
+ QVERIFY(popup->isVisible());
+ QTRY_VERIFY(popup->isOpened());
- // press inside and release outside
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + popup->x() + 1,
- button->y() + popup->y() + 1));
- QVERIFY(popup->isOpened());
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- QVERIFY(popup->isOpened());
+ // press inside and release outside
+ QQuickTest::pointerPress(device, window, 0, QPoint(button->x() + popup->x() + 1,
+ button->y() + popup->y() + 1));
+ QVERIFY(popup->isOpened());
+ QQuickTest::pointerRelease(device, window, 0, {1, 1});
+ QVERIFY(popup->isOpened());
+ }
// escape
QTest::keyClick(window, Qt::Key_Escape);
@@ -945,7 +973,7 @@ void tst_QQuickPopup::hover()
QSignalSpy openedSpy(popup, SIGNAL(opened()));
QVERIFY(openedSpy.isValid());
popup->open();
- QVERIFY(openedSpy.count() == 1 || openedSpy.wait());
+ QVERIFY(openedSpy.size() == 1 || openedSpy.wait());
QTRY_VERIFY(popup->width() > 10); // somehow this can take a short time with macOS style
// hover the parent button outside the popup
@@ -966,7 +994,7 @@ void tst_QQuickPopup::hover()
QSignalSpy closedSpy(popup, SIGNAL(closed()));
QVERIFY(closedSpy.isValid());
popup->close();
- QVERIFY(closedSpy.count() == 1 || closedSpy.wait());
+ QVERIFY(closedSpy.size() == 1 || closedSpy.wait());
// hover the parent button after closing the popup
QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2));
@@ -984,16 +1012,23 @@ void tst_QQuickPopup::wheel_data()
QTest::newRow("ApplicationWindow:modeless") << "applicationwindow-wheel.qml" << false;
}
-static bool sendWheelEvent(QQuickItem *item, const QPoint &localPos, int degrees)
+static bool sendWheelEvent(QQuickItem *item, const QPointF &localPos, int degrees)
{
QQuickWindow *window = item->window();
- QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0),
+ const QPoint scenePos = item->mapToScene(localPos).toPoint();
+ QWheelEvent wheelEvent(scenePos, window->mapToGlobal(scenePos), QPoint(0, 0),
QPoint(0, 8 * degrees), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase,
false);
QSpontaneKeyEvent::setSpontaneous(&wheelEvent);
return qGuiApp->notify(window, &wheelEvent);
}
+static bool sendWheelEvent(QQuickItem *item, int degrees)
+{
+ const QPointF localPos = QPointF(item->width() / 2, item->height() / 2);
+ return sendWheelEvent(item, localPos, degrees);
+}
+
void tst_QQuickPopup::wheel()
{
QFETCH(QString, source);
@@ -1012,6 +1047,10 @@ void tst_QQuickPopup::wheel()
QVERIFY(popup && popup->contentItem());
popup->setModal(modal);
+ QQuickPopup *nestedPopup = window->property("nestedPopup").value<QQuickPopup*>();
+ QVERIFY(nestedPopup && nestedPopup->contentItem());
+ nestedPopup->setModal(modal);
+
QQuickSlider *popupSlider = window->property("popupSlider").value<QQuickSlider*>();
QVERIFY(popupSlider);
@@ -1020,7 +1059,7 @@ void tst_QQuickPopup::wheel()
qreal oldContentValue = contentSlider->value();
qreal oldPopupValue = popupSlider->value();
- QVERIFY(sendWheelEvent(contentSlider, QPoint(contentSlider->width() / 2, contentSlider->height() / 2), 15));
+ QVERIFY(sendWheelEvent(contentSlider, 15));
QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); // must have moved
QVERIFY(qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must not have moved
@@ -1029,25 +1068,41 @@ void tst_QQuickPopup::wheel()
QSignalSpy openedSpy(popup, SIGNAL(opened()));
QVERIFY(openedSpy.isValid());
popup->open();
- QVERIFY(openedSpy.count() == 1 || openedSpy.wait());
+ QVERIFY(openedSpy.size() == 1 || openedSpy.wait());
{
// wheel over the popup content
qreal oldContentValue = contentSlider->value();
qreal oldPopupValue = popupSlider->value();
- QVERIFY(sendWheelEvent(popupSlider, QPoint(popupSlider->width() / 2, popupSlider->height() / 2), 15));
+ QVERIFY(sendWheelEvent(popupSlider, 15));
QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); // must not have moved
QVERIFY(!qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must have moved
}
+ QSignalSpy nestedOpenedSpy(nestedPopup, SIGNAL(opened()));
+ QVERIFY(nestedOpenedSpy.isValid());
+ nestedPopup->open();
+ QVERIFY(nestedOpenedSpy.size() == 1 || nestedOpenedSpy.wait());
+
+ {
+ // wheel over the popup content
+ qreal oldContentValue = contentSlider->value();
+ qreal oldPopupValue = popupSlider->value();
+
+ QVERIFY(sendWheelEvent(popupSlider, 15));
+
+ QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); // must not have moved
+ QCOMPARE(qFuzzyCompare(popupSlider->value(), oldPopupValue), modal); // must not have moved unless modeless
+ }
+
{
// wheel over the overlay
qreal oldContentValue = contentSlider->value();
qreal oldPopupValue = popupSlider->value();
- QVERIFY(sendWheelEvent(QQuickOverlay::overlay(window), QPoint(0, 0), 15));
+ QVERIFY(sendWheelEvent(QQuickOverlay::overlay(window), QPointF(0, 0), 15));
if (modal) {
// the content below a modal overlay must not move
@@ -1097,6 +1152,36 @@ void tst_QQuickPopup::nested()
QCOMPARE(modalPopup->isVisible(), true);
}
+void tst_QQuickPopup::nestedWheel()
+{
+ QQuickControlsApplicationHelper helper(this, QStringLiteral("nested-wheel.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
+ QVERIFY(modalPopup);
+
+ QQuickComboBox *comboBox = window->property("comboBox").value<QQuickComboBox *>();
+ QVERIFY(comboBox);
+
+ const QPoint comboBoxCenter = comboBox->mapToScene(
+ QPointF(comboBox->width() / 2, comboBox->height() / 2)).toPoint();
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, comboBoxCenter);
+ QTRY_VERIFY(comboBox->popup()->isOpened());
+
+ QQuickItem *listView = comboBox->popup()->contentItem();
+ QVERIFY(listView);
+ QQuickItem *vbar = listView->findChild<QQuickItem *>("vbar");
+ QVERIFY(vbar);
+
+ const double startPosition = vbar->property("position").toDouble();
+ // wheel over the list view, verify that it scrolls
+ sendWheelEvent(listView, -30);
+ QTRY_COMPARE_GT(vbar->property("position").toDouble(), startPosition);
+}
+
void tst_QQuickPopup::modelessOnModalOnModeless()
{
QQuickControlsApplicationHelper helper(this, QStringLiteral("modelessOnModalOnModeless.qml"));
@@ -1353,12 +1438,12 @@ void tst_QQuickPopup::enabled()
popup.setEnabled(false);
QVERIFY(!popup.isEnabled());
QVERIFY(!popup.popupItem()->isEnabled());
- QCOMPARE(enabledSpy.count(), 1);
+ QCOMPARE(enabledSpy.size(), 1);
popup.popupItem()->setEnabled(true);
QVERIFY(popup.isEnabled());
QVERIFY(popup.popupItem()->isEnabled());
- QCOMPARE(enabledSpy.count(), 2);
+ QCOMPARE(enabledSpy.size(), 2);
}
void tst_QQuickPopup::orientation_data()
@@ -1477,15 +1562,15 @@ void tst_QQuickPopup::disabledPalette()
auto palette = QQuickPopupPrivate::get(popup)->palette();
palette->setBase(Qt::green);
palette->disabled()->setBase(Qt::red);
- QCOMPARE(popupPaletteSpy.count(), 2);
- QCOMPARE(popupItemPaletteSpy.count(), 2);
+ QCOMPARE(popupPaletteSpy.size(), 2);
+ QCOMPARE(popupItemPaletteSpy.size(), 2);
QCOMPARE(popup->background()->property("color").value<QColor>(), Qt::green);
popup->setEnabled(false);
- QCOMPARE(popupEnabledSpy.count(), 1);
- QCOMPARE(popupItemEnabledSpy.count(), 1);
- QCOMPARE(popupPaletteSpy.count(), 3);
- QCOMPARE(popupItemPaletteSpy.count(), 3);
+ QCOMPARE(popupEnabledSpy.size(), 1);
+ QCOMPARE(popupItemEnabledSpy.size(), 1);
+ QCOMPARE(popupPaletteSpy.size(), 3);
+ QCOMPARE(popupItemPaletteSpy.size(), 3);
QCOMPARE(popup->background()->property("color").value<QColor>(), Qt::red);
}
@@ -1517,8 +1602,8 @@ void tst_QQuickPopup::disabledParentPalette()
auto palette = QQuickPopupPrivate::get(popup)->palette();
palette->setBase(Qt::green);
palette->disabled()->setBase(Qt::red);
- QCOMPARE(popupPaletteSpy.count(), 2);
- QCOMPARE(popupItemPaletteSpy.count(), 2);
+ QCOMPARE(popupPaletteSpy.size(), 2);
+ QCOMPARE(popupItemPaletteSpy.size(), 2);
QCOMPARE(popup->background()->property("color").value<QColor>(), Qt::green);
// Disable the overlay (which is QQuickPopupItem's parent) to ensure that
@@ -1529,10 +1614,10 @@ void tst_QQuickPopup::disabledParentPalette()
QVERIFY(!popup->isEnabled());
QVERIFY(!popup->popupItem()->isEnabled());
QCOMPARE(popup->background()->property("color").value<QColor>(), Qt::red);
- QCOMPARE(popupEnabledSpy.count(), 1);
- QCOMPARE(popupItemEnabledSpy.count(), 1);
- QCOMPARE(popupPaletteSpy.count(), 3);
- QCOMPARE(popupItemPaletteSpy.count(), 3);
+ QCOMPARE(popupEnabledSpy.size(), 1);
+ QCOMPARE(popupItemEnabledSpy.size(), 1);
+ QCOMPARE(popupPaletteSpy.size(), 3);
+ QCOMPARE(popupItemPaletteSpy.size(), 3);
popup->close();
QTRY_VERIFY(!popup->isVisible());
@@ -1690,7 +1775,7 @@ void tst_QQuickPopup::invisibleToolTipOpen()
QVERIFY(componentLoadedSpy.isValid());
loader->setProperty("active", true);
- QTRY_COMPARE(componentLoadedSpy.count(), 1);
+ QTRY_COMPARE(componentLoadedSpy.size(), 1);
QTRY_VERIFY(toolTip->isVisible());
}
@@ -1884,6 +1969,155 @@ void tst_QQuickPopup::shrinkPopupThatWasLargerThanWindow()
.arg(popup->height()).arg(window->height())));
}
+void tst_QQuickPopup::mirroredCombobox()
+{
+#ifdef Q_OS_ANDROID
+ // Android screens might be pretty small, such that additional
+ // repositioning (apart from the mirroring) will happen to the
+ // popups and mess up the expected positions below.
+ QSKIP("Skipping test for Android.");
+#endif
+ QStringList nativeStyles;
+ nativeStyles.append(u"macOS"_s);
+ nativeStyles.append(u"iOS"_s);
+ nativeStyles.append(u"Windows"_s);
+ if (nativeStyles.contains(QQuickStyle::name()))
+ QSKIP("Skipping test for native styles: they might rearrange their combobox the way they "
+ "want.");
+
+ QQuickControlsApplicationHelper helper(this, "mirroredCombobox.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
+
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ {
+ QQuickComboBox *comboBox = window->findChild<QQuickComboBox *>("first");
+ QVERIFY(comboBox);
+ QQuickPopup *popup = comboBox->popup();
+ QVERIFY(popup);
+ popup->open();
+ QTRY_COMPARE(popup->isVisible(), true);
+ const QPointF popupPos(popup->contentItem()->mapToItem(comboBox->parentItem(),
+ popup->contentItem()->position()));
+ const QSizeF popupSize(popup->contentItem()->size());
+
+ // ignore popup.{top,bottom}Padding() as not included in popup->contentItem()->size()
+ // some styles prefer to draw the popup "over" (in z-axis direction) the combobox to hide
+ // the combobox
+ const bool styleDrawsPopupOverCombobox =
+ comboBox->position().y() - popupSize.height() + comboBox->size().height()
+ == popupPos.y();
+ // some styles prefer to draw the popup below (in y-axis direction) the combobox
+ const bool styleDrawsPopupBelowCombobox =
+ comboBox->position().y() - popupSize.height() + comboBox->topPadding()
+ == popupPos.y();
+
+ QVERIFY(styleDrawsPopupOverCombobox || styleDrawsPopupBelowCombobox);
+
+ popup->close();
+ }
+
+ {
+ QQuickComboBox *comboBox = window->findChild<QQuickComboBox *>("second");
+ QVERIFY(comboBox);
+ QQuickPopup *popup = comboBox->popup();
+ QVERIFY(popup);
+ popup->open();
+ QTRY_COMPARE(popup->isVisible(), true);
+ const QPointF popupPos(popup->contentItem()->mapToItem(comboBox->parentItem(),
+ popup->contentItem()->position()));
+
+ // some styles prefer to draw the popup "over" (in z-axis direction) the combobox to hide
+ // the combobox
+ const bool styleDrawsPopupOverCombobox = comboBox->position().y() + comboBox->topPadding()
+ + popup->topPadding() + popup->bottomPadding()
+ == popupPos.y();
+ // some styles prefer to draw the popup above (in y-axis direction) the combobox
+ const bool styleDrawsPopupAboveCombobox =
+ comboBox->position().y() + comboBox->height() - comboBox->topPadding()
+ == popupPos.y();
+
+ QVERIFY(styleDrawsPopupOverCombobox || styleDrawsPopupAboveCombobox);
+
+ popup->close();
+ }
+}
+
+void tst_QQuickPopup::rotatedCombobox()
+{
+#ifdef Q_OS_ANDROID
+ // Android screens might be pretty small, such that additional
+ // repositioning (apart from the rotating) will happen to the
+ // popups and mess up the expected positions below.
+ QSKIP("Skipping test for Android.");
+#endif
+ QStringList nativeStyles;
+ nativeStyles.append(u"macOS"_s);
+ nativeStyles.append(u"iOS"_s);
+ nativeStyles.append(u"Windows"_s);
+ if (nativeStyles.contains(QQuickStyle::name()))
+ QSKIP("Skipping test for native styles: they might rearrange their combobox the way they "
+ "want.");
+
+ QQuickControlsApplicationHelper helper(this, "rotatedCombobox.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
+
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ {
+ QQuickComboBox *comboBox = window->findChild<QQuickComboBox *>("first");
+ QVERIFY(comboBox);
+ QQuickPopup *popup = comboBox->popup();
+ QVERIFY(popup);
+ popup->open();
+ QTRY_COMPARE(popup->isVisible(), true);
+ const QPointF popupPos(popup->contentItem()->mapToItem(comboBox->parentItem(),
+ popup->contentItem()->position()));
+ const QSizeF popupSize(popup->contentItem()->size());
+
+ // ignore popup.{left,right}Padding() as not included in popup->contentItem()->size()
+ // some styles prefer to draw the popup "over" (in z-axis direction) the combobox to hide
+ // the combobox
+ const bool styleDrawsPopupOverCombobox =
+ comboBox->position().x() - popupSize.width() + comboBox->width() == popupPos.x();
+ // some styles prefer to draw the popup right (in x-axis direction) of the combobox
+ const bool styleDrawsPopupBelowCombobox =
+ comboBox->position().x() - popupSize.width() - comboBox->leftPadding()
+ == popupPos.x();
+
+ QVERIFY(styleDrawsPopupOverCombobox || styleDrawsPopupBelowCombobox);
+ }
+
+ {
+ QQuickComboBox *comboBox = window->findChild<QQuickComboBox *>("second");
+ QVERIFY(comboBox);
+ QQuickPopup *popup = comboBox->popup();
+ QVERIFY(popup);
+ popup->open();
+ QTRY_COMPARE(popup->isVisible(), true);
+ const QPointF popupPos(popup->contentItem()->mapToItem(comboBox->parentItem(),
+ popup->contentItem()->position()));
+
+ // some styles prefer to draw the popup "over" (in z-axis direction) the combobox to hide
+ // the combobox
+ const bool styleDrawsPopupOverCombobox = comboBox->position().x() + comboBox->leftPadding()
+ + popup->leftPadding() + popup->rightPadding()
+ == popupPos.x();
+ // some styles prefer to draw the popup left (in y-axis direction) of the combobox
+ const bool styleDrawsPopupAboveCombobox =
+ comboBox->position().x() + comboBox->width() - comboBox->leftPadding()
+ == popupPos.x();
+
+ QVERIFY(styleDrawsPopupOverCombobox || styleDrawsPopupAboveCombobox);
+
+ popup->close();
+ }
+}
+
QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
#include "tst_qquickpopup.moc"
diff --git a/tests/auto/quickcontrols2/qquicktextarea/CMakeLists.txt b/tests/auto/quickcontrols2/qquicktextarea/CMakeLists.txt
new file mode 100644
index 0000000000..553a1588ae
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktextarea/CMakeLists.txt
@@ -0,0 +1,46 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#####################################################################
+## tst_qquicktextarea Test:
+#####################################################################
+
+# Collect test data
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ data/*)
+list(APPEND test_data ${test_data_glob})
+
+qt_internal_add_test(tst_qquicktextarea
+ SOURCES
+ tst_qquicktextarea.cpp
+ DEFINES
+ QQC2_IMPORT_PATH=\\\"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/quickcontrols2\\\"
+ PUBLIC_LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ Qt::QmlPrivate
+ Qt::QuickControls2
+ Qt::QuickControls2Private
+ Qt::QuickControlsTestUtilsPrivate
+ Qt::QuickPrivate
+ Qt::QuickTemplates2Private
+ Qt::QuickTest
+ Qt::QuickTestUtilsPrivate
+ Qt::TestPrivate
+ TESTDATA ${test_data}
+)
+
+## Scopes:
+#####################################################################
+
+qt_internal_extend_target(tst_qquicktextarea CONDITION ANDROID OR IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\":/data\\\"
+)
+
+qt_internal_extend_target(tst_qquicktextarea CONDITION NOT ANDROID AND NOT IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\"
+)
diff --git a/tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_default.qml b/tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_default.qml
new file mode 100644
index 0000000000..cb51b80545
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_default.qml
@@ -0,0 +1,6 @@
+import QtQuick.Controls
+
+TextArea {
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
+
diff --git a/tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_old_default.qml b/tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_old_default.qml
new file mode 100644
index 0000000000..1401be36c1
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_old_default.qml
@@ -0,0 +1,6 @@
+import QtQuick
+import QtQuick.Controls 6.3
+
+TextArea {
+ text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
diff --git a/tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_old_overridden.qml b/tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_old_overridden.qml
new file mode 100644
index 0000000000..c0e6fb60a8
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktextarea/data/mouseselection_old_overridden.qml
@@ -0,0 +1,7 @@
+import QtQuick
+import QtQuick.Controls 6.3
+
+TextArea {
+ selectByMouse: true
+ text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
diff --git a/tests/auto/quickcontrols2/qquicktextarea/data/twoInAColumn.qml b/tests/auto/quickcontrols2/qquicktextarea/data/twoInAColumn.qml
new file mode 100644
index 0000000000..944f5598ac
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktextarea/data/twoInAColumn.qml
@@ -0,0 +1,35 @@
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+ColumnLayout {
+ height: 200
+ width: 400
+ spacing: -6
+ Rectangle {
+ border.color: top.activeFocus ? "steelblue" : "lightgrey"
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ Layout.margins: 6
+ TextArea {
+ id: top
+ objectName: "top"
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ anchors.fill: parent
+ verticalAlignment: TextArea.AlignTop
+ }
+ }
+ Rectangle {
+ border.color: bottom.activeFocus ? "steelblue" : "lightgrey"
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ Layout.margins: 6
+ TextArea {
+ id: bottom
+ objectName: "bottom"
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ anchors.fill: parent
+ verticalAlignment: TextArea.AlignTop
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols2/qquicktextarea/tst_qquicktextarea.cpp b/tests/auto/quickcontrols2/qquicktextarea/tst_qquicktextarea.cpp
new file mode 100644
index 0000000000..1c40b078f7
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktextarea/tst_qquicktextarea.cpp
@@ -0,0 +1,166 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include <QtTest/qtest.h>
+#include <QtTest/qsignalspy.h>
+#include <QtTest/qtesttouch.h>
+
+#include <QtGui/qfontmetrics.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformintegration.h>
+#include <QtGui/qtestsupport_gui.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuickTestUtils/private/qmlutils_p.h>
+#include <QtQuickTestUtils/private/viewtestutils_p.h>
+#include <QtQuickTemplates2/private/qquicktextarea_p.h>
+#include <QtQuickControlsTestUtils/private/qtest_quickcontrols_p.h>
+
+class tst_QQuickTextArea : public QQmlDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_QQuickTextArea();
+
+private slots:
+ void initTestCase() override;
+ void touchscreenDoesNotSelect_data();
+ void touchscreenDoesNotSelect();
+ void touchscreenSetsFocusAndMovesCursor();
+
+private:
+ static bool hasWindowActivation();
+ QScopedPointer<QPointingDevice> touchDevice = QScopedPointer<QPointingDevice>(QTest::createTouchDevice());
+};
+
+tst_QQuickTextArea::tst_QQuickTextArea()
+ : QQmlDataTest(QT_QMLTEST_DATADIR)
+{
+}
+
+void tst_QQuickTextArea::initTestCase()
+{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() > 23)
+ QSKIP("Crashes on Android 7+, figure out why (QTBUG-107028)");
+#endif
+ QQmlDataTest::initTestCase();
+ qputenv("QML_NO_TOUCH_COMPRESSION", "1");
+}
+
+void tst_QQuickTextArea::touchscreenDoesNotSelect_data()
+{
+ QTest::addColumn<QUrl>("src");
+ QTest::addColumn<bool>("setEnv");
+ QTest::addColumn<bool>("selectByMouse");
+ QTest::addColumn<bool>("selectByTouch");
+ QTest::newRow("new default") << testFileUrl("mouseselection_default.qml") << false << true << false;
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ QTest::newRow("putenv") << testFileUrl("mouseselection_default.qml") << true << false << false;
+ QTest::newRow("old_import") << testFileUrl("mouseselection_old_default.qml") << false << true << false;
+ QTest::newRow("old+putenv") << testFileUrl("mouseselection_old_default.qml") << true << false << false;
+ QTest::newRow("old+putenv+selectByMouse") << testFileUrl("mouseselection_old_overridden.qml") << true << true << true;
+#endif
+}
+
+void tst_QQuickTextArea::touchscreenDoesNotSelect()
+{
+ QFETCH(QUrl, src);
+ QFETCH(bool, setEnv);
+ QFETCH(bool, selectByMouse);
+ QFETCH(bool, selectByTouch);
+
+ if (setEnv)
+ qputenv("QT_QUICK_CONTROLS_TEXT_SELECTION_BEHAVIOR", "old");
+ else
+ qunsetenv("QT_QUICK_CONTROLS_TEXT_SELECTION_BEHAVIOR");
+
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, src));
+
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(window.rootObject());
+ QVERIFY(textEditObject != nullptr);
+ QCOMPARE(textEditObject->selectByMouse(), selectByMouse);
+ textEditObject->setSelectByMouse(true); // enable selection with pre-6.4 import version
+ QVERIFY(textEditObject->selectedText().isEmpty());
+
+ if (selectByMouse) {
+ // press-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = QFontMetrics(textEditObject->font()).height() / 2;
+ QTest::touchEvent(&window, touchDevice.data()).press(0, QPoint(x1,y), &window);
+ QTest::touchEvent(&window, touchDevice.data()).move(0, QPoint(x2,y), &window);
+ QTest::touchEvent(&window, touchDevice.data()).release(0, QPoint(x2,y), &window);
+ QQuickTouchUtils::flush(&window);
+ // if the import version is old enough, fall back to old behavior: touch swipe _does_ select text if selectByMouse is true
+ QCOMPARE(textEditObject->selectedText().isEmpty(), !selectByTouch);
+ }
+}
+
+void tst_QQuickTextArea::touchscreenSetsFocusAndMovesCursor()
+{
+ if (!hasWindowActivation())
+ QSKIP("Window activation is not supported");
+ qunsetenv("QT_QUICK_CONTROLS_TEXT_SELECTION_BEHAVIOR");
+
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, testFileUrl("twoInAColumn.qml")));
+ window.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+
+ QQuickTextEdit *top = window.rootObject()->findChild<QQuickTextEdit*>("top");
+ QVERIFY(top);
+ QQuickTextEdit *bottom = window.rootObject()->findChild<QQuickTextEdit*>("bottom");
+ QVERIFY(bottom);
+ const auto len = bottom->text().size();
+
+ // tap the bottom field
+ const qreal yOffset = bottom->topPadding() + 6; // where to tap or drag to hit the text
+ QPoint p1 = bottom->mapToScene({60, yOffset}).toPoint();
+ QTest::touchEvent(&window, touchDevice.data()).press(0, p1, &window);
+ QQuickTouchUtils::flush(&window);
+ // text cursor is at 0 by default, on press
+ QCOMPARE(bottom->cursorPosition(), 0);
+ // the focus changes and the cursor moves after release (not after press, as in TextEdit)
+ QTest::touchEvent(&window, touchDevice.data()).release(0, p1, &window);
+ QQuickTouchUtils::flush(&window);
+ QCOMPARE(qApp->focusObject(), bottom);
+ QTRY_COMPARE_GT(bottom->cursorPosition(), 0);
+
+ // typing a character inserts it at the cursor position
+ QVERIFY(!bottom->text().contains('q'));
+ QTest::keyClick(&window, Qt::Key_Q);
+ QCOMPARE(bottom->text().size(), len + 1);
+ QCOMPARE_GT(bottom->text().indexOf('q'), 0);
+
+ // press-drag-and-release from p1 to p2 on the top field
+ p1 = top->mapToScene({0, yOffset}).toPoint();
+ QPoint p2 = top->mapToScene({76, yOffset}).toPoint();
+ QTest::touchEvent(&window, touchDevice.data()).press(0, p1, &window);
+ QQuickTouchUtils::flush(&window);
+ QTest::touchEvent(&window, touchDevice.data()).move(0, p2, &window);
+ QQuickTouchUtils::flush(&window);
+ QTest::touchEvent(&window, touchDevice.data()).release(0, p2, &window);
+ QQuickTouchUtils::flush(&window);
+ QCOMPARE(qApp->focusObject(), top);
+ QVERIFY(top->selectedText().isEmpty());
+ QCOMPARE_GT(top->cursorPosition(), 0);
+
+ // touch-drag did not select text, but mouse-drag from p2 back to p1
+ // does select the first part of the text, and leave the cursor at the beginning
+ QTest::mousePress(&window, Qt::LeftButton, {}, p2);
+ QTest::mouseMove(&window, p1);
+ QTest::mouseRelease(&window, Qt::LeftButton, {}, p1);
+ QCOMPARE(top->cursorPosition(), 0);
+ QCOMPARE_GT(top->selectedText().size(), 0);
+}
+
+bool tst_QQuickTextArea::hasWindowActivation()
+{
+ return (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation));
+}
+
+QTEST_QUICKCONTROLS_MAIN(tst_QQuickTextArea)
+
+#include "tst_qquicktextarea.moc"
diff --git a/tests/auto/quickcontrols2/qquicktextfield/CMakeLists.txt b/tests/auto/quickcontrols2/qquicktextfield/CMakeLists.txt
new file mode 100644
index 0000000000..953e75d9d8
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktextfield/CMakeLists.txt
@@ -0,0 +1,46 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#####################################################################
+## tst_qquicktextfield Test:
+#####################################################################
+
+# Collect test data
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ data/*)
+list(APPEND test_data ${test_data_glob})
+
+qt_internal_add_test(tst_qquicktextfield
+ SOURCES
+ tst_qquicktextfield.cpp
+ DEFINES
+ QQC2_IMPORT_PATH=\\\"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/quickcontrols2\\\"
+ PUBLIC_LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ Qt::QmlPrivate
+ Qt::QuickControls2
+ Qt::QuickControls2Private
+ Qt::QuickControlsTestUtilsPrivate
+ Qt::QuickPrivate
+ Qt::QuickTemplates2Private
+ Qt::QuickTest
+ Qt::QuickTestUtilsPrivate
+ Qt::TestPrivate
+ TESTDATA ${test_data}
+)
+
+## Scopes:
+#####################################################################
+
+qt_internal_extend_target(tst_qquicktextfield CONDITION ANDROID OR IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\":/data\\\"
+)
+
+qt_internal_extend_target(tst_qquicktextfield CONDITION NOT ANDROID AND NOT IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\"
+)
diff --git a/tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_default.qml b/tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_default.qml
new file mode 100644
index 0000000000..2bcaf2abd4
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_default.qml
@@ -0,0 +1,7 @@
+import QtQuick.Controls
+
+TextField {
+ width: 400
+ text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
+
diff --git a/tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_old_default.qml b/tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_old_default.qml
new file mode 100644
index 0000000000..0eb774a322
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_old_default.qml
@@ -0,0 +1,7 @@
+import QtQuick
+import QtQuick.Controls 6.3
+
+TextField {
+ width: 400
+ text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
diff --git a/tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_old_overridden.qml b/tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_old_overridden.qml
new file mode 100644
index 0000000000..0e357e032f
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktextfield/data/mouseselection_old_overridden.qml
@@ -0,0 +1,8 @@
+import QtQuick
+import QtQuick.Controls 6.3
+
+TextField {
+ width: 400
+ selectByMouse: true
+ text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
diff --git a/tests/auto/quickcontrols2/qquicktextfield/tst_qquicktextfield.cpp b/tests/auto/quickcontrols2/qquicktextfield/tst_qquicktextfield.cpp
new file mode 100644
index 0000000000..19219bb79e
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktextfield/tst_qquicktextfield.cpp
@@ -0,0 +1,101 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include <QtTest/qtest.h>
+#include <QtTest/qsignalspy.h>
+#include <QtTest/qtesttouch.h>
+
+#include <QtGui/qfontmetrics.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformintegration.h>
+#include <QtGui/qtestsupport_gui.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuickTestUtils/private/qmlutils_p.h>
+#include <QtQuickTestUtils/private/viewtestutils_p.h>
+#include <QtQuickTemplates2/private/qquicktextfield_p.h>
+#include <QtQuickControlsTestUtils/private/qtest_quickcontrols_p.h>
+
+class tst_QQuickTextField : public QQmlDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_QQuickTextField();
+
+private slots:
+ void initTestCase() override;
+ void touchscreenDoesNotSelect_data();
+ void touchscreenDoesNotSelect();
+
+private:
+ QScopedPointer<QPointingDevice> touchDevice = QScopedPointer<QPointingDevice>(QTest::createTouchDevice());
+};
+
+tst_QQuickTextField::tst_QQuickTextField()
+ : QQmlDataTest(QT_QMLTEST_DATADIR)
+{
+}
+
+void tst_QQuickTextField::initTestCase()
+{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() > 23)
+ QSKIP("Crashes on Android 7+, figure out why (QTBUG-107028)");
+#endif
+ QQmlDataTest::initTestCase();
+ qputenv("QML_NO_TOUCH_COMPRESSION", "1");
+}
+
+void tst_QQuickTextField::touchscreenDoesNotSelect_data()
+{
+ QTest::addColumn<QUrl>("src");
+ QTest::addColumn<bool>("setEnv");
+ QTest::addColumn<bool>("selectByMouse");
+ QTest::addColumn<bool>("selectByTouch");
+ QTest::newRow("new default") << testFileUrl("mouseselection_default.qml") << false << true << false;
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ QTest::newRow("putenv") << testFileUrl("mouseselection_default.qml") << true << false << false;
+ QTest::newRow("old_import") << testFileUrl("mouseselection_old_default.qml") << false << true << false;
+ QTest::newRow("old+putenv") << testFileUrl("mouseselection_old_default.qml") << true << false << false;
+ QTest::newRow("old+putenv+selectByMouse") << testFileUrl("mouseselection_old_overridden.qml") << true << true << true;
+#endif
+}
+
+void tst_QQuickTextField::touchscreenDoesNotSelect()
+{
+ QFETCH(QUrl, src);
+ QFETCH(bool, setEnv);
+ QFETCH(bool, selectByMouse);
+ QFETCH(bool, selectByTouch);
+
+ if (setEnv)
+ qputenv("QT_QUICK_CONTROLS_TEXT_SELECTION_BEHAVIOR", "old");
+ else
+ qunsetenv("QT_QUICK_CONTROLS_TEXT_SELECTION_BEHAVIOR");
+
+ QQuickView window;
+ QVERIFY(QQuickTest::showView(window, src));
+
+ QQuickTextField *textField = qobject_cast<QQuickTextField *>(window.rootObject());
+ QVERIFY(textField != nullptr);
+ QCOMPARE(textField->selectByMouse(), selectByMouse);
+ textField->setSelectByMouse(true); // enable selection with pre-6.4 import version
+ QVERIFY(textField->selectedText().isEmpty());
+
+ if (selectByMouse) {
+ // press-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = QFontMetrics(textField->font()).height() / 2;
+ QTest::touchEvent(&window, touchDevice.data()).press(0, QPoint(x1,y), &window);
+ QTest::touchEvent(&window, touchDevice.data()).move(0, QPoint(x2,y), &window);
+ QTest::touchEvent(&window, touchDevice.data()).release(0, QPoint(x2,y), &window);
+ QQuickTouchUtils::flush(&window);
+ // if the env var is set, fall back to old behavior: touch swipe _does_ select text if selectByMouse is true
+ QCOMPARE(textField->selectedText().isEmpty(), !selectByTouch);
+ }
+}
+
+QTEST_QUICKCONTROLS_MAIN(tst_QQuickTextField)
+
+#include "tst_qquicktextfield.moc"
diff --git a/tests/auto/quickcontrols2/qquicktreeviewdelegate/BLACKLIST b/tests/auto/quickcontrols2/qquicktreeviewdelegate/BLACKLIST
new file mode 100644
index 0000000000..ed6d7fd2cf
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquicktreeviewdelegate/BLACKLIST
@@ -0,0 +1,6 @@
+# perhaps related to QTBUG-103072
+[dragToSelect]
+android
+# perhaps related to QTBUG-103064
+[pressAndHoldToSelect]
+android
diff --git a/tests/auto/quickcontrols2/qquicktreeviewdelegate/data/unmodified.qml b/tests/auto/quickcontrols2/qquicktreeviewdelegate/data/unmodified.qml
index 02d8b39477..c3edb37d1c 100644
--- a/tests/auto/quickcontrols2/qquicktreeviewdelegate/data/unmodified.qml
+++ b/tests/auto/quickcontrols2/qquicktreeviewdelegate/data/unmodified.qml
@@ -10,6 +10,7 @@ Item {
height: 600
property alias treeView: treeView
+ property alias selectionRectangle: selectionRectangle
TreeView {
id: treeView
@@ -21,4 +22,9 @@ Item {
delegate: TreeViewDelegate {}
selectionModel: ItemSelectionModel { model: treeView.model }
}
+
+ SelectionRectangle {
+ id: selectionRectangle
+ target: treeView
+ }
}
diff --git a/tests/auto/quickcontrols2/qquicktreeviewdelegate/testmodel.cpp b/tests/auto/quickcontrols2/qquicktreeviewdelegate/testmodel.cpp
index 06f7c09b5e..6c6da8452b 100644
--- a/tests/auto/quickcontrols2/qquicktreeviewdelegate/testmodel.cpp
+++ b/tests/auto/quickcontrols2/qquicktreeviewdelegate/testmodel.cpp
@@ -51,7 +51,7 @@ int TestModel::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid())
return 1; // root of the tree
- return treeItem(parent)->m_childItems.count();
+ return treeItem(parent)->m_childItems.size();
}
int TestModel::columnCount(const QModelIndex &) const
@@ -87,7 +87,7 @@ QModelIndex TestModel::index(int row, int column, const QModelIndex &parent) con
if (!hasIndex(row, column, parent))
return QModelIndex();
if (!parent.isValid())
- return createIndex(0, 0, m_rootItem.data());
+ return createIndex(row, column, m_rootItem.data());
return createIndex(row, column, treeItem(parent)->m_childItems.at(row));
}
diff --git a/tests/auto/quickcontrols2/qquicktreeviewdelegate/tst_qquicktreeviewdelegate.cpp b/tests/auto/quickcontrols2/qquicktreeviewdelegate/tst_qquicktreeviewdelegate.cpp
index 79d8619567..834729e133 100644
--- a/tests/auto/quickcontrols2/qquicktreeviewdelegate/tst_qquicktreeviewdelegate.cpp
+++ b/tests/auto/quickcontrols2/qquicktreeviewdelegate/tst_qquicktreeviewdelegate.cpp
@@ -58,8 +58,11 @@ private slots:
void checkPropertiesRoot();
void checkPropertiesChildren();
void checkCurrentIndex();
+ void checkClickedSignal_data();
void checkClickedSignal();
void clearSelectionOnClick();
+ void dragToSelect();
+ void pressAndHoldToSelect();
};
tst_qquicktreeviewdelegate::tst_qquicktreeviewdelegate()
@@ -131,32 +134,18 @@ void tst_qquicktreeviewdelegate::expandAndCollapseClickOnIndicator()
const QPoint localPos = QPoint(indicator->width() / 2, indicator->height() / 2);
const QPoint pos = item->window()->contentItem()->mapFromItem(indicator, localPos).toPoint();
- // When treeview is interactive, we toggle expanded on pointer release
- // to not interfere with flicking. Otherwise we expand already on press.
- if (interactive)
- QTest::mouseClick(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
- else
- QTest::mousePress(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
+ QTest::mouseClick(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
WAIT_UNTIL_POLISHED;
// We now expect 5 rows, the root pluss it's 4 children
QCOMPARE(treeViewPrivate->loadedRows.count(), 5);
- if (!interactive)
- QTest::mouseRelease(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
-
// Collapse the root again
- if (interactive)
- QTest::mouseClick(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
- else
- QTest::mousePress(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
+ QTest::mouseClick(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
WAIT_UNTIL_POLISHED;
// Check that the view only has one row loaded again (the root of the tree)
QCOMPARE(treeViewPrivate->loadedRows.count(), 1);
-
- if (!interactive)
- QTest::mouseRelease(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
}
void tst_qquicktreeviewdelegate::pointerNavigationDisabled()
@@ -281,11 +270,23 @@ void tst_qquicktreeviewdelegate::checkCurrentIndex()
QVERIFY(item->selected());
}
+void tst_qquicktreeviewdelegate::checkClickedSignal_data()
+{
+ QTest::addColumn<bool>("pointerNavigationEnabled");
+ QTest::newRow("pointer navigation enabled") << true;
+ QTest::newRow("pointer navigation disabled") << false;
+}
+
void tst_qquicktreeviewdelegate::checkClickedSignal()
{
- // Check that the delegate emits clicked when clicking on the
- // label, but not when clicking on the indicator.
+ // Check that the delegate emits clicked when clicking on the
+ // label, but not when clicking on the indicator. This API is
+ // a part of the AbstractButton API, and should work with or
+ // without TableView.pointerNavigationEnabled set.
+ QFETCH(bool, pointerNavigationEnabled);
+
LOAD_TREEVIEW("unmodified.qml");
+ treeView->setPointerNavigationEnabled(pointerNavigationEnabled);
const auto item = treeView->itemAtCell(0, 0);
QVERIFY(item);
@@ -296,7 +297,8 @@ void tst_qquicktreeviewdelegate::checkClickedSignal()
QPoint localPos = QPoint(item->width() / 2, item->height() / 2);
QPoint pos = item->window()->contentItem()->mapFromItem(item, localPos).toPoint();
QTest::mouseClick(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
- QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
+ clickedSpy.clear();
// Click on the indicator
const auto indicator = item->property("indicator").value<QQuickItem *>();
@@ -304,7 +306,7 @@ void tst_qquicktreeviewdelegate::checkClickedSignal()
localPos = QPoint(indicator->x() + indicator->width() / 2, indicator->y() + indicator->height() / 2);
pos = item->window()->contentItem()->mapFromItem(item, localPos).toPoint();
QTest::mouseClick(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
- QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 0);
}
void tst_qquicktreeviewdelegate::clearSelectionOnClick()
@@ -314,7 +316,7 @@ void tst_qquicktreeviewdelegate::clearSelectionOnClick()
// Select root item
const auto index = treeView->selectionModel()->model()->index(0, 0);
treeView->selectionModel()->select(index, QItemSelectionModel::Select);
- QCOMPARE(treeView->selectionModel()->selectedIndexes().count(), 1);
+ QCOMPARE(treeView->selectionModel()->selectedIndexes().size(), 1);
// Click on a cell. This should remove the selection
const auto item = qobject_cast<QQuickTreeViewDelegate *>(treeView->itemAtCell(0, 0));
@@ -322,7 +324,76 @@ void tst_qquicktreeviewdelegate::clearSelectionOnClick()
QPoint localPos = QPoint(item->width() / 2, item->height() / 2);
QPoint pos = item->window()->contentItem()->mapFromItem(item, localPos).toPoint();
QTest::mouseClick(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
- QCOMPARE(treeView->selectionModel()->selectedIndexes().count(), 0);
+ QCOMPARE(treeView->selectionModel()->selectedIndexes().size(), 0);
+}
+
+void tst_qquicktreeviewdelegate::dragToSelect()
+{
+ // Check that the delegate is not blocking the user from
+ // being able to select cells using Drag.
+ LOAD_TREEVIEW("unmodified.qml");
+
+ // When TreeView is not interactive, SelectionRectangle
+ // will use Drag by default.
+ treeView->setInteractive(false);
+ treeView->expandRecursively();
+
+ WAIT_UNTIL_POLISHED;
+
+ QVERIFY(!treeView->selectionModel()->hasSelection());
+ QCOMPARE(treeView->selectionBehavior(), QQuickTableView::SelectRows);
+
+ // Drag on from cell 0,0 to 0,1
+ const auto item0_0 = treeView->itemAtCell(0, 0);
+ const auto item0_1 = treeView->itemAtCell(0, 1);
+ QVERIFY(item0_0);
+ QVERIFY(item0_1);
+
+ QQuickWindow *window = treeView->window();
+ QPoint localPos0_0 = QPoint(item0_0->width() / 2, item0_0->height() / 2);
+ QPoint windowPos0_0 = window->contentItem()->mapFromItem(item0_0, localPos0_0).toPoint();
+ QPoint localPos0_1 = QPoint(item0_1->width() / 2, item0_1->height() / 2);
+ QPoint windowPos0_1 = window->contentItem()->mapFromItem(item0_1, localPos0_1).toPoint();
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, windowPos0_0);
+ QTest::mouseMove(window, windowPos0_1);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, windowPos0_1);
+
+ // Since TreeView uses TableView.SelectRows by default, we
+ // now expect cells from 0,0 and 1,1 to be selected.
+ QCOMPARE(treeView->selectionModel()->selectedIndexes().size(), 4);
+}
+
+void tst_qquicktreeviewdelegate::pressAndHoldToSelect()
+{
+ // Check that the delegate is not blocking the user from
+ // being able to select cells using PressAndHold
+ LOAD_TREEVIEW("unmodified.qml");
+
+ // When TreeView is interactive, SelectionRectangle
+ // will use PressAndHold by default.
+ treeView->setInteractive(true);
+ treeView->expandRecursively();
+
+ WAIT_UNTIL_POLISHED;
+
+ QVERIFY(!treeView->selectionModel()->hasSelection());
+ QCOMPARE(treeView->selectionBehavior(), QQuickTableView::SelectRows);
+
+ // PressAndHold on cell 0,0
+ const auto item0_0 = treeView->itemAtCell(0, 0);
+ QVERIFY(item0_0);
+
+ QQuickWindow *window = treeView->window();
+ QPoint localPos0_0 = QPoint(item0_0->width() / 2, item0_0->height() / 2);
+ QPoint windowPos0_0 = window->contentItem()->mapFromItem(item0_0, localPos0_0).toPoint();
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, windowPos0_0);
+ QTRY_VERIFY(treeView->selectionModel()->hasSelection());
+ // Since TreeView uses TableView.SelectRows by default, we
+ // now expect both cell 0,0 and 1,0 to be selected.
+ QCOMPARE(treeView->selectionModel()->selectedIndexes().size(), 2);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, windowPos0_0);
}
QTEST_MAIN(tst_qquicktreeviewdelegate)
diff --git a/tests/auto/quickcontrols2/styleimports/tst_styleimports.cpp b/tests/auto/quickcontrols2/styleimports/tst_styleimports.cpp
index 5a73ad429a..e2bb80fb4e 100644
--- a/tests/auto/quickcontrols2/styleimports/tst_styleimports.cpp
+++ b/tests/auto/quickcontrols2/styleimports/tst_styleimports.cpp
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QtCore/qregularexpression.h>
+#include <QtGui/qpalette.h>
#include <QtTest/qtest.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQml/qqmlcontext.h>
@@ -195,6 +196,10 @@ void tst_StyleImports::customStyleSelector()
QCOMPARE(customComponent->objectName(), "+FileSystemStyle/CustomComponent.qml");
}
+QT_BEGIN_NAMESPACE
+extern QPalette qt_fusionPalette();
+QT_END_NAMESPACE
+
void tst_StyleImports::fallbackStyleShouldNotOverwriteTheme_data()
{
QTest::addColumn<QString>("style");
@@ -202,7 +207,8 @@ void tst_StyleImports::fallbackStyleShouldNotOverwriteTheme_data()
QTest::addColumn<QColor>("expectedContentItemColor");
QTest::addRow("style=Fusion,fallbackStyle=Material")
- << QString::fromLatin1("Fusion") << QString::fromLatin1("Material") << QColor::fromRgb(0x252525);
+ << QString::fromLatin1("Fusion") << QString::fromLatin1("Material")
+ << qt_fusionPalette().buttonText().color();
QTest::addRow("style=ResourceStyle,fallbackStyle=Material")
<< QString::fromLatin1("ResourceStyle") << QString::fromLatin1("Material") << QColor("salmon");
}
diff --git a/tests/auto/quickcontrols2/translation/tst_translation.cpp b/tests/auto/quickcontrols2/translation/tst_translation.cpp
index 76e3244cbd..f0798d0367 100644
--- a/tests/auto/quickcontrols2/translation/tst_translation.cpp
+++ b/tests/auto/quickcontrols2/translation/tst_translation.cpp
@@ -157,7 +157,7 @@ void tst_translation::stackView()
QVERIFY(button);
// Shouldn't crash when calling retranslate.
QVERIFY(clickButton(button));
- QTRY_COMPARE(calledTranslateSpy.count(), 1);
+ QTRY_COMPARE(calledTranslateSpy.size(), 1);
}
QTEST_MAIN(tst_translation)
diff --git a/tests/auto/quickdialogs/qquickcolordialogimpl/tst_qquickcolordialogimpl.cpp b/tests/auto/quickdialogs/qquickcolordialogimpl/tst_qquickcolordialogimpl.cpp
index d7666498df..3a463c8b08 100644
--- a/tests/auto/quickdialogs/qquickcolordialogimpl/tst_qquickcolordialogimpl.cpp
+++ b/tests/auto/quickdialogs/qquickcolordialogimpl/tst_qquickcolordialogimpl.cpp
@@ -51,7 +51,6 @@ private slots:
void changeHex();
void changeColorFromTextFields_data();
void changeColorFromTextFields();
- void eyeDropper();
void windowTitle_data();
void windowTitle();
@@ -168,7 +167,7 @@ void tst_QQuickColorDialogImpl::moveColorPickerHandle()
// Move handle to where the saturation is the highest and the lightness is 'neutral'
QTest::mouseClick(dialogHelper.window(), Qt::LeftButton, Qt::NoModifier, topCenter);
- QCOMPARE(colorChangedSpy.count(), 1);
+ QCOMPARE(colorChangedSpy.size(), 1);
const qreal floatingPointComparisonThreshold = 1.0 / colorPicker->width();
const QString floatComparisonErrorString(
@@ -196,7 +195,7 @@ void tst_QQuickColorDialogImpl::moveColorPickerHandle()
QCOMPARE(colorPicker->hue(), QColorConstants::Cyan.hslHueF());
QCOMPARE(colorPicker->color().rgba(), QColorConstants::Cyan.rgba());
- QCOMPARE(colorChangedSpy.count(), 2);
+ QCOMPARE(colorChangedSpy.size(), 2);
QPoint bottomCenter = colorPicker->mapToScene({ colorPicker->width() / 2, colorPicker->height() }).toPoint();
@@ -209,7 +208,7 @@ void tst_QQuickColorDialogImpl::moveColorPickerHandle()
// This means that the current color was changed twice.
// (The press happens 1 pixel above the release, to work around an issue where the mouse event
// wasn't received by the color picker)
- QCOMPARE(colorChangedSpy.count(), 4);
+ QCOMPARE(colorChangedSpy.size(), 4);
FUZZYCOMPARE(colorPicker->saturation(), 0.0, floatingPointComparisonThreshold,
qPrintable(floatComparisonErrorString.arg("saturation()").arg(colorPicker->saturation()).arg(0.0).arg(floatingPointComparisonThreshold)));
FUZZYCOMPARE(dialogHelper.quickDialog->saturation(), 0.0, floatingPointComparisonThreshold,
@@ -318,7 +317,7 @@ void tst_QQuickColorDialogImpl::changeHex()
// Modify the value in the TextField to something else.
colorTextField->forceActiveFocus();
- colorTextField->select(1, colorTextField->text().length());
+ colorTextField->select(1, colorTextField->text().size());
QVERIFY(colorTextField->hasActiveFocus());
QTest::keyClick(dialogHelper.window(), Qt::Key_Backspace);
QTest::keyClick(dialogHelper.window(), '0');
@@ -432,53 +431,6 @@ void tst_QQuickColorDialogImpl::changeColorFromTextFields()
CLOSE_DIALOG("Ok");
}
-void tst_QQuickColorDialogImpl::eyeDropper()
-{
-#ifdef Q_OS_QNX
- QSKIP("Skipping the test for the QNX platform!");
-#endif
-
- DialogTestHelper<QQuickColorDialog, QQuickColorDialogImpl> dialogHelper(this, "colorDialog.qml");
- QVERIFY2(dialogHelper.isWindowInitialized(), dialogHelper.failureMessage());
- QVERIFY(dialogHelper.waitForWindowActive());
-
- // Open the dialog.
- QVERIFY(dialogHelper.openDialog());
- QTRY_VERIFY(dialogHelper.isQuickDialogOpen());
-
- QQuickAbstractButton *eyeDropperButton = dialogHelper.quickDialog->findChild<QQuickAbstractButton *>("eyeDropperButton");
- QVERIFY(eyeDropperButton);
-
- // Only test on platforms that support grabbing of external windows.
- const bool wayland = QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive) == 0;
- const bool offscreen = qgetenv("QT_QPA_PLATFORM").compare(QLatin1String("offscreen"), Qt::CaseInsensitive) == 0;
- if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ScreenWindowGrabbing) && !wayland && !offscreen)
- {
- QVERIFY(eyeDropperButton->isVisible());
-
- // Enable the eyeDropper.
- QTest::mouseClick(dialogHelper.window(), Qt::LeftButton, Qt::NoModifier, eyeDropperButton->mapToScene({eyeDropperButton->width() / 2, eyeDropperButton->height() / 2}).toPoint());
- QTest::qWait(500); // Flaky
-
- // Pick the new color from the screen somewhere.
- const auto p = dialogHelper.quickDialog->popupItem()->mapToScene({-10, 0}).toPoint();
- QTest::mouseMove(dialogHelper.window(), p);
- QTest::mouseClick(dialogHelper.window(), Qt::LeftButton, Qt::NoModifier, p);
-
- // The color should be equal to the ApplicationWindows background color
- const unsigned int yellow = QColorConstants::Yellow.rgba();
- if (dialogHelper.quickDialog->color().rgba() != yellow)
- QFAIL(qPrintable(QStringLiteral("The picked color was %1, when yellow was expected. Window size: %2x%3").arg(dialogHelper.quickDialog->color().name()).arg(dialogHelper.window()->width()).arg(dialogHelper.window()->height())));
- }
- else
- {
- // Feature should be hidden on unsupported platforms.
- QVERIFY(!eyeDropperButton->isVisible());
- }
-
- CLOSE_DIALOG("Ok");
-}
-
void tst_QQuickColorDialogImpl::windowTitle_data()
{
QTest::addColumn<QString>("title");
diff --git a/tests/auto/quickdialogs/qquickfiledialogimpl/tst_qquickfiledialogimpl.cpp b/tests/auto/quickdialogs/qquickfiledialogimpl/tst_qquickfiledialogimpl.cpp
index ae9db3dfd1..1a615ae948 100644
--- a/tests/auto/quickdialogs/qquickfiledialogimpl/tst_qquickfiledialogimpl.cpp
+++ b/tests/auto/quickdialogs/qquickfiledialogimpl/tst_qquickfiledialogimpl.cpp
@@ -86,6 +86,8 @@ private slots:
void done();
void setSelectedFile_data();
void setSelectedFile();
+ void selectNewFileViaTextField_data();
+ void selectNewFileViaTextField();
private:
QTemporaryDir tempDir;
@@ -97,6 +99,7 @@ private:
QScopedPointer<QFile> tempSubFile2;
QTemporaryDir largeTempDir;
+ QStringList largeTempDirPaths;
QDir largeTempDirLargeSubDir;
const int largeTempDirLargeSubDirIndex = 80;
@@ -120,7 +123,7 @@ void tst_QQuickFileDialogImpl::initTestCase()
qputenv("QT_QUICK_DIALOGS_PRESELECT_FIRST_FILE", "1");
- QVERIFY(tempDir.isValid());
+ QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString()));
// QTEST_QUICKCONTROLS_MAIN constructs the test case object once,
// and then calls qRun() for each style, and qRun() calls initTestCase().
// So, we need to check if we've already made the temporary directory.
@@ -166,24 +169,23 @@ void tst_QQuickFileDialogImpl::initTestCase()
/*
Create another temporary directory that contains a large amount of folders.
*/
- QVERIFY(largeTempDir.isValid());
+ QVERIFY2(largeTempDir.isValid(), qPrintable(largeTempDir.errorString()));
const static int largeFileCount = 100;
+ const QDir largeTempDirectory(largeTempDir.path());
for (int i = 0; i < largeFileCount; ++i) {
- QDir newDir(largeTempDir.path());
- QVERIFY(newDir.exists());
// Pad with zeroes so that the directories are ordered as we expect.
- QVERIFY(newDir.mkdir(QString::fromLatin1("dir%1").arg(i, 3, 10, QLatin1Char('0'))));
+ const QString dirName = QString::fromLatin1("dir%1").arg(i, 3, 10, QLatin1Char('0'));
+ QVERIFY(largeTempDirectory.mkdir(dirName));
+ largeTempDirPaths.append(largeTempDirectory.filePath(dirName));
}
// ... and within one of those folders, more folders.
largeTempDirLargeSubDir = QDir(largeTempDir.path() + "/dir"
+ QString::fromLatin1("%1").arg(largeTempDirLargeSubDirIndex, 3, 10, QLatin1Char('0')));
QVERIFY(largeTempDirLargeSubDir.exists());
- for (int i = 0; i < largeFileCount; ++i) {
- QDir newDir(largeTempDirLargeSubDir.path());
- QVERIFY(newDir.exists());
- QVERIFY(newDir.mkdir(QString::fromLatin1("sub-dir%1").arg(i, 3, 10, QLatin1Char('0'))));
- }
+ const QDir largeTempSubDirectory = QDir(largeTempDirLargeSubDir.path());
+ for (int i = 0; i < largeFileCount; ++i)
+ QVERIFY(largeTempSubDirectory.mkdir(QString::fromLatin1("sub-dir%1").arg(i, 3, 10, QLatin1Char('0'))));
// Ensure that each test starts off in the temporary directory.
oldCurrentDir = QDir::current();
@@ -807,6 +809,9 @@ void tst_QQuickFileDialogImpl::goUpIntoLargeFolder()
// Go up a directory via the keyboard shortcut.
QTest::keySequence(dialogHelper.window(), goUpKeySequence);
+ QString failureMessage;
+ QTRY_VERIFY2(verifyFileDialogDelegates(dialogHelper.fileDialogListView,
+ largeTempDirPaths, failureMessage), qPrintable(failureMessage));
VERIFY_FILE_SELECTED_AND_FOCUSED(QUrl::fromLocalFile(largeTempDir.path()),
QUrl::fromLocalFile(largeTempDirLargeSubDir.path()), largeTempDirLargeSubDirIndex);
}
@@ -1028,7 +1033,7 @@ void tst_QQuickFileDialogImpl::tabFocusNavigation()
}
// Tab through each item, checking the focus after each.
- for (auto expectedFocusItem : qAsConst(expectedFocusItems)) {
+ for (auto expectedFocusItem : std::as_const(expectedFocusItems)) {
// Check the focus item first so that we account for the first item.
// Print detailed failure message as workaround for QTBUG-92102.
QVERIFY2(dialogHelper.window()->activeFocusItem() == expectedFocusItem, qPrintable(QString::fromLatin1(
@@ -1043,7 +1048,7 @@ void tst_QQuickFileDialogImpl::tabFocusNavigation()
std::reverse(expectedFocusItems.begin(), expectedFocusItems.end());
// We know the first (last) item has focus already, so skip it.
expectedFocusItems.removeFirst();
- for (auto expectedFocusItem : qAsConst(expectedFocusItems)) {
+ for (auto expectedFocusItem : std::as_const(expectedFocusItems)) {
QTest::keyClick(dialogHelper.window(), Qt::Key_Tab, Qt::ShiftModifier);
QCOMPARE(dialogHelper.window()->activeFocusItem(), expectedFocusItem);
@@ -1370,6 +1375,48 @@ void tst_QQuickFileDialogImpl::setSelectedFile()
}
}
+void tst_QQuickFileDialogImpl::selectNewFileViaTextField_data()
+{
+ fileMode_data();
+}
+void tst_QQuickFileDialogImpl::selectNewFileViaTextField()
+{
+ QFETCH(QQuickFileDialog::FileMode, fileMode);
+
+ // Open the dialog.
+ FileDialogTestHelper dialogHelper(this, "fileDialog.qml");
+ dialogHelper.dialog->setFileMode(fileMode);
+
+ if (fileMode == QQuickFileDialog::SaveFile)
+ dialogHelper.dialog->setSelectedFile(QUrl());
+
+ OPEN_QUICK_DIALOG();
+ QQuickTest::qWaitForPolish(dialogHelper.window());
+
+ const QQuickTextField *fileNameTextField =
+ dialogHelper.quickDialog->findChild<QQuickTextField *>("fileNameTextField");
+ QVERIFY(fileNameTextField);
+
+ QVERIFY2(fileNameTextField->isVisible() == (fileMode == QQuickFileDialog::SaveFile),
+ "The TextField for file name should only be visible when the FileMode is 'SaveFile'");
+
+ if (fileMode == QQuickFileDialog::SaveFile) {
+ const QPoint textFieldCenterPos =
+ fileNameTextField->mapToScene({ fileNameTextField->width() / 2, fileNameTextField->height() / 2 }).toPoint();
+
+ QTest::mouseClick(dialogHelper.window(), Qt::LeftButton, Qt::NoModifier, textFieldCenterPos);
+ QTRY_VERIFY(fileNameTextField->hasActiveFocus());
+
+ const QByteArray newFileName("foo.txt");
+ for (const auto &c : newFileName)
+ QTest::keyClick(dialogHelper.window(), c);
+ QTest::keyClick(dialogHelper.window(), Qt::Key_Enter);
+
+ QTRY_COMPARE(fileNameTextField->text(), newFileName);
+ QCOMPARE(dialogHelper.dialog->selectedFile().fileName(), newFileName);
+ }
+}
+
QTEST_MAIN(tst_QQuickFileDialogImpl)
#include "tst_qquickfiledialogimpl.moc"
diff --git a/tests/auto/quickdialogs/qquickfolderdialogimpl/tst_qquickfolderdialogimpl.cpp b/tests/auto/quickdialogs/qquickfolderdialogimpl/tst_qquickfolderdialogimpl.cpp
index 097bc3a9af..01116aa7e9 100644
--- a/tests/auto/quickdialogs/qquickfolderdialogimpl/tst_qquickfolderdialogimpl.cpp
+++ b/tests/auto/quickdialogs/qquickfolderdialogimpl/tst_qquickfolderdialogimpl.cpp
@@ -231,10 +231,10 @@ void tst_QQuickFolderDialogImpl::chooseFolderViaStandardButtons()
COMPARE_URL(dialogHelper.quickDialog->selectedFolder(), QUrl::fromLocalFile(tempSubDir2.path()));
COMPARE_URL(dialogHelper.dialog->selectedFolder(), QUrl::fromLocalFile(tempSubDir2.path()));
// Only selectedFile-related signals should be emitted.
- QCOMPARE(signalHelper.dialogSelectedFolderChangedSpy.count(), 1);
- QCOMPARE(signalHelper.quickDialogSelectedFolderChangedSpy.count(), 1);
- QCOMPARE(signalHelper.dialogCurrentFolderChangedSpy.count(), 0);
- QCOMPARE(signalHelper.quickDialogCurrentFolderChangedSpy.count(), 0);
+ QCOMPARE(signalHelper.dialogSelectedFolderChangedSpy.size(), 1);
+ QCOMPARE(signalHelper.quickDialogSelectedFolderChangedSpy.size(), 1);
+ QCOMPARE(signalHelper.dialogCurrentFolderChangedSpy.size(), 0);
+ QCOMPARE(signalHelper.quickDialogCurrentFolderChangedSpy.size(), 0);
// Click the "Open" button.
QVERIFY(dialogHelper.quickDialog->footer());
@@ -245,10 +245,10 @@ void tst_QQuickFolderDialogImpl::chooseFolderViaStandardButtons()
QVERIFY(clickButton(openButton));
COMPARE_URL(dialogHelper.dialog->selectedFolder(), QUrl::fromLocalFile(tempSubDir2.path()));
COMPARE_URL(dialogHelper.quickDialog->selectedFolder(), QUrl::fromLocalFile(tempSubDir2.path()));
- QCOMPARE(signalHelper.dialogSelectedFolderChangedSpy.count(), 1);
- QCOMPARE(signalHelper.quickDialogSelectedFolderChangedSpy.count(), 1);
- QCOMPARE(signalHelper.dialogCurrentFolderChangedSpy.count(), 0);
- QCOMPARE(signalHelper.quickDialogCurrentFolderChangedSpy.count(), 0);
+ QCOMPARE(signalHelper.dialogSelectedFolderChangedSpy.size(), 1);
+ QCOMPARE(signalHelper.quickDialogSelectedFolderChangedSpy.size(), 1);
+ QCOMPARE(signalHelper.dialogCurrentFolderChangedSpy.size(), 0);
+ QCOMPARE(signalHelper.quickDialogCurrentFolderChangedSpy.size(), 0);
QTRY_VERIFY(!dialogHelper.quickDialog->isVisible());
QVERIFY(!dialogHelper.dialog->isVisible());
}
@@ -323,10 +323,10 @@ void tst_QQuickFolderDialogImpl::changeFolderViaDoubleClick()
COMPARE_URL(dialogHelper.dialog->selectedFolder(), QUrl());
// selectedFolder is set to the folder when clicked and then set to an empty URL after
// the double click.
- QCOMPARE(signalHelper.dialogSelectedFolderChangedSpy.count(), 2);
- QCOMPARE(signalHelper.quickDialogSelectedFolderChangedSpy.count(), 2);
- QCOMPARE(signalHelper.dialogCurrentFolderChangedSpy.count(), 1);
- QCOMPARE(signalHelper.quickDialogCurrentFolderChangedSpy.count(), 1);
+ QCOMPARE(signalHelper.dialogSelectedFolderChangedSpy.size(), 2);
+ QCOMPARE(signalHelper.quickDialogSelectedFolderChangedSpy.size(), 2);
+ QCOMPARE(signalHelper.dialogCurrentFolderChangedSpy.size(), 1);
+ QCOMPARE(signalHelper.quickDialogCurrentFolderChangedSpy.size(), 1);
// Since we only changed the current folder, the dialog should still be open.
QVERIFY(dialogHelper.dialog->isVisible());
@@ -396,10 +396,10 @@ void tst_QQuickFolderDialogImpl::changeFolderViaEnter()
QTest::keyClick(dialogHelper.window(), Qt::Key_Return);
COMPARE_URL(dialogHelper.dialog->currentFolder(), QUrl::fromLocalFile(tempSubDir1.path()));
COMPARE_URL(dialogHelper.dialog->selectedFolder(), QUrl::fromLocalFile(tempSubSubDir.path()));
- QCOMPARE(signalHelper.dialogSelectedFolderChangedSpy.count(), 1);
- QCOMPARE(signalHelper.quickDialogSelectedFolderChangedSpy.count(), 1);
- QCOMPARE(signalHelper.dialogCurrentFolderChangedSpy.count(), 1);
- QCOMPARE(signalHelper.quickDialogCurrentFolderChangedSpy.count(), 1);
+ QCOMPARE(signalHelper.dialogSelectedFolderChangedSpy.size(), 1);
+ QCOMPARE(signalHelper.quickDialogSelectedFolderChangedSpy.size(), 1);
+ QCOMPARE(signalHelper.dialogCurrentFolderChangedSpy.size(), 1);
+ QCOMPARE(signalHelper.quickDialogCurrentFolderChangedSpy.size(), 1);
// Since we only changed the current folder, the dialog should still be open.
QVERIFY(dialogHelper.dialog->isVisible());
@@ -687,7 +687,7 @@ void tst_QQuickFolderDialogImpl::tabFocusNavigation()
}
// Tab through each item, checking the focus after each.
- for (auto expectedFocusItem : qAsConst(expectedFocusItems)) {
+ for (auto expectedFocusItem : std::as_const(expectedFocusItems)) {
// Check the focus item first so that we account for the first item.
// Print detailed failure message as workaround for QTBUG-92102.
QVERIFY2(dialogHelper.window()->activeFocusItem() == expectedFocusItem, qPrintable(QString::fromLatin1(
@@ -702,7 +702,7 @@ void tst_QQuickFolderDialogImpl::tabFocusNavigation()
std::reverse(expectedFocusItems.begin(), expectedFocusItems.end());
// We know the first (last) item has focus already, so skip it.
expectedFocusItems.removeFirst();
- for (auto expectedFocusItem : qAsConst(expectedFocusItems)) {
+ for (auto expectedFocusItem : std::as_const(expectedFocusItems)) {
QTest::keyClick(dialogHelper.window(), Qt::Key_Tab, Qt::ShiftModifier);
QCOMPARE(dialogHelper.window()->activeFocusItem(), expectedFocusItem);
diff --git a/tests/auto/quickdialogs/qquickfontdialogimpl/tst_qquickfontdialogimpl.cpp b/tests/auto/quickdialogs/qquickfontdialogimpl/tst_qquickfontdialogimpl.cpp
index 78a0060824..5de4fe291b 100644
--- a/tests/auto/quickdialogs/qquickfontdialogimpl/tst_qquickfontdialogimpl.cpp
+++ b/tests/auto/quickdialogs/qquickfontdialogimpl/tst_qquickfontdialogimpl.cpp
@@ -151,7 +151,7 @@ void tst_QQuickFontDialogImpl::changingWritingSystem()
QVERIFY(anyDelegate);
QCOMPARE(anyDelegate->text(), QFontDatabase::writingSystemName(QFontDatabase::Any));
- QCOMPARE(fontFamilyModelSpy.count(), 0);
+ QCOMPARE(fontFamilyModelSpy.size(), 0);
// Select "Japanese" from the ComboBox.
const int japaneseIndex = QFontDatabase::Japanese;
@@ -162,7 +162,7 @@ void tst_QQuickFontDialogImpl::changingWritingSystem()
QTRY_VERIFY(!writingSystemComboBox->popup()->isVisible());
// Check that the contents of the font family listview changed
- QCOMPARE(fontFamilyModelSpy.count(), 1);
+ QCOMPARE(fontFamilyModelSpy.size(), 1);
// And that the sample text is correctly set
QCOMPARE(sampleEdit->text(), QFontDatabase::writingSystemSample(QFontDatabase::Japanese));
@@ -235,11 +235,11 @@ void tst_QQuickFontDialogImpl::clickAroundInTheFamilyListView()
const QString expected2 = fontListModel[i],
actual2 = dialogHelper.dialog->selectedFont().family();
QVERIFY2(expected2 == actual2, qPrintable(err.arg(expected2, actual2).append(", FONT ").append(fontDelegate->text())));
- const int selectedFontSpyCount = selectedFontSpy.count();
+ const int selectedFontSpyCount = selectedFontSpy.size();
QVERIFY2(selectedFontSpyCount == 1, qPrintable(err.arg(1).arg(selectedFontSpyCount).append(", FONT ").append(fontDelegate->text())));
- QVERIFY2((oldStyleModel == fontStyleListView->model()) != (styleModelSpy.count() == 1),
+ QVERIFY2((oldStyleModel == fontStyleListView->model()) != (styleModelSpy.size() == 1),
qPrintable(QString("LOOP INDEX %1").arg(i)));
- QVERIFY2((oldSizeModel == fontSizeListView->model()) != (sizeModelSpy.count() == 1),
+ QVERIFY2((oldSizeModel == fontSizeListView->model()) != (sizeModelSpy.size() == 1),
qPrintable(QString("LOOP INDEX %1").arg(i)));
}
@@ -269,25 +269,25 @@ void tst_QQuickFontDialogImpl::settingUnderlineAndStrikeoutEffects()
QVERIFY(clickButton(underlineCheckBox));
- QCOMPARE(selectedFontSpy.count(), 1);
+ QCOMPARE(selectedFontSpy.size(), 1);
QVERIFY(dialogHelper.dialog->selectedFont().underline());
QVERIFY(!dialogHelper.dialog->selectedFont().strikeOut());
QVERIFY(clickButton(underlineCheckBox));
- QCOMPARE(selectedFontSpy.count(), 2);
+ QCOMPARE(selectedFontSpy.size(), 2);
QVERIFY(!dialogHelper.dialog->selectedFont().underline());
QVERIFY(!dialogHelper.dialog->selectedFont().strikeOut());
QVERIFY(clickButton(strikeoutCheckBox));
- QCOMPARE(selectedFontSpy.count(), 3);
+ QCOMPARE(selectedFontSpy.size(), 3);
QVERIFY(!dialogHelper.dialog->selectedFont().underline());
QVERIFY(dialogHelper.dialog->selectedFont().strikeOut());
QVERIFY(clickButton(strikeoutCheckBox));
- QCOMPARE(selectedFontSpy.count(), 4);
+ QCOMPARE(selectedFontSpy.size(), 4);
QVERIFY(!dialogHelper.dialog->selectedFont().underline());
QVERIFY(!dialogHelper.dialog->selectedFont().strikeOut());
@@ -401,7 +401,7 @@ public:
do {
m_searchText.append(searchText);
- for (int i = 0; i < m_model.count(); ++i) {
+ for (int i = 0; i < m_model.size(); ++i) {
if (m_model.at(i).startsWith(m_searchText, Qt::CaseInsensitive))
return i;
}
@@ -512,7 +512,7 @@ void tst_QQuickFontDialogImpl::setCurrentFontFromApi()
QVERIFY(fontSizeEdit);
// From when the listviews are populated
- QCOMPARE(selectedFontSpy.count(), 1);
+ QCOMPARE(selectedFontSpy.size(), 1);
selectedFontSpy.clear();
@@ -538,16 +538,16 @@ void tst_QQuickFontDialogImpl::setCurrentFontFromApi()
QCOMPARE(styleModel.at(fontStyleListView->currentIndex()), style);
QCOMPARE(fontSizeEdit->text(), QString::number(size++));
- QCOMPARE(selectedFontSpy.count(), ++spyCounter);
+ QCOMPARE(selectedFontSpy.size(), ++spyCounter);
- for (int styleIt = 0; styleIt < qMin(styleModel.count(), maxNumberOfStyles); ++styleIt) {
+ for (int styleIt = 0; styleIt < qMin(styleModel.size(), maxNumberOfStyles); ++styleIt) {
const QString currentStyle = styleModel.at(styleIt);
const QFont f = QFontDatabase::font(*family, currentStyle, size);
dialogHelper.dialog->setSelectedFont(f);
QCOMPARE(styleModel.at(fontStyleListView->currentIndex()), currentStyle);
- QCOMPARE(selectedFontSpy.count(), ++spyCounter);
+ QCOMPARE(selectedFontSpy.size(), ++spyCounter);
}
}
diff --git a/tests/auto/quickdialogs/qquickmessagedialogimpl/tst_qquickmessagedialogimpl.cpp b/tests/auto/quickdialogs/qquickmessagedialogimpl/tst_qquickmessagedialogimpl.cpp
index 93b29d6a16..b2f3d6456c 100644
--- a/tests/auto/quickdialogs/qquickmessagedialogimpl/tst_qquickmessagedialogimpl.cpp
+++ b/tests/auto/quickdialogs/qquickmessagedialogimpl/tst_qquickmessagedialogimpl.cpp
@@ -79,7 +79,7 @@ void tst_QQuickMessageDialogImpl::changeText()
// update the text property
dialogHelper.dialog->setText(testString1);
- QCOMPARE(textSpy.count(), 1);
+ QCOMPARE(textSpy.size(), 1);
// The textLabel is empty until dialog is re-opened
QCOMPARE(dialogHelper.dialog->text(), testString1);
@@ -91,7 +91,7 @@ void tst_QQuickMessageDialogImpl::changeText()
// The textLabel isn't updated immediately
dialogHelper.dialog->setText(testString2);
- QCOMPARE(textSpy.count(), 2);
+ QCOMPARE(textSpy.size(), 2);
QCOMPARE(textLabel->text(), testString1);
dialogHelper.dialog->close();
@@ -128,7 +128,7 @@ void tst_QQuickMessageDialogImpl::changeInformativeText()
// update the informativeText property
dialogHelper.dialog->setInformativeText(testString1);
- QCOMPARE(informativeTextSpy.count(), 1);
+ QCOMPARE(informativeTextSpy.size(), 1);
// The textLabel is empty until dialog is re-opened
QCOMPARE(dialogHelper.dialog->informativeText(), testString1);
@@ -140,7 +140,7 @@ void tst_QQuickMessageDialogImpl::changeInformativeText()
// The textLabel shouldn't update immediately
dialogHelper.dialog->setInformativeText(testString2);
- QCOMPARE(informativeTextSpy.count(), 2);
+ QCOMPARE(informativeTextSpy.size(), 2);
QCOMPARE(informativeTextLabel->text(), testString1);
dialogHelper.dialog->close();
@@ -169,7 +169,7 @@ void tst_QQuickMessageDialogImpl::changeStandardButtons()
QPlatformDialogHelper::StandardButtons(QPlatformDialogHelper::StandardButton::Save
| QPlatformDialogHelper::StandardButton::Cancel
| QPlatformDialogHelper::StandardButton::Apply));
- QCOMPARE(buttonBoxSpy.count(), 1);
+ QCOMPARE(buttonBoxSpy.size(), 1);
QCOMPARE(buttonBox->count(), 1);
dialogHelper.dialog->close();
dialogHelper.dialog->open();
@@ -190,7 +190,7 @@ void tst_QQuickMessageDialogImpl::changeStandardButtons()
dialogHelper.dialog->setButtons(
QPlatformDialogHelper::StandardButton(QPlatformDialogHelper::StandardButton::Ok
| QPlatformDialogHelper::StandardButton::Close));
- QCOMPARE(buttonBoxSpy.count(), 2);
+ QCOMPARE(buttonBoxSpy.size(), 2);
QCOMPARE(buttonBox->count(), 3);
dialogHelper.dialog->open();
QCOMPARE(buttonBox->count(), 2);
@@ -233,7 +233,7 @@ void tst_QQuickMessageDialogImpl::detailedText()
// Set the detailed text to a non-empty string
dialogHelper.dialog->setDetailedText(nonEmptyString);
QCOMPARE(dialogHelper.dialog->detailedText(), nonEmptyString);
- QCOMPARE(detailedTextSpy.count(), 1);
+ QCOMPARE(detailedTextSpy.size(), 1);
QCOMPARE(detailedTextArea->text(), emptyString);
QVERIFY(!detailedTextButton->isVisible());
dialogHelper.dialog->close();
@@ -246,7 +246,7 @@ void tst_QQuickMessageDialogImpl::detailedText()
// Set the detailed text to an empty string
dialogHelper.dialog->setDetailedText(emptyString);
- QCOMPARE(detailedTextSpy.count(), 2);
+ QCOMPARE(detailedTextSpy.size(), 2);
QCOMPARE(dialogHelper.dialog->detailedText(), emptyString);
QCOMPARE(detailedTextArea->text(), nonEmptyString);
QVERIFY(detailedTextButton->isVisible());
@@ -260,7 +260,7 @@ void tst_QQuickMessageDialogImpl::detailedText()
// Change the detailed text property while the dialog is already open, should not immediately
// update the dialog ui
dialogHelper.dialog->setDetailedText(nonEmptyString);
- QCOMPARE(detailedTextSpy.count(), 3);
+ QCOMPARE(detailedTextSpy.size(), 3);
QCOMPARE(dialogHelper.dialog->detailedText(), nonEmptyString);
QCOMPARE(detailedTextArea->text(), emptyString);
QVERIFY2(!detailedTextButton->isVisible(),
diff --git a/tests/auto/quicktest/signalspy/tst_signalspy.cpp b/tests/auto/quicktest/signalspy/tst_signalspy.cpp
index 559d16cea3..545f4d3cc7 100644
--- a/tests/auto/quicktest/signalspy/tst_signalspy.cpp
+++ b/tests/auto/quicktest/signalspy/tst_signalspy.cpp
@@ -54,7 +54,7 @@ void tst_SignalSpy::testCount()
window.resize(200, 200);
window.setSource(url);
window.show();
- QVERIFY(QTest::qWaitForWindowActive(&window));
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
QVERIFY(window.rootObject() != nullptr);
QObject *mouseSpy = window.rootObject()->findChild<QObject *>("mouseSpy");
diff --git a/tests/auto/quickwidgets/qquickwidget/CMakeLists.txt b/tests/auto/quickwidgets/qquickwidget/CMakeLists.txt
index 24da087db5..5ce5cf3125 100644
--- a/tests/auto/quickwidgets/qquickwidget/CMakeLists.txt
+++ b/tests/auto/quickwidgets/qquickwidget/CMakeLists.txt
@@ -19,6 +19,7 @@ qt_internal_add_test(tst_qquickwidget
Qt::GuiPrivate
Qt::QmlPrivate
Qt::QuickPrivate
+ Qt::QuickTemplates2Private
Qt::QuickWidgets
Qt::QuickWidgetsPrivate
Qt::WidgetsPrivate
diff --git a/tests/auto/quickwidgets/qquickwidget/data/button.qml b/tests/auto/quickwidgets/qquickwidget/data/button.qml
new file mode 100644
index 0000000000..30698908d7
--- /dev/null
+++ b/tests/auto/quickwidgets/qquickwidget/data/button.qml
@@ -0,0 +1,27 @@
+import QtQuick
+import QtQuick.Controls.Basic
+
+Item {
+ width: 100
+ height: 100
+ visible: true
+
+ property bool wasPressed: false
+ property bool wasReleased: false
+ property bool wasClicked: false
+
+ Popup {
+ closePolicy: Popup.NoAutoClose
+ visible: true
+
+ Button {
+ objectName: "button"
+ text: "TAP ME"
+ anchors.fill: parent
+
+ onPressed: wasPressed = true
+ onReleased: wasReleased = true
+ onClicked: wasClicked = true
+ }
+ }
+}
diff --git a/tests/auto/quickwidgets/qquickwidget/data/mouse.qml b/tests/auto/quickwidgets/qquickwidget/data/mouse.qml
index 5d1c6e8443..25a7329a08 100644
--- a/tests/auto/quickwidgets/qquickwidget/data/mouse.qml
+++ b/tests/auto/quickwidgets/qquickwidget/data/mouse.qml
@@ -7,8 +7,10 @@ Rectangle {
property bool wasClicked: false
property bool wasDoubleClicked: false
property bool wasMoved: false
+ color: ma.pressed ? "wheat" : "lightsteelblue"
MouseArea {
+ id: ma
anchors.fill: parent
hoverEnabled: true
onClicked: wasClicked = true
diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
index fb86ef9e72..6ecf14fdff 100644
--- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
+++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
@@ -10,6 +10,8 @@
#include <QtQuick/qquickview.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquickmousearea_p.h>
+#include <QtQuickTemplates2/private/qquickbutton_p.h>
#include <QtQuickTestUtils/private/qmlutils_p.h>
#include <QtGui/QWindow>
#include <QtGui/QScreen>
@@ -123,6 +125,9 @@ private slots:
void mouseEventWindowPos();
void synthMouseFromTouch_data();
void synthMouseFromTouch();
+ void touchTapMouseArea();
+ void touchTapButton();
+ void touchMultipleWidgets();
void tabKey();
void resizeOverlay();
void controls();
@@ -340,7 +345,7 @@ void tst_qquickwidget::errors()
QQmlTestMessageHandler messageHandler;
view->setSource(testFileUrl("error1.qml"));
QCOMPARE(view->status(), QQuickWidget::Error);
- QCOMPARE(view->errors().count(), 1);
+ QCOMPARE(view->errors().size(), 1);
}
void tst_qquickwidget::engine()
@@ -613,13 +618,106 @@ void tst_qquickwidget::synthMouseFromTouch()
QTest::touchEvent(&window, device).move(0, p2, &window);
QTest::touchEvent(&window, device).release(0, p2, &window);
- QCOMPARE(item->m_touchEvents.count(), synthMouse ? 0 : (acceptTouch ? 3 : 1));
- QCOMPARE(item->m_mouseEvents.count(), synthMouse ? 3 : 0);
- QCOMPARE(childView->m_mouseEvents.count(), 0);
+ qCDebug(lcTests) << item->m_touchEvents << item->m_mouseEvents;
+ QCOMPARE(item->m_touchEvents.size(), synthMouse ? 0 : (acceptTouch ? 3 : 1));
+ QCOMPARE(item->m_mouseEvents.size(), synthMouse ? 3 : 0);
+ QCOMPARE(childView->m_mouseEvents.size(), 0);
for (const auto &ev : item->m_mouseEvents)
QCOMPARE(ev, Qt::MouseEventSynthesizedByQt);
}
+void tst_qquickwidget::touchTapMouseArea()
+{
+ QWidget window;
+ window.resize(100, 100);
+ window.setObjectName("window widget");
+ window.setAttribute(Qt::WA_AcceptTouchEvents);
+ QVERIFY(QCoreApplication::testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents));
+ QQuickWidget *quick = new QQuickWidget(&window);
+ quick->setSource(testFileUrl("mouse.qml"));
+ quick->move(50, 50);
+ quick->setObjectName("quick widget");
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QQuickItem *rootItem = quick->rootObject();
+ QVERIFY(rootItem);
+ QQuickMouseArea *ma = rootItem->findChild<QQuickMouseArea *>();
+ QVERIFY(ma);
+
+ QPoint p1 = QPoint(70, 70);
+ QTest::touchEvent(&window, device).press(0, p1, &window);
+ QTRY_COMPARE(ma->pressed(), true);
+ QTest::touchEvent(&window, device).move(0, p1, &window);
+ QTest::touchEvent(&window, device).release(0, p1, &window);
+ QTRY_COMPARE(ma->pressed(), false);
+ QVERIFY(rootItem->property("wasClicked").toBool());
+}
+
+void tst_qquickwidget::touchTapButton()
+{
+ QWidget window;
+ QQuickWidget *quick = new QQuickWidget;
+ quick->setSource(testFileUrl("button.qml"));
+
+ QHBoxLayout hbox;
+ hbox.addWidget(quick);
+ window.setLayout(&hbox);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ QQuickItem *rootItem = quick->rootObject();
+ QVERIFY(rootItem);
+ QQuickButton *button = rootItem->findChild<QQuickButton *>("button");
+ QVERIFY(button);
+
+ const QPoint point = quick->mapTo(&window, button->mapToScene(button->boundingRect().center()).toPoint());
+ QTest::touchEvent(&window, device).press(0, point, &window).commit();
+ QTRY_VERIFY(rootItem->property("wasPressed").toBool());
+ QTest::touchEvent(&window, device).release(0, point, &window).commit();
+ QTRY_VERIFY(rootItem->property("wasReleased").toBool());
+ QTRY_VERIFY(rootItem->property("wasClicked").toBool());
+}
+
+void tst_qquickwidget::touchMultipleWidgets()
+{
+ QWidget window;
+ QQuickWidget *leftQuick = new QQuickWidget;
+ leftQuick->setSource(testFileUrl("button.qml"));
+ QQuickWidget *rightQuick = new QQuickWidget;
+ rightQuick->setSource(testFileUrl("button.qml"));
+
+ QHBoxLayout hbox;
+ hbox.addWidget(leftQuick);
+ hbox.addWidget(rightQuick);
+ window.setLayout(&hbox);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ QQuickItem *leftRootItem = leftQuick->rootObject();
+ QQuickItem *rightRootItem = rightQuick->rootObject();
+ QVERIFY(leftRootItem);
+ QVERIFY(rightRootItem);
+ QQuickButton *leftButton = leftRootItem->findChild<QQuickButton *>("button");
+ QQuickButton *rightButton = rightRootItem->findChild<QQuickButton *>("button");
+ QVERIFY(leftButton);
+ QVERIFY(rightButton);
+
+ const QPoint leftPoint = leftQuick->mapTo(&window, leftButton->mapToScene(
+ leftButton->boundingRect().center()).toPoint());
+ const QPoint rightPoint = rightQuick->mapTo(&window, rightButton->mapToScene(
+ rightButton->boundingRect().center()).toPoint());
+ QTest::touchEvent(&window, device).press(0, leftPoint, &window).commit();
+ QTRY_VERIFY(leftRootItem->property("wasPressed").toBool());
+ QTest::touchEvent(&window, device).press(1, rightPoint, &window).commit();
+ QTRY_VERIFY(rightRootItem->property("wasPressed").toBool());
+ QTest::touchEvent(&window, device).release(1, rightPoint, &window).commit();
+ QTRY_VERIFY(rightRootItem->property("wasReleased").toBool());
+ QVERIFY(rightRootItem->property("wasClicked").toBool());
+ QTest::touchEvent(&window, device).release(0, leftPoint, &window).commit();
+ QTRY_VERIFY(leftRootItem->property("wasReleased").toBool());
+ QVERIFY(leftRootItem->property("wasClicked").toBool());
+}
+
void tst_qquickwidget::tabKey()
{
if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls)
diff --git a/tests/baseline/controls/tst_baseline_controls.cpp b/tests/baseline/controls/tst_baseline_controls.cpp
index 7e5833b786..1faed68311 100644
--- a/tests/baseline/controls/tst_baseline_controls.cpp
+++ b/tests/baseline/controls/tst_baseline_controls.cpp
@@ -182,9 +182,9 @@ void tst_Baseline_Controls::setupTestSuite()
if (testFiles.isEmpty())
QSKIP("No .qml test files found in " + testSuitePath.toLatin1());
- for (const auto &filePath : qAsConst(testFiles)) {
- QString itemName = filePath.sliced(testSuitePath.length() + 1);
- itemName = itemName.left(itemName.length() - qmlExt.length());
+ for (const auto &filePath : std::as_const(testFiles)) {
+ QString itemName = filePath.sliced(testSuitePath.size() + 1);
+ itemName = itemName.left(itemName.size() - qmlExt.size());
QBaselineTest::newRow(itemName.toLatin1()) << filePath;
}
}
diff --git a/tests/baseline/scenegraph/data/text/text_nativerendering_no_antialiasing.qml b/tests/baseline/scenegraph/data/text/text_nativerendering_no_antialiasing.qml
new file mode 100644
index 0000000000..92598eb490
--- /dev/null
+++ b/tests/baseline/scenegraph/data/text/text_nativerendering_no_antialiasing.qml
@@ -0,0 +1,25 @@
+import QtQuick 2.0
+
+//vary font style, native rendering without antialiasing
+
+Item {
+ id: topLevel
+ width: 320
+ height: 580
+
+ Repeater {
+ model: [Text.Normal, Text.Outline, Text.Raised, Text.Sunken]
+ Text {
+ y: 20 * index
+ clip: true
+ renderType: Text.NativeRendering
+ width: parent.width
+ wrapMode: Text.Wrap
+ font.pointSize: 10
+ style: modelData
+ styleColor: "green"
+ antialiasing: false
+ text: "The quick fox jumps in style " + modelData
+ }
+ }
+}
diff --git a/tests/baseline/scenegraph/scenegraph/tst_baseline_scenegraph.cpp b/tests/baseline/scenegraph/scenegraph/tst_baseline_scenegraph.cpp
index fe8eb66ce9..124580f3b6 100644
--- a/tests/baseline/scenegraph/scenegraph/tst_baseline_scenegraph.cpp
+++ b/tests/baseline/scenegraph/scenegraph/tst_baseline_scenegraph.cpp
@@ -159,15 +159,15 @@ void tst_Scenegraph::setupTestSuite(const QByteArray& filter)
while (it.hasNext()) {
QString fp = it.next();
if (fp.endsWith(".qml")) {
- QString itemName = fp.mid(testSuitePath.length() + 1);
+ QString itemName = fp.mid(testSuitePath.size() + 1);
if (!ignoreItems.contains(itemName) && (filter.isEmpty() || !itemName.startsWith(filter)))
itemFiles.append(it.filePath());
}
}
std::sort(itemFiles.begin(), itemFiles.end());
- for (const QString &filePath : qAsConst(itemFiles)) {
- QByteArray itemName = filePath.mid(testSuitePath.length() + 1).toLatin1();
+ for (const QString &filePath : std::as_const(itemFiles)) {
+ QByteArray itemName = filePath.mid(testSuitePath.size() + 1).toLatin1();
QBaselineTest::newRow(itemName, checksumFileOrDir(filePath)) << filePath;
numItems++;
}
diff --git a/tests/benchmarks/particles/affectors/tst_affectors.cpp b/tests/benchmarks/particles/affectors/tst_affectors.cpp
index abce304f9a..172d986186 100644
--- a/tests/benchmarks/particles/affectors/tst_affectors.cpp
+++ b/tests/benchmarks/particles/affectors/tst_affectors.cpp
@@ -66,7 +66,7 @@ void tst_affectors::test_basic()
int stillAlive = 0;
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 1000, 10));//Small simulation variance is permissible.
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -106,7 +106,7 @@ void tst_affectors::test_filtered()
int stillAlive = 0;
QVERIFY(extremelyFuzzyCompare(system->groupData[1]->size(), 1000, 10));//Small simulation variance is permissible.
- for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/benchmarks/particles/emission/tst_emission.cpp b/tests/benchmarks/particles/emission/tst_emission.cpp
index 155e2c6cff..875906ad45 100644
--- a/tests/benchmarks/particles/emission/tst_emission.cpp
+++ b/tests/benchmarks/particles/emission/tst_emission.cpp
@@ -54,7 +54,7 @@ void tst_emission::test_basic()
int stillAlive = 0;
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 1000, 10));//Small simulation variance is permissible.
- for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
+ for (QQuickParticleData *d : std::as_const(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp b/tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp
index c4400f4d1b..f64a44d66a 100644
--- a/tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp
+++ b/tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp
@@ -239,7 +239,7 @@ void tst_librarymetrics_performance::compilation()
if (nResults.size() == 0) nResults.append(9999);
for (int i = 0; i < nResults.size(); ++i)
totaltime += nResults.at(i);
- double average = ((double)totaltime) / nResults.count();
+ double average = ((double)totaltime) / nResults.size();
// and return it as the result
QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds);
@@ -288,7 +288,7 @@ void tst_librarymetrics_performance::instantiation_cached()
if (nResults.size() == 0) nResults.append(9999);
for (int i = 0; i < nResults.size(); ++i)
totaltime += nResults.at(i);
- double average = ((double)totaltime) / nResults.count();
+ double average = ((double)totaltime) / nResults.size();
// and return it as the result
QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds);
@@ -345,7 +345,7 @@ void tst_librarymetrics_performance::instantiation()
if (nResults.size() == 0) nResults.append(9999);
for (int i = 0; i < nResults.size(); ++i)
totaltime += nResults.at(i);
- double average = ((double)totaltime) / nResults.count();
+ double average = ((double)totaltime) / nResults.size();
// and return it as the result
QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds);
@@ -411,7 +411,7 @@ void tst_librarymetrics_performance::positioners()
if (nResults.size() == 0) nResults.append(9999);
for (int i = 0; i < nResults.size(); ++i)
totaltime += nResults.at(i);
- double average = ((double)totaltime) / nResults.count();
+ double average = ((double)totaltime) / nResults.size();
// and return it as the result
QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds);
diff --git a/tests/benchmarks/qml/qqmlchangeset/CMakeLists.txt b/tests/benchmarks/qml/qqmlchangeset/CMakeLists.txt
index 2d6461eefd..ee61a372af 100644
--- a/tests/benchmarks/qml/qqmlchangeset/CMakeLists.txt
+++ b/tests/benchmarks/qml/qqmlchangeset/CMakeLists.txt
@@ -1,10 +1,10 @@
# Generated from qqmlchangeset.pro.
#####################################################################
-## tst_qqmlchangeset Binary:
+## tst_bench_qqmlchangeset Binary:
#####################################################################
-qt_internal_add_benchmark(tst_qqmlchangeset
+qt_internal_add_benchmark(tst_bench_qqmlchangeset
SOURCES
tst_qqmlchangeset.cpp
DEFINES
diff --git a/tests/benchmarks/quickcontrols2/creationtime/CMakeLists.txt b/tests/benchmarks/quickcontrols2/creationtime/CMakeLists.txt
index 9e3a6d58c1..ad39b3ea0b 100644
--- a/tests/benchmarks/quickcontrols2/creationtime/CMakeLists.txt
+++ b/tests/benchmarks/quickcontrols2/creationtime/CMakeLists.txt
@@ -1,5 +1,11 @@
# Generated from creationtime.pro.
+if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_creationtime LANGUAGES C CXX ASM)
+ find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST)
+endif()
+
#####################################################################
## tst_creationtime Test:
#####################################################################
diff --git a/tests/benchmarks/quickcontrols2/creationtime/tst_creationtime.cpp b/tests/benchmarks/quickcontrols2/creationtime/tst_creationtime.cpp
index 2e37d00dd8..82259269d9 100644
--- a/tests/benchmarks/quickcontrols2/creationtime/tst_creationtime.cpp
+++ b/tests/benchmarks/quickcontrols2/creationtime/tst_creationtime.cpp
@@ -57,7 +57,7 @@ static void doBenchmark(QQuickStyleHelper &styleHelper, const QUrl &url)
QCOMPARE(styleAndFileName.size(), 2);
QString style = styleAndFileName.first();
style[0] = style.at(0).toUpper();
- styleHelper.updateStyle(style);
+ QVERIFY(styleHelper.updateStyle(style));
QQmlComponent component(styleHelper.engine.data());
component.loadUrl(url);
@@ -98,7 +98,7 @@ void tst_CreationTime::fusion_data()
QTest::addColumn<QUrl>("url");
addTestRowForEachControl(styleHelper.engine.data(), QQC2_IMPORT_PATH, "fusion", "QtQuick/Controls/Fusion",
QStringList() << "ApplicationWindow" << "ButtonPanel" << "CheckIndicator"
- << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator");
+ << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator" << "TreeViewDelegate");
}
void tst_CreationTime::imagine()
@@ -125,7 +125,7 @@ void tst_CreationTime::material_data()
QTest::addColumn<QUrl>("url");
addTestRowForEachControl(styleHelper.engine.data(), QQC2_IMPORT_PATH, "material", "QtQuick/Controls/Material",
QStringList() << "ApplicationWindow" << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator"
- << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate");
+ << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate" << "TreeViewDelegate");
}
void tst_CreationTime::universal()
diff --git a/tests/benchmarks/quickcontrols2/objectcount/CMakeLists.txt b/tests/benchmarks/quickcontrols2/objectcount/CMakeLists.txt
index 752230ec7e..e0434a08eb 100644
--- a/tests/benchmarks/quickcontrols2/objectcount/CMakeLists.txt
+++ b/tests/benchmarks/quickcontrols2/objectcount/CMakeLists.txt
@@ -1,5 +1,11 @@
# Generated from objectcount.pro.
+if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_objectcount LANGUAGES C CXX ASM)
+ find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST)
+endif()
+
#####################################################################
## tst_objectcount Test:
#####################################################################
diff --git a/tests/benchmarks/quickcontrols2/objectcount/tst_objectcount.cpp b/tests/benchmarks/quickcontrols2/objectcount/tst_objectcount.cpp
index aad8e7d571..e1d37eec8f 100644
--- a/tests/benchmarks/quickcontrols2/objectcount/tst_objectcount.cpp
+++ b/tests/benchmarks/quickcontrols2/objectcount/tst_objectcount.cpp
@@ -67,11 +67,12 @@ static void initTestRows(QQmlEngine *engine)
addTestRowForEachControl(engine, QQC2_IMPORT_PATH, "basic", "QtQuick/Controls/Basic",
QStringList() << "Calendar" << "TreeViewDelegate");
addTestRowForEachControl(engine, QQC2_IMPORT_PATH, "fusion", "QtQuick/Controls/Fusion",
- QStringList() << "ButtonPanel" << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator");
+ QStringList() << "ButtonPanel" << "CheckIndicator" << "RadioIndicator" << "SliderGroove"
+ << "SliderHandle" << "SwitchIndicator" << "TreeViewDelegate");
addTestRowForEachControl(engine, QQC2_IMPORT_PATH, "imagine", "QtQuick/Controls/Imagine");
addTestRowForEachControl(engine, QQC2_IMPORT_PATH, "material", "QtQuick/Controls/Material",
QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator"
- << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate");
+ << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate" << "TreeViewDelegate");
addTestRowForEachControl(engine, QQC2_IMPORT_PATH, "universal", "QtQuick/Controls/Universal",
QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator");
}
@@ -88,7 +89,7 @@ static void doBenchmark(QQmlEngine *engine, const QUrl &url)
QVERIFY2(object.data(), qPrintable(component.errorString()));
QObjectList objects;
- for (QObject *object : qAsConst(*qt_qobjects())) {
+ for (QObject *object : std::as_const(*qt_qobjects())) {
if (qobject_cast<T *>(object))
objects += object;
}
@@ -98,7 +99,7 @@ static void doBenchmark(QQmlEngine *engine, const QUrl &url)
qInfo() << "\t" << object;
}
- QTest::setBenchmarkResult(objects.count(), QTest::Events);
+ QTest::setBenchmarkResult(objects.size(), QTest::Events);
}
void tst_ObjectCount::qobjects()
diff --git a/tests/manual/pointer/pinchNullTarget.qml b/tests/manual/pointer/pinchNullTarget.qml
new file mode 100644
index 0000000000..79c6047991
--- /dev/null
+++ b/tests/manual/pointer/pinchNullTarget.qml
@@ -0,0 +1,50 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick 2.15
+
+Rectangle {
+ width: 1024; height: 600
+ color: "#eee"
+
+ function getTransformationDetails(item, pinchhandler) {
+ return "\n\npinch.scale:" + pinchhandler.scale.toFixed(2)
+ + "\npinch.activeScale:" + pinchhandler.activeScale.toFixed(2)
+ + "\npinch.rotation:" + pinchhandler.rotation.toFixed(2)
+ + "\npinch.translation:" + "(" + pinchhandler.translation.x.toFixed(2) + "," + pinchhandler.translation.y.toFixed(2) + ")"
+ + "\nrect.scale: " + item.scale.toFixed(2)
+ + "\nrect.rotation: " + item.rotation.toFixed(2)
+ + "\nrect.position: " + "(" + item.x.toFixed(2) + "," + item.y.toFixed(2) + ")"
+ }
+
+ Rectangle {
+ width: parent.width - 100; height: parent.height - 100; x: 50; y: 50
+ color: "lightsteelblue"
+ antialiasing: true
+ scale: pinch.scale
+
+ PinchHandler {
+ id: pinch
+ target: null
+ minimumScale: 0.5
+ maximumScale: 3
+ }
+
+ Text {
+ text: "Pinch with 2 fingers to scale, rotate and translate"
+ + getTransformationDetails(parent, pinch)
+ }
+ }
+
+ Rectangle {
+ id: centroidIndicator
+ x: pinch.centroid.scenePosition.x - radius
+ y: pinch.centroid.scenePosition.y - radius
+ z: 1
+ visible: pinch.active
+ radius: width / 2
+ width: 10
+ height: width
+ color: "red"
+ }
+}
diff --git a/tests/manual/quickcontrols2/headerview/main.qml b/tests/manual/quickcontrols2/headerview/main.qml
index f8504b9f7f..89367d91bf 100644
--- a/tests/manual/quickcontrols2/headerview/main.qml
+++ b/tests/manual/quickcontrols2/headerview/main.qml
@@ -14,6 +14,7 @@ Window {
width: 640
height: 480
title: qsTr("HeaderView Test")
+ color: Qt.styleHints.appearance === Qt.Light ? palette.mid : palette.midlight
TestTableModelWithHeader {
id: tableModel
@@ -30,8 +31,8 @@ Window {
model: tableModel
rightMargin: 100
bottomMargin: 100
- columnSpacing: 4
- rowSpacing: 4
+ columnSpacing: 1
+ rowSpacing: 1
syncDirection: Qt.Vertical | Qt.Horizontal
implicitWidth: parent.width + columnSpacing
implicitHeight: parent.height + rowSpacing
@@ -39,7 +40,7 @@ Window {
delegate: Rectangle {
implicitWidth: 150
implicitHeight: 50
- color: "#e6ecf5"
+ color: tableView.palette.base
CheckBox {
anchors.fill: parent
@@ -68,12 +69,17 @@ Window {
clip: true
}
- ToolButton {
+ Rectangle {
width: verticalHeader.width
height: horizontalHeader.height
- onClicked: {
- horizontalHeader.contentX = 0
- verticalHeader.contentY = 0
+ color: palette.base
+ ToolButton {
+ anchors.fill: parent
+ text: "<<"
+ onClicked: {
+ horizontalHeader.contentX = 0
+ verticalHeader.contentY = 0
+ }
}
}
}
diff --git a/tests/manual/quickcontrols2/testbench/controls/Button.qml b/tests/manual/quickcontrols2/testbench/controls/Button.qml
index 5c0b67d2b6..1dcf05da36 100644
--- a/tests/manual/quickcontrols2/testbench/controls/Button.qml
+++ b/tests/manual/quickcontrols2/testbench/controls/Button.qml
@@ -9,25 +9,47 @@ QtObject {
[],
["disabled"],
["pressed"],
- ["checked"],
- ["checked", "disabled"],
- ["checked"],
+ ["checkable", "checked"],
+ ["checkable", "checked", "disabled"],
+ ["checkable", "checked"],
["highlighted"],
["highlighted", "disabled"],
["highlighted", "pressed"],
- ["highlighted", "checked"],
+ ["highlighted", "checkable"],
["highlighted", "checkable", "pressed"],
["highlighted", "checkable", "checked"],
+ ["icon"],
+ ["icon", "disabled"],
+ ["icon", "pressed"],
+ ["icon", "checkable", "checked"],
+ ["icon", "checkable", "checked", "disabled"],
+ ["icon", "checkable", "checked"],
+ ["icon", "highlighted"],
+ ["icon", "highlighted", "disabled"],
+ ["icon", "highlighted", "pressed"],
+ ["icon", "highlighted", "checkable"],
+ ["icon", "highlighted", "checkable", "pressed"],
+ ["icon", "highlighted", "checkable", "checked"],
["flat"],
["flat", "disabled"],
["flat", "pressed"],
- ["flat", "checked"],
["flat", "checkable"],
+ ["flat", "checkable", "checked"],
["flat", "checkable", "pressed"],
["flat", "checkable", "checked", "pressed"],
["flat", "checkable", "highlighted"],
["flat", "checkable", "highlighted", "pressed"],
- ["flat", "checkable", "highlighted", "checked"]
+ ["flat", "checkable", "highlighted", "checked"],
+ ["icon", "flat"],
+ ["icon", "flat", "disabled"],
+ ["icon", "flat", "pressed"],
+ ["icon", "flat", "checkable"],
+ ["icon", "flat", "checkable", "checked"],
+ ["icon", "flat", "checkable", "pressed"],
+ ["icon", "flat", "checkable", "checked", "pressed"],
+ ["icon", "flat", "checkable", "highlighted"],
+ ["icon", "flat", "checkable", "highlighted", "pressed"],
+ ["icon", "flat", "checkable", "highlighted", "checked"]
]
property Component component: Button {
@@ -39,5 +61,6 @@ QtObject {
// Only set it if it's pressed, or the non-pressed examples will have no press effects
down: is("pressed") ? true : undefined
highlighted: is("highlighted")
+ icon.source: is("icon") ? "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png" : ""
}
}
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 51adb49aa8..9ad2abe781 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -236,7 +236,7 @@ public Q_SLOTS:
if (o) {
checkForWindow(o);
if (conf && qae)
- for (PartialScene *ps : qAsConst(conf->completers))
+ for (PartialScene *ps : std::as_const(conf->completers))
if (o->inherits(ps->itemType().toUtf8().constData()))
contain(o, ps->container());
}
@@ -364,7 +364,7 @@ static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory)
if (dummyData && !quietMode) {
printf("qml: Loaded dummy data: %s\n", qPrintable(dir.filePath(qml)));
- qml.truncate(qml.length()-4);
+ qml.truncate(qml.size()-4);
engine.rootContext()->setContextProperty(qml, dummyData);
dummyData->setParent(&engine);
}
@@ -586,7 +586,7 @@ int main(int argc, char *argv[])
QLoggingCategory::setFilterRules(QStringLiteral("*=false"));
}
- if (files.count() <= 0) {
+ if (files.size() <= 0) {
#if defined(Q_OS_DARWIN) && defined(QT_GUI_LIB)
if (applicationType == QmlApplicationTypeGui)
exitTimerId = static_cast<LoaderApplication *>(app.get())->startTimer(FILE_OPEN_EVENT_WAIT_TIME);
@@ -599,7 +599,7 @@ int main(int argc, char *argv[])
loadConf(confFile, !verboseMode);
// Load files
- QScopedPointer<LoadWatcher> lw(new LoadWatcher(&e, files.count()));
+ QScopedPointer<LoadWatcher> lw(new LoadWatcher(&e, files.size()));
#if QT_DEPRECATED_SINCE(6, 3)
QString dummyDir;
@@ -612,7 +612,7 @@ int main(int argc, char *argv[])
}
#endif
- for (const QString &path : qAsConst(files)) {
+ for (const QString &path : std::as_const(files)) {
QUrl url = QUrl::fromUserInput(path, QDir::currentPath(), QUrl::AssumeLocalFile);
if (verboseMode)
printf("qml: loading %s\n", qPrintable(url.toString()));
diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp
index f3fc06bec5..141c010272 100644
--- a/tools/qmlcachegen/qmlcachegen.cpp
+++ b/tools/qmlcachegen/qmlcachegen.cpp
@@ -66,6 +66,8 @@ int main(int argc, char **argv)
parser.addHelpOption();
parser.addVersionOption();
+ QCommandLineOption bareOption(QStringLiteral("bare"), QCoreApplication::translate("main", "Do not include default import directories. This may be used to run qmlcachegen on a project using a different Qt version."));
+ parser.addOption(bareOption);
QCommandLineOption filterResourceFileOption(QStringLiteral("filter-resource-file"), QCoreApplication::translate("main", "Filter out QML/JS files from a resource file that can be cached ahead of time instead"));
parser.addOption(filterResourceFileOption);
QCommandLineOption resourceFileMappingOption(QStringLiteral("resource-file-mapping"), QCoreApplication::translate("main", "Path from original resource file to new one"), QCoreApplication::translate("main", "old-name=new-name"));
@@ -234,7 +236,8 @@ int main(int argc, char **argv)
if (parser.isSet(importPathOption))
importPaths = parser.values(importPathOption);
- importPaths.append(QLibraryInfo::path(QLibraryInfo::QmlImportsPath));
+ if (!parser.isSet(bareOption))
+ importPaths.append(QLibraryInfo::path(QLibraryInfo::QmlImportsPath));
QQmlJSImporter importer(
importPaths, parser.isSet(resourceOption) ? &fileMapper : nullptr);
@@ -243,6 +246,7 @@ int main(int argc, char **argv)
// Always trigger the qFatal() on "pragma Strict" violations.
logger.setCategoryLevel(Log_Compiler, QtCriticalMsg);
logger.setCategoryIgnored(Log_Compiler, false);
+ logger.setCategoryFatal(Log_Compiler, true);
// By default, we're completely silent,
// as the lcAotCompiler category default is QtFatalMsg
diff --git a/tools/qmlcachegen/qtquickcompiler.prf b/tools/qmlcachegen/qtquickcompiler.prf
index 262ed08785..b7413a3de3 100644
--- a/tools/qmlcachegen/qtquickcompiler.prf
+++ b/tools/qmlcachegen/qtquickcompiler.prf
@@ -77,6 +77,7 @@ for(res, QMLCACHE_RESOURCE_FILES) {
defineReplace(qmlCacheOutputName) {
name = $$absolute_path($$1, $$OUT_PWD)
name = $$relative_path($$name, $$_PRO_FILE_PWD_)
+ contains(name, ^\\.\\..*): name = $$relative_path($$1, $$OUT_PWD)
name = $$replace(name, \\.qml$, _qml)
name = $$replace(name, \\.js$, _js)
name = $$replace(name, \\.mjs$, _mjs)
diff --git a/tools/qmldom/qmldomtool.cpp b/tools/qmldom/qmldomtool.cpp
index 1e8de35f5d..badf1917f9 100644
--- a/tools/qmldom/qmldomtool.cpp
+++ b/tools/qmldom/qmldomtool.cpp
@@ -188,10 +188,10 @@ int main(int argc, char *argv[])
{
QDebug dbg = qDebug();
dbg << "dirs:\n";
- for (const QString &d : qAsConst(qmltypeDirs))
+ for (const QString &d : std::as_const(qmltypeDirs))
dbg << " '" << d << "'\n";
dbg << "files:\n";
- for (const QString &f : qAsConst(positionalArguments))
+ for (const QString &f : std::as_const(positionalArguments))
dbg << " '" << f << "'\n";
dbg << "fieldFilter: " << filter.describeFieldsFilter();
dbg << "\n";
@@ -206,7 +206,7 @@ int main(int argc, char *argv[])
env.loadBuiltins();
QList<DomItem> loadedFiles(positionalArguments.size());
qsizetype iPos = 0;
- for (const QString &s : qAsConst(positionalArguments)) {
+ for (const QString &s : std::as_const(positionalArguments)) {
env.loadFile(
s, QString(),
[&loadedFiles, iPos](Path, const DomItem &, const DomItem &newIt) {
diff --git a/tools/qmleasing/splineeditor.cpp b/tools/qmleasing/splineeditor.cpp
index 4dd725afbc..dc71adafa4 100644
--- a/tools/qmleasing/splineeditor.cpp
+++ b/tools/qmleasing/splineeditor.cpp
@@ -169,7 +169,7 @@ void SplineEditor::paintEvent(QPaintEvent *)
paintControlPoint(QPointF(0.0, 0.0), &painter, false, true, false, false);
paintControlPoint(QPointF(1.0, 1.0), &painter, false, true, false, false);
- for (int i = 0; i < m_controlPoints.count() - 1; ++i)
+ for (int i = 0; i < m_controlPoints.size() - 1; ++i)
paintControlPoint(m_controlPoints.at(i),
&painter,
true,
@@ -265,7 +265,7 @@ QHash<QString, QEasingCurve> SplineEditor::presets() const
QString SplineEditor::generateCode()
{
QString s = QLatin1String("[");
- for (const QPointF &point : qAsConst(m_controlPoints)) {
+ for (const QPointF &point : std::as_const(m_controlPoints)) {
s += QString::number(point.x(), 'g', 2) + QLatin1Char(',')
+ QString::number(point.y(), 'g', 3) + QLatin1Char(',');
}
@@ -344,7 +344,7 @@ void SplineEditor::smoothPoint(int index)
before = m_controlPoints.at(index - 3);
QPointF after = QPointF(1.0, 1.0);
- if ((index + 3) < m_controlPoints.count())
+ if ((index + 3) < m_controlPoints.size())
after = m_controlPoints.at(index + 3);
QPointF tangent = (after - before) / 6;
@@ -354,7 +354,7 @@ void SplineEditor::smoothPoint(int index)
if (index > 0)
m_controlPoints[index - 1] = thisPoint - tangent;
- if (index + 1 < m_controlPoints.count())
+ if (index + 1 < m_controlPoints.size())
m_controlPoints[index + 1] = thisPoint + tangent;
m_smoothList[index / 3] = true;
@@ -372,7 +372,7 @@ void SplineEditor::cornerPoint(int index)
before = m_controlPoints.at(index - 3);
QPointF after = QPointF(1.0, 1.0);
- if ((index + 3) < m_controlPoints.count())
+ if ((index + 3) < m_controlPoints.size())
after = m_controlPoints.at(index + 3);
QPointF thisPoint = m_controlPoints.at(index);
@@ -380,7 +380,7 @@ void SplineEditor::cornerPoint(int index)
if (index > 0)
m_controlPoints[index - 1] = (before - thisPoint) / 3 + thisPoint;
- if (index + 1 < m_controlPoints.count())
+ if (index + 1 < m_controlPoints.size())
m_controlPoints[index + 1] = (after - thisPoint) / 3 + thisPoint;
m_smoothList[(index) / 3] = false;
@@ -412,7 +412,7 @@ void SplineEditor::addPoint(const QPointF point)
before = m_controlPoints.at(splitIndex);
QPointF after = QPointF(1.0, 1.0);
- if ((splitIndex + 3) < m_controlPoints.count())
+ if ((splitIndex + 3) < m_controlPoints.size())
after = m_controlPoints.at(splitIndex + 3);
if (splitIndex > 0) {
@@ -541,7 +541,7 @@ bool SplineEditor::isControlPointSmooth(int i) const
if (i == 0)
return false;
- if (i == m_controlPoints.count() - 1)
+ if (i == m_controlPoints.size() - 1)
return false;
if (m_numberOfSegments == 1)
@@ -552,7 +552,7 @@ bool SplineEditor::isControlPointSmooth(int i) const
if (index == 0)
return false;
- if (index == m_controlPoints.count() - 1)
+ if (index == m_controlPoints.size() - 1)
return false;
return m_smoothList.at(index / 3);
@@ -611,7 +611,7 @@ void SplineEditor::mouseMoveEvent(QMouseEvent *e)
if ((m_activeControlPoint > 1) && (m_activeControlPoint % 3) == 0) { //right control point
m_controlPoints[m_activeControlPoint - 2] -= distance;
- } else if ((m_activeControlPoint < (m_controlPoints.count() - 2)) //left control point
+ } else if ((m_activeControlPoint < (m_controlPoints.size() - 2)) //left control point
&& (m_activeControlPoint % 3) == 1) {
m_controlPoints[m_activeControlPoint + 2] -= distance;
}
@@ -628,7 +628,7 @@ void SplineEditor::setEasingCurve(const QEasingCurve &easingCurve)
m_block = true;
m_easingCurve = easingCurve;
m_controlPoints = m_easingCurve.toCubicSpline();
- m_numberOfSegments = m_controlPoints.count() / 3;
+ m_numberOfSegments = m_controlPoints.size() / 3;
update();
emit easingCurveChanged();
@@ -652,9 +652,9 @@ void SplineEditor::setEasingCurve(const QString &code)
if (code.startsWith(QLatin1Char('[')) && code.endsWith(QLatin1Char(']'))) {
const auto cleanCode = QStringView(code).mid(1, code.size() - 2);
const auto stringList = cleanCode.split(QLatin1Char(','), Qt::SkipEmptyParts);
- if (stringList.count() >= 6 && (stringList.count() % 6 == 0)) {
+ if (stringList.size() >= 6 && (stringList.size() % 6 == 0)) {
QVector<qreal> realList;
- realList.reserve(stringList.count());
+ realList.reserve(stringList.size());
for (const QStringView &string : stringList) {
bool ok;
realList.append(string.toDouble(&ok));
@@ -662,14 +662,14 @@ void SplineEditor::setEasingCurve(const QString &code)
return;
}
QVector<QPointF> points;
- const int count = realList.count() / 2;
+ const int count = realList.size() / 2;
points.reserve(count);
for (int i = 0; i < count; ++i)
points.append(QPointF(realList.at(i * 2), realList.at(i * 2 + 1)));
if (points.constLast() == QPointF(1.0, 1.0)) {
QEasingCurve easingCurve(QEasingCurve::BezierSpline);
- for (int i = 0; i < points.count() / 3; ++i) {
+ for (int i = 0; i < points.size() / 3; ++i) {
easingCurve.addCubicBezierSegment(points.at(i * 3),
points.at(i * 3 + 1),
points.at(i * 3 + 2));
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp
index 820a3987c2..18e784a658 100644
--- a/tools/qmlimportscanner/main.cpp
+++ b/tools/qmlimportscanner/main.cpp
@@ -281,7 +281,7 @@ QPair<QString, QString> resolveImportPath(const QString &uri, const QString &ver
QString ver = version;
QPair<QString, QString> candidate;
while (true) {
- for (const QString &qmlImportPath : qAsConst(g_qmlImportPaths)) {
+ for (const QString &qmlImportPath : std::as_const(g_qmlImportPaths)) {
// Search for the most specific version first, and search
// also for the version in parent modules. For example:
// - qml/QtQml/Models.2.0
@@ -940,8 +940,12 @@ int main(int argc, char *argv[])
std::cerr << qPrintable(appName) << ": No such file or directory: \""
<< qPrintable(arg) << "\"\n";
return 1;
- } else {
+ } else if (argReceiver) {
*argReceiver += arg;
+ } else {
+ std::cerr << qPrintable(appName) << ": Invalid argument: \""
+ << qPrintable(arg) << "\"\n";
+ return 1;
}
}
}
diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp
index 69f6b15299..c874caf752 100644
--- a/tools/qmljs/qmljs.cpp
+++ b/tools/qmljs/qmljs.cpp
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
QV4::GlobalExtensions::init(vm.globalObject, QJSEngine::ConsoleExtension | QJSEngine::GarbageCollectionExtension);
- for (const QString &fn : qAsConst(args)) {
+ for (const QString &fn : std::as_const(args)) {
QV4::ScopedValue result(scope);
if (runAsModule) {
auto moduleUnit = vm.loadModule(QUrl::fromLocalFile(QFileInfo(fn).absoluteFilePath()));
diff --git a/tools/qmljsrootgen/main.cpp b/tools/qmljsrootgen/main.cpp
index 921185b879..aeea1dcded 100644
--- a/tools/qmljsrootgen/main.cpp
+++ b/tools/qmljsrootgen/main.cpp
@@ -357,7 +357,7 @@ int main(int argc, char *argv[])
QStringList args = app.arguments();
- if (args.length() != 2) {
+ if (args.size() != 2) {
qWarning().noquote() << app.applicationName() << "[output json path]";
return 1;
}
diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp
index 6171d92360..3193a6d807 100644
--- a/tools/qmllint/main.cpp
+++ b/tools/qmllint/main.cpp
@@ -66,7 +66,8 @@ All warnings can be set to three levels:
parser.addOption(silentOption);
QCommandLineOption jsonOption(QStringList() << "json",
- QLatin1String("Write output as JSON to file"),
+ QLatin1String("Write output as JSON to file (or use the special "
+ "filename '-' to write to stdout)"),
QLatin1String("file"), QString());
parser.addOption(jsonOption);
diff --git a/tools/qmlls/qlanguageserver.cpp b/tools/qmlls/qlanguageserver.cpp
index 70cbd354b0..4f9c9fe77d 100644
--- a/tools/qmlls/qlanguageserver.cpp
+++ b/tools/qmlls/qlanguageserver.cpp
@@ -203,7 +203,7 @@ void QLanguageServer::setupCapabilities(const QLspSpecification::InitializeParam
QLspSpecification::InitializeResult &serverInfo)
{
Q_D(QLanguageServer);
- for (auto module : qAsConst(d->modules))
+ for (auto module : std::as_const(d->modules))
module->setupCapabilities(clientInfo, serverInfo);
}
diff --git a/tools/qmlls/qmlcompletionsupport.cpp b/tools/qmlls/qmlcompletionsupport.cpp
index f599787af4..0788174532 100644
--- a/tools/qmlls/qmlcompletionsupport.cpp
+++ b/tools/qmlls/qmlcompletionsupport.cpp
@@ -132,19 +132,19 @@ static qsizetype posAfterLineChar(QString code, int line, int character)
{
int targetLine = line;
qsizetype i = 0;
- while (i != code.length() && targetLine != 0) {
+ while (i != code.size() && targetLine != 0) {
QChar c = code.at(i++);
if (c == u'\n') {
--targetLine;
}
if (c == u'\r') {
- if (i != code.length() && code.at(i) == u'\n')
+ if (i != code.size() && code.at(i) == u'\n')
++i;
--targetLine;
}
}
qsizetype leftChars = character;
- while (i != code.length() && leftChars) {
+ while (i != code.size() && leftChars) {
QChar c = code.at(i);
if (c == u'\n' || c == u'\r')
break;
@@ -301,7 +301,7 @@ static QList<CompletionItem> importCompletions(DomItem &file, const CompletionCo
ImportCompletionType importCompletionType = ImportCompletionType::None;
QRegularExpression spaceRe(uR"(\W+)"_s);
QList<QStringView> linePieces = ctx.preLine().split(spaceRe, Qt::SkipEmptyParts);
- qsizetype effectiveLength = linePieces.length()
+ qsizetype effectiveLength = linePieces.size()
+ ((!ctx.preLine().isEmpty() && ctx.preLine().last().isSpace()) ? 1 : 0);
if (effectiveLength < 2) {
CompletionItem comp;
@@ -333,7 +333,7 @@ static QList<CompletionItem> importCompletions(DomItem &file, const CompletionCo
for (const QString &uri : envPtr->moduleIndexUris(env)) {
QStringView base = ctx.base(); // if we allow spaces we should get rid of them
if (uri.startsWith(base)) {
- QStringList rest = uri.mid(base.length()).split(u'.');
+ QStringList rest = uri.mid(base.size()).split(u'.');
if (rest.isEmpty())
continue;
CompletionItem comp;
@@ -356,7 +356,7 @@ static QList<CompletionItem> importCompletions(DomItem &file, const CompletionCo
bool hasMajorVersion = ctx.base().endsWith(u'.');
int majorV = -1;
if (hasMajorVersion)
- majorV = ctx.base().mid(0, ctx.base().length() - 1).toInt(&hasMajorVersion);
+ majorV = ctx.base().mid(0, ctx.base().size() - 1).toInt(&hasMajorVersion);
if (!hasMajorVersion)
break;
if (std::shared_ptr<ModuleIndex> mIndex =
@@ -468,7 +468,7 @@ static QList<CompletionItem> reachableSymbols(DomItem &context, const Completion
QString label = it.key() + u"(";
QString doc = it.key() + u"(";
bool first = true;
- for (const MethodParameter &pInfo : qAsConst(it->parameters)) {
+ for (const MethodParameter &pInfo : std::as_const(it->parameters)) {
if (first)
first = false;
else {
@@ -559,7 +559,7 @@ QList<CompletionItem> CompletionRequest::completions(QmlLsp::OpenDocumentSnapsho
QList<ItemLocation> itemsFound =
findLastItemsContaining(file, completionParams.position.line,
completionParams.position.character - ctx.filterChars().size());
- if (itemsFound.length() > 1) {
+ if (itemsFound.size() > 1) {
QStringList paths;
for (auto &it : itemsFound)
paths.append(it.domItem.canonicalPath().toString());
diff --git a/tools/qmlls/qmllanguageservertool.cpp b/tools/qmlls/qmllanguageservertool.cpp
index 82f0dedbf3..086515256a 100644
--- a/tools/qmlls/qmllanguageservertool.cpp
+++ b/tools/qmlls/qmllanguageservertool.cpp
@@ -18,6 +18,8 @@
#include <QtCore/qthreadpool.h>
#include <QtCore/qtimer.h>
+#include <QtJsonRpc/private/qhttpmessagestreamparser_p.h>
+
#include <QtQmlCompiler/private/qqmljsresourcefilemapper_p.h>
#include <QtQmlCompiler/private/qqmljscompiler_p.h>
#include <QtQmlCompiler/private/qqmljslogger_p.h>
@@ -31,8 +33,6 @@
# include <QtCore/qlibraryinfo.h>
#endif
-#include "qlanguageserver_p.h"
-
#include <iostream>
#ifdef Q_OS_WIN32
# include <fcntl.h>
@@ -51,12 +51,40 @@ public:
void run()
{
auto guard = qScopeGuard([this]() { emit eof(); });
- char data[256];
- auto buffer = static_cast<char *>(data);
- while (std::cin.get(buffer[0])) { // should poll/select and process events
- const int read = std::cin.readsome(buffer + 1, 255) + 1;
- emit receivedData(QByteArray(buffer, read));
+ const constexpr qsizetype bufSize = 1024;
+ qsizetype bytesInBuf = 0;
+ char bufferData[2 * bufSize];
+ char *buffer = static_cast<char *>(bufferData);
+
+ auto trySend = [this, &bytesInBuf, buffer]() {
+ if (bytesInBuf == 0)
+ return;
+ qsizetype toSend = bytesInBuf;
+ bytesInBuf = 0;
+ QByteArray dataToSend(buffer, toSend);
+ emit receivedData(dataToSend);
+ };
+ QHttpMessageStreamParser streamParser(
+ [](const QByteArray &, const QByteArray &) { /* just a header, do nothing */ },
+ [&trySend](const QByteArray &) {
+ // message body
+ trySend();
+ },
+ [&trySend](QtMsgType, QString) {
+ // there was an error
+ trySend();
+ },
+ QHttpMessageStreamParser::UNBUFFERED);
+
+ while (std::cin.get(buffer[bytesInBuf])) { // should poll/select and process events
+ qsizetype readNow = std::cin.readsome(buffer + bytesInBuf + 1, bufSize) + 1;
+ QByteArray toAdd(buffer + bytesInBuf, readNow);
+ bytesInBuf += readNow;
+ if (bytesInBuf >= bufSize)
+ trySend();
+ streamParser.receiveData(toAdd);
}
+ trySend();
}
signals:
void receivedData(const QByteArray &data);
@@ -180,7 +208,7 @@ int main(int argv, char *argc[])
QQmlLanguageServer qmlServer(
[&writeMutex](const QByteArray &data) {
QMutexLocker l(&writeMutex);
- std::cout.write(data.constData(), data.length());
+ std::cout.write(data.constData(), data.size());
std::cout.flush();
},
(parser.isSet(ignoreSettings) ? nullptr : &settings));
diff --git a/tools/qmlls/qqmlcodemodel.cpp b/tools/qmlls/qqmlcodemodel.cpp
index 1250978cee..e0d2c7d763 100644
--- a/tools/qmlls/qqmlcodemodel.cpp
+++ b/tools/qmlls/qqmlcodemodel.cpp
@@ -112,7 +112,7 @@ int QQmlCodeModel::indexEvalProgress() const
Q_ASSERT(!m_mutex.tryLock()); // should be called while locked
const int dirCost = 10;
int costToDo = 1;
- for (const ToIndex &el : qAsConst(m_toIndex))
+ for (const ToIndex &el : std::as_const(m_toIndex))
costToDo += dirCost * el.leftDepth;
costToDo += m_indexInProgressCost;
return m_indexDoneCost * 100 / (costToDo + m_indexDoneCost);
@@ -173,7 +173,6 @@ void QQmlCodeModel::indexDirectory(const QString &path, int depthLeft)
if (qmljs.isEmpty())
return;
DomItem newCurrent = m_currentEnv.makeCopy(DomItem::CopyOption::EnvConnected).item();
- int iFile = 0;
for (const QString &file : qmljs) {
if (indexCancelled())
return;
@@ -186,7 +185,6 @@ void QQmlCodeModel::indexDirectory(const QString &path, int depthLeft)
newCurrent.loadPendingDependencies();
newCurrent.commitToBase(m_validEnv.ownerAs<DomEnvironment>());
}
- ++iFile;
{
QMutexLocker l(&m_mutex);
++m_indexDoneCost;
@@ -408,7 +406,7 @@ void QQmlCodeModel::openUpdateEnd()
void QQmlCodeModel::newDocForOpenFile(const QByteArray &url, int version, const QString &docText)
{
qCDebug(codeModelLog) << "updating doc" << url << "to version" << version << "("
- << docText.length() << "chars)";
+ << docText.size() << "chars)";
DomItem newCurrent = m_currentEnv.makeCopy(DomItem::CopyOption::EnvConnected).item();
QStringList loadPaths = buildPathsForFileUrl(url);
loadPaths.append(QLibraryInfo::path(QLibraryInfo::QmlImportsPath));
@@ -527,9 +525,9 @@ QStringList QQmlCodeModel::buildPathsForFileUrl(const QByteArray &url)
}
// we want to longest match to be first, as it should override shorter matches
std::sort(roots.begin(), roots.end(), [](const QByteArray &el1, const QByteArray &el2) {
- if (el1.length() > el2.length())
+ if (el1.size() > el2.size())
return true;
- if (el1.length() < el2.length())
+ if (el1.size() < el2.size())
return false;
return el1 < el2;
});
@@ -538,7 +536,7 @@ QStringList QQmlCodeModel::buildPathsForFileUrl(const QByteArray &url)
if (!roots.isEmpty() && roots.last().isEmpty())
roots.removeLast();
QByteArray urlSlash(url);
- if (!urlSlash.isEmpty() && isNotSeparator(urlSlash.at(urlSlash.length() - 1)))
+ if (!urlSlash.isEmpty() && isNotSeparator(urlSlash.at(urlSlash.size() - 1)))
urlSlash.append('/');
// look if the file has a know prefix path
for (const QByteArray &root : roots) {
@@ -604,7 +602,7 @@ QStringList QQmlCodeModel::buildPathsForFileUrl(const QByteArray &url)
void QQmlCodeModel::setBuildPathsForRootUrl(QByteArray url, const QStringList &paths)
{
QMutexLocker l(&m_mutex);
- if (!url.isEmpty() && isNotSeparator(url.at(url.length() - 1)))
+ if (!url.isEmpty() && isNotSeparator(url.at(url.size() - 1)))
url.append('/');
if (paths.isEmpty())
m_buildPathsForRootUrl.remove(url);
@@ -671,7 +669,7 @@ QDebug OpenDocumentSnapshot::dump(QDebug dbg, DumpOptions options)
<< doc.field(Fields::code).value().toString() << "\n==========\n";
} else {
dbg << u" doc:"
- << (doc ? u"%1chars"_s.arg(doc.field(Fields::code).value().toString().length())
+ << (doc ? u"%1chars"_s.arg(doc.field(Fields::code).value().toString().size())
: u"*none*"_s)
<< "\n";
}
@@ -683,7 +681,7 @@ QDebug OpenDocumentSnapshot::dump(QDebug dbg, DumpOptions options)
} else {
dbg << u" validDoc:"
<< (validDoc ? u"%1chars"_s.arg(
- validDoc.field(Fields::code).value().toString().length())
+ validDoc.field(Fields::code).value().toString().size())
: u"*none*"_s)
<< "\n";
}
diff --git a/tools/qmlls/qqmllanguageserver.cpp b/tools/qmlls/qqmllanguageserver.cpp
index 7621f5bed1..48639f37d2 100644
--- a/tools/qmlls/qqmllanguageserver.cpp
+++ b/tools/qmlls/qqmllanguageserver.cpp
@@ -88,7 +88,7 @@ void QQmlLanguageServer::setupCapabilities(const QLspSpecification::InitializePa
{
Q_UNUSED(clientInfo);
QJsonObject expCap;
- if (serverInfo.capabilities.experimental->isObject())
+ if (serverInfo.capabilities.experimental.has_value() && serverInfo.capabilities.experimental->isObject())
expCap = serverInfo.capabilities.experimental->toObject();
expCap.insert(u"addBuildDirs"_s, QJsonObject({ { u"supported"_s, true } }));
serverInfo.capabilities.experimental = expCap;
diff --git a/tools/qmlls/textdocument.cpp b/tools/qmlls/textdocument.cpp
index 2e6dc2cbd9..b5d4cc6f68 100644
--- a/tools/qmlls/textdocument.cpp
+++ b/tools/qmlls/textdocument.cpp
@@ -13,7 +13,7 @@ TextDocument::TextDocument(const QString &text)
TextBlock TextDocument::findBlockByNumber(int blockNumber) const
{
- return (blockNumber >= 0 && blockNumber < m_blocks.length())
+ return (blockNumber >= 0 && blockNumber < m_blocks.size())
? m_blocks.at(blockNumber).textBlock
: TextBlock();
}
@@ -30,7 +30,7 @@ QChar TextDocument::characterAt(int pos) const
int TextDocument::characterCount() const
{
- return m_content.length();
+ return m_content.size();
}
TextBlock TextDocument::begin() const
@@ -70,7 +70,7 @@ void TextDocument::setPlainText(const QString &text)
int blockStart = 0;
int blockNumber = 0;
- while (blockStart < text.length()) {
+ while (blockStart < text.size()) {
Block block;
block.textBlock.setBlockNumber(blockNumber++);
block.textBlock.setPosition(blockStart);
@@ -78,7 +78,7 @@ void TextDocument::setPlainText(const QString &text)
int blockEnd = text.indexOf('\n', blockStart) + 1;
if (blockEnd == 0)
- blockEnd = text.length();
+ blockEnd = text.size();
block.textBlock.setLength(blockEnd - blockStart);
m_blocks.append(block);
@@ -98,13 +98,13 @@ void TextDocument::setModified(bool modified)
void TextDocument::setUserState(int blockNumber, int state)
{
- if (blockNumber >= 0 && blockNumber < m_blocks.length())
+ if (blockNumber >= 0 && blockNumber < m_blocks.size())
m_blocks[blockNumber].userState = state;
}
int TextDocument::userState(int blockNumber) const
{
- return (blockNumber >= 0 && blockNumber < m_blocks.length()) ? m_blocks[blockNumber].userState
+ return (blockNumber >= 0 && blockNumber < m_blocks.size()) ? m_blocks[blockNumber].userState
: -1;
}
diff --git a/tools/qmlls/workspace.cpp b/tools/qmlls/workspace.cpp
index 8291afc671..a18d5f6f8d 100644
--- a/tools/qmlls/workspace.cpp
+++ b/tools/qmlls/workspace.cpp
@@ -152,7 +152,7 @@ void WorkspaceHandlers::clientInitialized(QLanguageServer *server)
if (clientInfo.workspaceFolders
&& std::holds_alternative<QList<WorkspaceFolder>>(*clientInfo.workspaceFolders)) {
for (const WorkspaceFolder &workspace :
- qAsConst(std::get<QList<WorkspaceFolder>>(*clientInfo.workspaceFolders))) {
+ std::as_const(std::get<QList<WorkspaceFolder>>(*clientInfo.workspaceFolders))) {
const QUrl workspaceUrl(QString::fromUtf8(QmlLsp::lspUriToQmlUrl(workspace.uri)));
rootPaths.insert(workspaceUrl.toLocalFile());
}
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index 7180c33b47..86466a3928 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -496,7 +496,7 @@ public:
}
}
- for (const QMetaObject *meta : qAsConst(objectsToMerge)) {
+ for (const QMetaObject *meta : std::as_const(objectsToMerge)) {
for (int index = meta->enumeratorOffset(); index < meta->enumeratorCount(); ++index)
dump(meta->enumerator(index));
@@ -629,11 +629,11 @@ private:
if (typeName->endsWith('*')) {
*isPointer = true;
- typeName->truncate(typeName->length() - 1);
+ typeName->truncate(typeName->size() - 1);
removePointerAndList(typeName, isList, isPointer);
} else if (typeName->startsWith(declListPrefix)) {
*isList = true;
- typeName->truncate(typeName->length() - 1); // get rid of the suffix '>'
+ typeName->truncate(typeName->size() - 1); // get rid of the suffix '>'
*typeName = typeName->mid(declListPrefix.size());
removePointerAndList(typeName, isList, isPointer);
}
@@ -885,7 +885,7 @@ static bool getDependencies(const QQmlEngine &engine, const QString &pluginImpor
if (!importScanner.waitForFinished()) {
std::cerr << "failure to start " << qPrintable(command);
- for (const QString &arg : qAsConst(commandArgs))
+ for (const QString &arg : std::as_const(commandArgs))
std::cerr << ' ' << qPrintable(arg);
std::cerr << std::endl;
return false;
@@ -920,18 +920,18 @@ bool dependencyBetter(const QString &lhs, const QString &rhs)
if (leftModule > rightModule)
return false;
- if (leftSegments.length() == 1)
+ if (leftSegments.size() == 1)
return false;
- if (rightSegments.length() == 1)
+ if (rightSegments.size() == 1)
return true;
const QStringList leftVersion = leftSegments.at(1).split(QLatin1Char('.'));
const QStringList rightVersion = rightSegments.at(1).split(QLatin1Char('.'));
auto compareSegment = [&](int segmentIndex) {
- if (leftVersion.length() <= segmentIndex)
- return rightVersion.length() > segmentIndex ? 1 : 0;
- if (rightVersion.length() <= segmentIndex)
+ if (leftVersion.size() <= segmentIndex)
+ return rightVersion.size() > segmentIndex ? 1 : 0;
+ if (rightVersion.size() <= segmentIndex)
return -1;
bool leftOk = false;
@@ -1198,7 +1198,7 @@ int main(int argc, char *argv[])
// load the QtQml builtins and the dependencies
{
QByteArray code(qtQmlImportString.toUtf8());
- for (const QString &moduleToImport : qAsConst(dependencies)) {
+ for (const QString &moduleToImport : std::as_const(dependencies)) {
code.append("\nimport ");
code.append(moduleToImport.toUtf8());
}
@@ -1262,7 +1262,7 @@ int main(int argc, char *argv[])
QString::number(qtObjectType.version().minorVersion())).toUtf8();
}
// avoid importing dependencies?
- for (const QString &moduleToImport : qAsConst(dependencies)) {
+ for (const QString &moduleToImport : std::as_const(dependencies)) {
importCode.append("\nimport ");
importCode.append(moduleToImport.toUtf8());
}
@@ -1299,7 +1299,7 @@ int main(int argc, char *argv[])
it->erase(std::unique(it->begin(), it->end()), it->end());
}
- for (const QMetaObject *mo : qAsConst(candidates)) {
+ for (const QMetaObject *mo : std::as_const(candidates)) {
if (mo->className() != QLatin1String("Qt"))
metas.insert(mo);
}
@@ -1327,13 +1327,13 @@ int main(int argc, char *argv[])
// put the metaobjects into a map so they are always dumped in the same order
QMap<QString, const QMetaObject *> nameToMeta;
- for (const QMetaObject *meta : qAsConst(metas))
+ for (const QMetaObject *meta : std::as_const(metas))
nameToMeta.insert(convertToId(meta), meta);
Dumper dumper(&qml);
if (relocatable)
dumper.setRelocatableModuleUri(pluginImportUri);
- for (const QMetaObject *meta : qAsConst(nameToMeta)) {
+ for (const QMetaObject *meta : std::as_const(nameToMeta)) {
dumper.dump(QQmlEnginePrivate::get(&engine), meta, uncreatableMetas.contains(meta), singletonMetas.contains(meta));
}
diff --git a/tools/qmlpreview/qmlpreviewfilesystemwatcher.cpp b/tools/qmlpreview/qmlpreviewfilesystemwatcher.cpp
index 9034b3559e..4db2c03b20 100644
--- a/tools/qmlpreview/qmlpreviewfilesystemwatcher.cpp
+++ b/tools/qmlpreview/qmlpreviewfilesystemwatcher.cpp
@@ -119,7 +119,7 @@ void QmlPreviewFileSystemWatcher::onDirectoryChanged(const QString &path)
toReadd.removeOne(rejected);
// If we've successfully added the file, that means it was deleted and replaced.
- for (const QString &reAdded : qAsConst(toReadd))
+ for (const QString &reAdded : std::as_const(toReadd))
emit fileChanged(reAdded);
}
}
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index 2c2a387ff7..04752cd4e0 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -383,7 +383,7 @@ void QmlProfilerApplication::userCommand(const QString &command)
} else if (m_profilerData->isEmpty()) {
prompt(tr("No data was recorded so far."));
} else {
- m_interactiveOutputFile = args.length() > 0 ? args.at(0).toString() : m_outputFile;
+ m_interactiveOutputFile = args.size() > 0 ? args.at(0).toString() : m_outputFile;
if (checkOutputFile(REQUEST_OUTPUT_FILE))
output();
}
@@ -400,7 +400,7 @@ void QmlProfilerApplication::userCommand(const QString &command)
if (!m_recording && m_profilerData->isEmpty()) {
prompt(tr("No data was recorded so far."));
} else {
- m_interactiveOutputFile = args.length() > 0 ? args.at(0).toString() : m_outputFile;
+ m_interactiveOutputFile = args.size() > 0 ? args.at(0).toString() : m_outputFile;
if (checkOutputFile(REQUEST_FLUSH_FILE))
flush();
}
diff --git a/tools/qmlprofiler/qmlprofilerdata.cpp b/tools/qmlprofiler/qmlprofilerdata.cpp
index 51ac32f2d5..8f75226fd8 100644
--- a/tools/qmlprofiler/qmlprofilerdata.cpp
+++ b/tools/qmlprofiler/qmlprofilerdata.cpp
@@ -211,7 +211,7 @@ void QmlProfilerData::computeQmlTime()
qint64 level0Start = -1;
int level = 0;
- for (const QQmlProfilerEvent &event : qAsConst(d->events)) {
+ for (const QQmlProfilerEvent &event : std::as_const(d->events)) {
const QQmlProfilerEventType &type = d->eventTypes.at(event.typeIndex());
if (type.message() != MaximumMessage)
continue;
@@ -248,7 +248,7 @@ bool compareStartTimes(const QQmlProfilerEvent &t1, const QQmlProfilerEvent &t2)
void QmlProfilerData::sortStartTimes()
{
- if (d->events.count() < 2)
+ if (d->events.size() < 2)
return;
// assuming startTimes is partially sorted
@@ -510,7 +510,7 @@ bool QmlProfilerData::save(const QString &filename)
}
};
- for (const QQmlProfilerEvent &event : qAsConst(d->events)) {
+ for (const QQmlProfilerEvent &event : std::as_const(d->events)) {
const QQmlProfilerEventType &type = d->eventTypes.at(event.typeIndex());
if (type.rangeType() != MaximumRangeType) {
@@ -523,7 +523,7 @@ bool QmlProfilerData::save(const QString &filename)
}
case RangeEnd: {
QStack<qint64> &ends = rangeEnds[type.rangeType()];
- if (starts.length() > ends.length()) {
+ if (starts.size() > ends.size()) {
ends.push(event.timestamp());
if (--level == 0)
sendPending();
@@ -542,7 +542,7 @@ bool QmlProfilerData::save(const QString &filename)
}
for (int i = 0; i < MaximumRangeType; ++i) {
- while (rangeEnds[i].length() < rangeStarts[i].length()) {
+ while (rangeEnds[i].size() < rangeStarts[i].size()) {
rangeEnds[i].push(d->traceEndTime);
--level;
}
@@ -597,7 +597,7 @@ void QmlProfilerData::setState(QmlProfilerData::State state)
int QmlProfilerData::numLoadedEventTypes() const
{
- return d->eventTypes.length();
+ return d->eventTypes.size();
}
#include "moc_qmlprofilerdata.cpp"
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index f4d11caca4..891b7534bd 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -86,7 +86,7 @@ void RenderStatistics::updateStats()
void RenderStatistics::printTotalStats()
{
- int count = timePerFrame.count();
+ int count = timePerFrame.size();
if (count == 0)
return;
@@ -311,7 +311,7 @@ static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory)
if (dummyData) {
fprintf(stderr, "Loaded dummy data: %s\n", qPrintable(dir.filePath(qml)));
- qml.truncate(qml.length()-4);
+ qml.truncate(qml.size()-4);
engine.rootContext()->setContextProperty(qml, dummyData);
dummyData->setParent(&engine);
}
@@ -454,7 +454,7 @@ int main(int argc, char ** argv)
}
QSurfaceFormat::setDefaultFormat(surfaceFormat);
- for (Qt::ApplicationAttribute a : qAsConst(options.applicationAttributes))
+ for (Qt::ApplicationAttribute a : std::as_const(options.applicationAttributes))
QCoreApplication::setAttribute(a);
QScopedPointer<QGuiApplication> app;
#ifdef QT_WIDGETS_LIB
diff --git a/tools/qmltc/main.cpp b/tools/qmltc/main.cpp
index cf47943034..4fbd01ff25 100644
--- a/tools/qmltc/main.cpp
+++ b/tools/qmltc/main.cpp
@@ -16,6 +16,7 @@
#include <QtCore/qfileinfo.h>
#include <QtCore/qlibraryinfo.h>
#include <QtCore/qcommandlineparser.h>
+#include <QtCore/qregularexpression.h>
#include <QtQml/private/qqmljslexer_p.h>
#include <QtQml/private/qqmljsparser_p.h>
@@ -58,6 +59,14 @@ int main(int argc, char **argv)
parser.addHelpOption();
parser.addVersionOption();
+ QCommandLineOption bareOption {
+ u"bare"_s,
+ QCoreApplication::translate(
+ "main", "Do not include default import directories. This may be used to run "
+ "qmltc on a project using a different Qt version.")
+ };
+ parser.addOption(bareOption);
+
QCommandLineOption importPathOption {
u"I"_s, QCoreApplication::translate("main", "Look for QML modules in specified directory"),
QCoreApplication::translate("main", "import directory")
@@ -114,6 +123,15 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
+ static QRegularExpression nameChecker(u"^[a-zA-Z_][a-zA-Z0-9_]*\\.qml$"_s);
+ if (auto match = nameChecker.match(QUrl(url).fileName()); !match.hasMatch()) {
+ fprintf(stderr,
+ "The given QML filename is unsuited for type compilation: the name must consist of "
+ "letters, digits and underscores, starting with "
+ "a letter or an underscore and ending in '.qml'!\n");
+ return EXIT_FAILURE;
+ }
+
QString sourceCode = loadUrl(url);
if (sourceCode.isEmpty())
return EXIT_FAILURE;
@@ -123,7 +141,8 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
QStringList importPaths = parser.values(importPathOption);
- importPaths.append(QLibraryInfo::path(QLibraryInfo::QmlImportsPath));
+ if (!parser.isSet(bareOption))
+ importPaths.append(QLibraryInfo::path(QLibraryInfo::QmlImportsPath));
QStringList qmldirFiles = parser.values(qmldirOption);
QString outputCppFile;
diff --git a/tools/qmltc/qmltccodewriter.cpp b/tools/qmltc/qmltccodewriter.cpp
index 7c9958e215..b2722d1e37 100644
--- a/tools/qmltc/qmltccodewriter.cpp
+++ b/tools/qmltc/qmltccodewriter.cpp
@@ -199,23 +199,23 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcProgram &progra
writeUrl(code, program.urlMethod);
// forward declare all the types first
- for (const QmltcType &type : qAsConst(program.compiledTypes))
+ for (const QmltcType &type : std::as_const(program.compiledTypes))
code.rawAppendToHeader(u"class " + type.cppType + u";");
// write all the types and their content
- for (const QmltcType &type : qAsConst(program.compiledTypes))
+ for (const QmltcType &type : std::as_const(program.compiledTypes))
write(code, type);
// add typeCount definitions. after all types have been written down (so
// they are now complete types as per C++). practically, this only concerns
// document root type
- for (const QmltcType &type : qAsConst(program.compiledTypes)) {
+ for (const QmltcType &type : std::as_const(program.compiledTypes)) {
if (!type.typeCount)
continue;
code.rawAppendToHeader(u""); // blank line
code.rawAppendToHeader(u"constexpr %1 %2::%3()"_s.arg(type.typeCount->returnType,
type.cppType, type.typeCount->name));
code.rawAppendToHeader(u"{");
- for (const QString &line : qAsConst(type.typeCount->body))
+ for (const QString &line : std::as_const(type.typeCount->body))
code.rawAppendToHeader(line, 1);
code.rawAppendToHeader(u"}");
}
@@ -240,7 +240,7 @@ static void dumpFunctions(QmltcOutputWrapper &code, const QList<QmltcMethod> &fu
for (auto it = orderedFunctions.cbegin(); it != orderedFunctions.cend(); ++it) {
code.rawAppendToHeader(it.key() + u":", -1);
- for (const QmltcMethod *function : qAsConst(it.value()))
+ for (const QmltcMethod *function : std::as_const(it.value()))
QmltcCodeWriter::write(code, *function);
}
}
@@ -264,7 +264,7 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcType &type)
code.rawAppendToHeader(constructClassString());
code.rawAppendToHeader(u"{");
- for (const QString &mocLine : qAsConst(type.mocCode))
+ for (const QString &mocLine : std::as_const(type.mocCode))
code.rawAppendToHeader(mocLine, 1);
QmltcOutputWrapper::MemberNameScope typeScope(&code, type.cppType);
@@ -294,7 +294,7 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcType &type)
QmltcCodeWriter::write(code, *type.dtor);
// enums
- for (const auto &enumeration : qAsConst(type.enums))
+ for (const auto &enumeration : std::as_const(type.enums))
QmltcCodeWriter::write(code, enumeration);
// visible functions
@@ -331,7 +331,7 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcType &type)
}
// children
- for (const auto &child : qAsConst(type.children))
+ for (const auto &child : std::as_const(type.children))
QmltcCodeWriter::write(code, child);
// (non-visible) functions
@@ -342,14 +342,14 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcType &type)
code.rawAppendToHeader(u""); // blank line
code.rawAppendToHeader(u"protected:", -1);
}
- for (const auto &property : qAsConst(type.properties))
+ for (const auto &property : std::as_const(type.properties))
write(code, property);
- for (const auto &variable : qAsConst(type.variables))
+ for (const auto &variable : std::as_const(type.variables))
write(code, variable);
}
code.rawAppendToHeader(u"private:", -1);
- for (const QString &otherLine : qAsConst(type.otherCode))
+ for (const QString &otherLine : std::as_const(type.otherCode))
code.rawAppendToHeader(otherLine, 1);
if (type.typeCount) {
@@ -396,7 +396,7 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcMethod &method)
{
QmltcOutputWrapper::CppIndentationScope cppIndent(&code);
Q_UNUSED(cppIndent);
- for (const QString &line : qAsConst(method.body))
+ for (const QString &line : std::as_const(method.body))
code.rawAppendToCpp(line);
}
code.rawAppendToCpp(u"}");
@@ -419,7 +419,7 @@ static void writeSpecialMethod(QmltcOutputWrapper &code, const QmltcMethodBase &
{
QmltcOutputWrapper::CppIndentationScope cppIndent(&code);
Q_UNUSED(cppIndent);
- for (const QString &line : qAsConst(specialMethod.body))
+ for (const QString &line : std::as_const(specialMethod.body))
code.rawAppendToCpp(line);
}
code.rawAppendToCpp(u"}");
@@ -472,7 +472,7 @@ void QmltcCodeWriter::writeUrl(QmltcOutputWrapper &code, const QmltcMethod &urlM
{
QmltcOutputWrapper::CppIndentationScope cppIndent(&code);
Q_UNUSED(cppIndent);
- for (const QString &line : qAsConst(urlMethod.body))
+ for (const QString &line : std::as_const(urlMethod.body))
code.rawAppendToCpp(line);
}
code.rawAppendToCpp(u"}");
diff --git a/tools/qmltc/qmltccommandlineutils.cpp b/tools/qmltc/qmltccommandlineutils.cpp
index d6c6a9242c..e3f6b4d3b7 100644
--- a/tools/qmltc/qmltccommandlineutils.cpp
+++ b/tools/qmltc/qmltccommandlineutils.cpp
@@ -43,7 +43,7 @@ QString loadUrl(const QString &url)
}
QByteArray data(fi.size(), Qt::Uninitialized);
- if (f.read(data.data(), data.length()) != data.length()) {
+ if (f.read(data.data(), data.size()) != data.size()) {
fprintf(stderr, "Unable to read \"%s\": %s.\n",
qPrintable(QDir::toNativeSeparators(fi.absoluteFilePath())),
qPrintable(f.errorString()));
diff --git a/tools/qmltc/qmltccompiler.cpp b/tools/qmltc/qmltccompiler.cpp
index 66d10eaa83..a8200d41d1 100644
--- a/tools/qmltc/qmltccompiler.cpp
+++ b/tools/qmltc/qmltccompiler.cpp
@@ -245,7 +245,7 @@ void QmltcCompiler::compileType(
}
// compilation stub:
- current.externalCtor.body << u"Q_UNUSED(engine);"_s;
+ current.externalCtor.body << u"Q_UNUSED(engine)"_s;
if (documentRoot) {
current.externalCtor.body << u"// document root:"_s;
// if it's document root, we want to create our QQmltcObjectCreationBase
@@ -310,7 +310,7 @@ void QmltcCompiler::compileTypeElements(QmltcType &current, const QQmlJSScope::C
[](const QQmlJSMetaProperty &x, const QQmlJSMetaProperty &y) {
return x.index() < y.index();
});
- for (const QQmlJSMetaProperty &p : qAsConst(properties)) {
+ for (const QQmlJSMetaProperty &p : std::as_const(properties)) {
if (p.index() == -1) {
recordError(type->sourceLocation(),
u"Internal error: property '%1' has incomplete information"_s.arg(
@@ -1042,7 +1042,7 @@ void QmltcCompiler::compileBinding(QmltcType &current, const QQmlJSMetaPropertyB
auto subbindings = attachedType->ownPropertyBindingsInQmlIROrder();
// compile bindings of the attached property
partitionBindings(subbindings.begin(), subbindings.end());
- for (const auto &b : qAsConst(subbindings)) {
+ for (const auto &b : std::as_const(subbindings)) {
compileBinding(current, b, attachedType,
{ type, attachedMemberName, propertyName, false });
}
diff --git a/tools/qmltc/qmltccompilerpieces.h b/tools/qmltc/qmltccompilerpieces.h
index fc27ab76cc..e316321a20 100644
--- a/tools/qmltc/qmltccompilerpieces.h
+++ b/tools/qmltc/qmltccompilerpieces.h
@@ -136,7 +136,7 @@ inline decltype(auto) QmltcCodeGenerator::generate_initCode(QmltcType &current,
// * bool canFinalize [optional, when document root]
const bool isDocumentRoot = type == visitor->result();
- current.init.body << u"Q_UNUSED(creator);"_s; // can happen sometimes
+ current.init.body << u"Q_UNUSED(creator)"_s; // can happen sometimes
current.init.body << u"auto context = parentContext;"_s;
@@ -182,7 +182,7 @@ inline decltype(auto) QmltcCodeGenerator::generate_initCode(QmltcType &current,
current.init.body
<< QStringLiteral("auto %1 = QQmlEnginePrivate::get(engine);").arg(privateEngineName);
- current.init.body << QStringLiteral("Q_UNUSED(%1);").arg(privateEngineName); // precaution
+ current.init.body << QStringLiteral("Q_UNUSED(%1)").arg(privateEngineName); // precaution
// when generating root, we need to create a new (document-level) context.
// otherwise, just use existing context as is
@@ -379,8 +379,8 @@ inline void QmltcCodeGenerator::generate_endInitCode(QmltcType &current,
// QML_endInit()'s parameters:
// * QQmltcObjectCreationHelper* creator
// * QQmlEngine* engine
- current.endInit.body << u"Q_UNUSED(creator);"_s;
- current.endInit.body << u"Q_UNUSED(engine);"_s;
+ current.endInit.body << u"Q_UNUSED(creator)"_s;
+ current.endInit.body << u"Q_UNUSED(engine)"_s;
generate_qmltcInstructionCallCode(&current.endInit, type, u"engine"_s, u"creator, engine"_s);
@@ -415,8 +415,8 @@ QmltcCodeGenerator::generate_setComplexBindingsCode(QmltcType &current,
// QML_setComplexBindings()'s parameters:
// * QQmltcObjectCreationHelper* creator
// * QQmlEngine* engine
- current.setComplexBindings.body << u"Q_UNUSED(creator);"_s;
- current.setComplexBindings.body << u"Q_UNUSED(engine);"_s;
+ current.setComplexBindings.body << u"Q_UNUSED(creator)"_s;
+ current.setComplexBindings.body << u"Q_UNUSED(engine)"_s;
generate_qmltcInstructionCallCode(&current.setComplexBindings, type, u"engine"_s,
u"creator, engine"_s);
@@ -440,9 +440,9 @@ inline void QmltcCodeGenerator::generate_interfaceCallCode(QmltcMethod *function
// * QQmltcObjectCreationHelper* creator
// * bool canFinalize [optional, when document root]
const bool isDocumentRoot = type == visitor->result();
- function->body << u"Q_UNUSED(creator);"_s;
+ function->body << u"Q_UNUSED(creator)"_s;
if (isDocumentRoot)
- function->body << u"Q_UNUSED(canFinalize);"_s;
+ function->body << u"Q_UNUSED(canFinalize)"_s;
if (auto base = type->baseType(); base->isComposite()) {
function->body << u"// call base's method"_s;
@@ -550,7 +550,7 @@ QmltcCodeGenerator::generate_handleOnCompletedCode(QmltcType &current,
// QML_handleOnCompleted()'s parameters:
// * QQmltcObjectCreationHelper* creator
- current.handleOnCompleted.body << u"Q_UNUSED(creator);"_s;
+ current.handleOnCompleted.body << u"Q_UNUSED(creator)"_s;
generate_qmltcInstructionCallCode(&current.handleOnCompleted, type, QString(), u"creator"_s);
}
diff --git a/tools/qmltc/qmltcvisitor.cpp b/tools/qmltc/qmltcvisitor.cpp
index efe573d05d..d15f1dbe2f 100644
--- a/tools/qmltc/qmltcvisitor.cpp
+++ b/tools/qmltc/qmltcvisitor.cpp
@@ -36,6 +36,12 @@ static bool isExplicitComponent(const QQmlJSScope::ConstPtr &type)
return base && base->internalName() == u"QQmlComponent";
}
+/*! \internal
+ Returns if type is an implicit component.
+ This method should only be called after implicit components
+ are detected, that is, after QQmlJSImportVisitor::endVisit(UiProgram *)
+ was called.
+ */
static bool isImplicitComponent(const QQmlJSScope::ConstPtr &type)
{
if (!type->isComposite())
@@ -45,6 +51,12 @@ static bool isImplicitComponent(const QQmlJSScope::ConstPtr &type)
return type->isComponentRootElement() && !isComponentBased;
}
+/*! \internal
+ Checks if type is inside or a (implicit or explicit) component.
+ This method should only be called after implicit components
+ are detected, that is, after QQmlJSImportVisitor::endVisit(UiProgram *)
+ was called.
+ */
static bool isOrUnderComponent(QQmlJSScope::ConstPtr type)
{
Q_ASSERT(type->isComposite()); // we're dealing with composite types here
@@ -186,11 +198,7 @@ bool QmltcVisitor::visit(QQmlJS::AST::UiObjectDefinition *object)
addCleanQmlTypeName(&m_qmlTypeNames, m_currentScope);
// give C++-relevant internal names to QMLScopes, we can use them later in compiler
m_currentScope->setInternalName(uniqueNameFromPieces(m_qmlTypeNames, m_qmlTypeNameCounts));
-
- if (auto base = m_currentScope->baseType();
- base && base->isComposite() && !isOrUnderComponent(m_currentScope)) {
- m_qmlTypesWithQmlBases.append(m_currentScope);
- }
+ m_qmlTypesWithQmlBases.append(m_currentScope);
return true;
}
@@ -212,11 +220,7 @@ bool QmltcVisitor::visit(QQmlJS::AST::UiObjectBinding *uiob)
// give C++-relevant internal names to QMLScopes, we can use them later in compiler
m_currentScope->setInternalName(uniqueNameFromPieces(m_qmlTypeNames, m_qmlTypeNameCounts));
- if (auto base = m_currentScope->baseType();
- base && base->isComposite() && !isOrUnderComponent(m_currentScope)) {
- m_qmlTypesWithQmlBases.append(m_currentScope);
- }
-
+ m_qmlTypesWithQmlBases.append(m_currentScope);
return true;
}
@@ -309,7 +313,7 @@ void QmltcVisitor::endVisit(QQmlJS::AST::UiProgram *program)
return;
QHash<QQmlJSScope::ConstPtr, QList<QQmlJSMetaPropertyBinding>> bindings;
- for (const QQmlJSScope::ConstPtr &type : qAsConst(m_qmlTypes)) {
+ for (const QQmlJSScope::ConstPtr &type : std::as_const(m_qmlTypes)) {
if (isOrUnderComponent(type))
continue;
bindings.insert(type, type->ownPropertyBindingsInQmlIROrder());
@@ -408,13 +412,15 @@ void iterateBindings(
}
}
+/*! \internal
+ This is a special function that must be called after
+ QQmlJSImportVisitor::endVisit(QQmlJS::AST::UiProgram *). It is used to
+ resolve things that couldn't be resolved during the AST traversal, such
+ as anything that is dependent on implicit or explicit components
+*/
void QmltcVisitor::postVisitResolve(
const QHash<QQmlJSScope::ConstPtr, QList<QQmlJSMetaPropertyBinding>> &qmlIrOrderedBindings)
{
- // This is a special function that must be called after
- // QQmlJSImportVisitor::endVisit(QQmlJS::AST::UiProgram *). It is used to
- // resolve things that couldn't be resolved during the AST traversal, such
- // as anything that is dependent on implicit or explicit components
// match scopes to indices of QmlIR::Object from QmlIR::Document
qsizetype count = 0;
@@ -480,19 +486,30 @@ void QmltcVisitor::postVisitResolve(
// add explicit components to the object creation indices
{
qsizetype index = 0;
- for (const QQmlJSScope::ConstPtr &c : qAsConst(explicitComponents))
+ for (const QQmlJSScope::ConstPtr &c : std::as_const(explicitComponents))
m_creationIndices[c] = m_pureQmlTypes.size() + index++;
}
- // filter out deferred types
- {
- QList<QQmlJSScope::ConstPtr> filteredQmlTypesWithQmlBases;
- filteredQmlTypesWithQmlBases.reserve(m_qmlTypesWithQmlBases.size());
- std::copy_if(m_qmlTypesWithQmlBases.cbegin(), m_qmlTypesWithQmlBases.cend(),
- std::back_inserter(filteredQmlTypesWithQmlBases),
- [&](const QQmlJSScope::ConstPtr &type) { return !isOrUnderDeferred(type); });
- qSwap(m_qmlTypesWithQmlBases, filteredQmlTypesWithQmlBases);
- }
+ // m_qmlTypesWithQmlBases should contain the types to be compiled.
+ // Some types should not be compiled and are therefore filtered out:
+ // * deferred types
+ // * types inside of capital-c-Components (implicit and explicit)
+ // * non-composite types (that is, types not defined in qml)
+ //
+ // This can not be done earlier as implicitly wrapped Components are
+ // only known after visitation is over!
+
+ // filter step:
+ QList<QQmlJSScope::ConstPtr> filteredQmlTypesWithQmlBases;
+ filteredQmlTypesWithQmlBases.reserve(m_qmlTypesWithQmlBases.size());
+ std::copy_if(m_qmlTypesWithQmlBases.cbegin(), m_qmlTypesWithQmlBases.cend(),
+ std::back_inserter(filteredQmlTypesWithQmlBases),
+ [&](const QQmlJSScope::ConstPtr &type) {
+ auto base = type->baseType();
+ return base && base->isComposite() && !isOrUnderComponent(type)
+ && !isOrUnderDeferred(type);
+ });
+ qSwap(m_qmlTypesWithQmlBases, filteredQmlTypesWithQmlBases);
// count QmlIR::Objects in the document - the amount is used to calculate
// object indices of implicit components
diff --git a/tools/shared/qqmltoolingsettings.cpp b/tools/shared/qqmltoolingsettings.cpp
index 6bfd419aa2..dffd59fbc7 100644
--- a/tools/shared/qqmltoolingsettings.cpp
+++ b/tools/shared/qqmltoolingsettings.cpp
@@ -83,7 +83,7 @@ bool QQmlToolingSettings::search(const QString &path)
const QString iniFile = dir.absoluteFilePath(settingsFileName);
if (read(iniFile)) {
- for (const QString &dir : qAsConst(dirs))
+ for (const QString &dir : std::as_const(dirs))
m_seenDirectories[dir] = iniFile;
return true;
}
@@ -94,7 +94,7 @@ bool QQmlToolingSettings::search(const QString &path)
if (const QString iniFile = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, u"%1.ini"_s.arg(m_toolName)); !iniFile.isEmpty()) {
if (read(iniFile)) {
- for (const QString &dir : qAsConst(dirs))
+ for (const QString &dir : std::as_const(dirs))
m_seenDirectories[dir] = iniFile;
return true;
}
@@ -102,7 +102,7 @@ bool QQmlToolingSettings::search(const QString &path)
// No INI file found anywhere, record the failure so we won't have to traverse the entire
// filesystem again
- for (const QString &dir : qAsConst(dirs))
+ for (const QString &dir : std::as_const(dirs))
m_seenDirectories[dir] = QString();
return false;